diff options
author | Primiano Tucci <primiano@google.com> | 2014-09-30 14:45:55 +0100 |
---|---|---|
committer | Primiano Tucci <primiano@google.com> | 2014-09-30 14:45:55 +0100 |
commit | 1320f92c476a1ad9d19dba2a48c72b75566198e9 (patch) | |
tree | ea7f149ccad687b22c18a72b729646568b2d54fb /build | |
parent | 39b78c562f50ad7d5551ee861121f899239525a2 (diff) | |
download | chromium_org-1320f92c476a1ad9d19dba2a48c72b75566198e9.tar.gz |
Merge from Chromium at DEPS revision 267aeeb8d85c
This commit was generated by merge_to_master.py.
Change-Id: Id3aac9713b301fae64408cdaee0888724eeb7c0e
Diffstat (limited to 'build')
137 files changed, 4294 insertions, 1033 deletions
diff --git a/build/all.gyp b/build/all.gyp index e6d2446614..4cafea2808 100644 --- a/build/all.gyp +++ b/build/all.gyp @@ -39,8 +39,25 @@ ['OS=="ios"', { 'dependencies': [ '../ios/ios.gyp:*', + # NOTE: This list of targets is present because + # mojo_base.gyp:mojo_base cannot be built on iOS, as + # javascript-related targets cause v8 to be built. + '../mojo/mojo_base.gyp:mojo_common_lib', + '../mojo/mojo_base.gyp:mojo_common_unittests', + '../mojo/mojo_base.gyp:mojo_cpp_bindings', + '../mojo/mojo_base.gyp:mojo_public_bindings_unittests', + '../mojo/mojo_base.gyp:mojo_public_environment_unittests', + '../mojo/mojo_base.gyp:mojo_public_system_perftests', + '../mojo/mojo_base.gyp:mojo_public_system_unittests', + '../mojo/mojo_base.gyp:mojo_public_test_utils', + '../mojo/mojo_base.gyp:mojo_public_utility_unittests', + '../mojo/mojo_base.gyp:mojo_system', + '../mojo/mojo_base.gyp:mojo_system_impl', + '../mojo/mojo_base.gyp:mojo_system_unittests', + '../google_apis/google_apis.gyp:google_apis_unittests', + '../ui/base/ui_base_tests.gyp:ui_unittests', + '../ui/ios/ui_ios_tests.gyp:ui_ios_unittests', '../ui/gfx/gfx_tests.gyp:gfx_unittests', - '../ui/ui_unittests.gyp:ui_unittests', ], }], ['OS=="android"', { @@ -51,8 +68,10 @@ '<@(android_app_targets)', 'android_builder_tests', '../android_webview/android_webview.gyp:android_webview_apk', + '../android_webview/android_webview.gyp:system_webview_apk', '../android_webview/android_webview_telemetry_shell.gyp:android_webview_telemetry_shell_apk', '../chrome/chrome.gyp:chrome_shell_apk', + '../chrome/chrome.gyp:chrome_sync_shell_apk', '../remoting/remoting.gyp:remoting_apk', '../tools/telemetry/telemetry.gyp:*#host', # TODO(nyquist) This should instead by a target for sync when all of @@ -79,6 +98,7 @@ 'dependencies': [ '../third_party/re2/re2.gyp:re2', '../chrome/chrome.gyp:*', + '../chrome/tools/profile_reset/jtl_compiler.gyp:*', '../cc/blink/cc_blink_tests.gyp:*', '../cc/cc_tests.gyp:*', '../device/bluetooth/bluetooth.gyp:*', @@ -233,7 +253,7 @@ '../google_apis/gcm/gcm.gyp:*', ], }], - ['chromeos==1 or (OS=="linux" and use_aura==1)', { + ['chromeos==1 or (OS=="linux" and use_aura==1) or OS=="win"', { 'dependencies': [ '../extensions/shell/app_shell.gyp:*', ], @@ -269,9 +289,9 @@ '../net/net.gyp:net_unittests', '../sql/sql.gyp:sql_unittests', '../sync/sync.gyp:sync_unit_tests', + '../ui/base/ui_base_tests.gyp:ui_unittests', '../ui/display/display.gyp:display_unittests', '../ui/gfx/gfx_tests.gyp:gfx_unittests', - '../ui/ui_unittests.gyp:ui_unittests', '../url/url.gyp:url_unittests', ], 'conditions': [ @@ -413,6 +433,7 @@ }], ['disable_nacl==0 and disable_nacl_untrusted==0', { 'dependencies': [ + '../mojo/mojo_nacl.gyp:*', '../testing/gtest_nacl.gyp:*', ], }], @@ -523,6 +544,7 @@ '../gpu/gles2_conform_support/gles2_conform_test.gyp:gles2_conform_test', '../gpu/gpu.gyp:gl_tests', '../gpu/gpu.gyp:angle_unittests', + '../gpu/gpu.gyp:gpu_unittests', '../tools/telemetry/telemetry.gyp:*', ], 'conditions': [ @@ -558,6 +580,7 @@ '../gpu/gles2_conform_support/gles2_conform_test.gyp:gles2_conform_test', '../gpu/gpu.gyp:gl_tests', '../gpu/gpu.gyp:angle_unittests', + '../gpu/gpu.gyp:gpu_unittests', '../tools/telemetry/telemetry.gyp:*', ], 'conditions': [ @@ -629,20 +652,14 @@ 'target_name': 'chromium_builder_webrtc', 'type': 'none', 'dependencies': [ - 'chromium_builder_qa', # TODO(phoglund): not sure if needed? + 'chromium_builder_perf', '../chrome/chrome.gyp:browser_tests', '../content/content_shell_and_tests.gyp:content_browsertests', '../content/content_shell_and_tests.gyp:content_unittests', + '../media/media.gyp:media_unittests', '../third_party/webrtc/tools/tools.gyp:frame_analyzer', '../third_party/webrtc/tools/tools.gyp:rgba_to_i420_converter', ], - 'conditions': [ - ['OS=="win"', { - 'dependencies': [ - '../chrome/chrome.gyp:crash_service', - ], - }], - ], }, # target_name: chromium_builder_webrtc { 'target_name': 'chromium_builder_chromedriver', @@ -764,13 +781,14 @@ '../sandbox/sandbox.gyp:sandbox_linux_unittests_stripped', '../sql/sql.gyp:sql_unittests', '../sync/sync.gyp:sync_unit_tests', + '../testing/android/junit/junit_test.gyp:junit_unit_tests', '../third_party/leveldatabase/leveldatabase.gyp:env_chromium_unittests', '../third_party/WebKit/public/all.gyp:*', '../tools/android/android_tools.gyp:android_tools', '../tools/android/android_tools.gyp:memconsumer', '../tools/android/findbugs_plugin/findbugs_plugin.gyp:findbugs_plugin_test', + '../ui/base/ui_base_tests.gyp:ui_unittests', '../ui/events/events.gyp:events_unittests', - '../ui/ui_unittests.gyp:ui_unittests', # Unit test bundles packaged as an apk. '../android_webview/android_webview.gyp:android_webview_test_apk', '../android_webview/android_webview.gyp:android_webview_unittests_apk', @@ -778,9 +796,11 @@ '../cc/blink/cc_blink_tests.gyp:cc_blink_unittests_apk', '../cc/cc_tests.gyp:cc_unittests_apk', '../chrome/chrome.gyp:chrome_shell_test_apk', + '../chrome/chrome.gyp:chrome_sync_shell_test_apk', '../chrome/chrome.gyp:chrome_shell_uiautomator_tests', '../chrome/chrome.gyp:unit_tests_apk', '../components/components_tests.gyp:components_unittests_apk', + '../components/devtools_bridge.gyp:devtools_bridge_tests_apk', '../content/content_shell_and_tests.gyp:content_browsertests_apk', '../content/content_shell_and_tests.gyp:content_gl_tests_apk', '../content/content_shell_and_tests.gyp:content_unittests_apk', @@ -794,30 +814,12 @@ '../sql/sql.gyp:sql_unittests_apk', '../sync/sync.gyp:sync_unit_tests_apk', '../tools/android/heap_profiler/heap_profiler.gyp:heap_profiler_unittests_apk', + '../ui/base/ui_base_tests.gyp:ui_unittests_apk', '../ui/events/events.gyp:events_unittests_apk', '../ui/gfx/gfx_tests.gyp:gfx_unittests_apk', - '../ui/ui_unittests.gyp:ui_unittests_apk', ], }, { - # WebRTC Android APK tests. - 'target_name': 'android_builder_webrtc', - 'type': 'none', - 'variables': { - # Set default value for include_tests to '0'. It is normally only - # used in WebRTC GYP files. It is set to '1' only when building - # WebRTC for Android, inside a Chromium checkout. - 'include_tests%': 0, - }, - 'conditions': [ - ['include_tests==1', { - 'dependencies': [ - '../third_party/webrtc/build/apk_tests.gyp:*', - ], - }], - ], - }, # target_name: android_builder_webrtc - { # WebRTC Chromium tests to run on Android. 'target_name': 'android_builder_chromium_webrtc', 'type': 'none', @@ -878,8 +880,8 @@ '../third_party/libphonenumber/libphonenumber.gyp:libphonenumber_unittests', '../tools/perf/clear_system_cache/clear_system_cache.gyp:*', '../tools/telemetry/telemetry.gyp:*', + '../ui/base/ui_base_tests.gyp:ui_unittests', '../ui/gfx/gfx_tests.gyp:gfx_unittests', - '../ui/ui_unittests.gyp:ui_unittests', '../url/url.gyp:url_unittests', ], }, @@ -915,8 +917,8 @@ '../third_party/libphonenumber/libphonenumber.gyp:libphonenumber_unittests', '../tools/perf/clear_system_cache/clear_system_cache.gyp:*', '../tools/telemetry/telemetry.gyp:*', + '../ui/base/ui_base_tests.gyp:ui_unittests', '../ui/gfx/gfx_tests.gyp:gfx_unittests', - '../ui/ui_unittests.gyp:ui_unittests', '../url/url.gyp:url_unittests', ], }, @@ -963,8 +965,8 @@ '../third_party/leveldatabase/leveldatabase.gyp:env_chromium_unittests', '../third_party/libaddressinput/libaddressinput.gyp:libaddressinput_unittests', '../third_party/libphonenumber/libphonenumber.gyp:libphonenumber_unittests', + '../ui/base/ui_base_tests.gyp:ui_unittests', '../ui/gfx/gfx_tests.gyp:gfx_unittests', - '../ui/ui_unittests.gyp:ui_unittests', '../url/url.gyp:url_unittests', ], }, @@ -1014,9 +1016,9 @@ '../third_party/libphonenumber/libphonenumber.gyp:libphonenumber_unittests', '../tools/perf/clear_system_cache/clear_system_cache.gyp:*', '../tools/telemetry/telemetry.gyp:*', + '../ui/base/ui_base_tests.gyp:ui_unittests', '../ui/events/events.gyp:events_unittests', '../ui/gfx/gfx_tests.gyp:gfx_unittests', - '../ui/ui_unittests.gyp:ui_unittests', '../ui/views/views.gyp:views_unittests', '../url/url.gyp:url_unittests', ], @@ -1141,6 +1143,7 @@ 'dependencies': [ '../base/base.gyp:base_unittests', '../chrome/chrome.gyp:browser_tests', + '../chrome/chrome.gyp:sync_integration_tests', '../chrome/chrome.gyp:crash_service', '../chrome/chrome.gyp:gcapi_dll', '../chrome/chrome.gyp:pack_policy_templates', @@ -1156,8 +1159,8 @@ '../sql/sql.gyp:sql_unittests', '../sync/sync.gyp:sync_unit_tests', '../third_party/widevine/cdm/widevine_cdm.gyp:widevinecdmadapter', + '../ui/base/ui_base_tests.gyp:ui_unittests', '../ui/gfx/gfx_tests.gyp:gfx_unittests', - '../ui/ui_unittests.gyp:ui_unittests', '../ui/views/views.gyp:views_unittests', '../url/url.gyp:url_unittests', ], @@ -1200,6 +1203,7 @@ '../remoting/remoting.gyp:remoting_unittests', '../ui/app_list/app_list.gyp:*', '../ui/aura/aura.gyp:*', + '../ui/base/ui_base_tests.gyp:ui_unittests', '../ui/compositor/compositor.gyp:*', '../ui/display/display.gyp:display_unittests', '../ui/events/events.gyp:*', @@ -1207,7 +1211,6 @@ '../ui/keyboard/keyboard.gyp:*', '../ui/message_center/message_center.gyp:*', '../ui/snapshot/snapshot.gyp:snapshot_unittests', - '../ui/ui_unittests.gyp:ui_unittests', '../ui/views/examples/examples.gyp:views_examples_with_content_exe', '../ui/views/views.gyp:views', '../ui/views/views.gyp:views_unittests', @@ -1289,6 +1292,17 @@ }, # target_name: chromium_swarm_tests ], }], + ['archive_chromoting_tests==1', { + 'targets': [ + { + 'target_name': 'chromoting_swarm_tests', + 'type': 'none', + 'dependencies': [ + '../testing/chromoting/integration_tests.gyp:chromoting_integration_tests_run', + ], + }, # target_name: chromoting_swarm_tests + ] + }], ['OS=="mac" and toolkit_views==1', { 'targets': [ { diff --git a/build/android/PRESUBMIT.py b/build/android/PRESUBMIT.py index f8decfaf14..bb57e54b49 100644 --- a/build/android/PRESUBMIT.py +++ b/build/android/PRESUBMIT.py @@ -48,8 +48,9 @@ def CommonChecks(input_api, output_api): white_list=[r'gyp/.*\.py$', r'gn/.*\.py'], extra_paths_list=[J('gyp'), J('gn')])) - output.extend(input_api.canned_checks.RunUnitTestsInDirectory( - input_api, output_api, J('buildbot', 'tests'))) + # Disabled due to http://crbug.com/410936 + #output.extend(input_api.canned_checks.RunUnitTestsInDirectory( + #input_api, output_api, J('buildbot', 'tests'))) pylib_test_env = dict(input_api.environ) pylib_test_env.update({ @@ -62,6 +63,7 @@ def CommonChecks(input_api, output_api): unit_tests=[ J('pylib', 'device', 'device_utils_test.py'), J('pylib', 'gtest', 'test_package_test.py'), + J('pylib', 'instrumentation', 'test_runner_test.py'), ], env=pylib_test_env)) output.extend(_CheckDeletionsOnlyFiles(input_api, output_api)) diff --git a/build/android/adb_gdb b/build/android/adb_gdb index a1e2fad0ba..07178c2bd3 100755 --- a/build/android/adb_gdb +++ b/build/android/adb_gdb @@ -473,14 +473,11 @@ get_ndk_toolchain_prebuilt () { local SUBPATH="$3" local NAME="$(get_arch_toolchain_prefix $ARCH)" local FILE TARGET - FILE=$NDK_DIR/toolchains/$NAME-4.8/prebuilt/$SUBPATH + FILE=$NDK_DIR/toolchains/$NAME-4.9/prebuilt/$SUBPATH if [ ! -f "$FILE" ]; then - FILE=$NDK_DIR/toolchains/$NAME-4.9/prebuilt/$SUBPATH + FILE=$NDK_DIR/toolchains/$NAME-4.8/prebuilt/$SUBPATH if [ ! -f "$FILE" ]; then - FILE=$NDK_DIR/toolchains/$NAME-4.6/prebuilt/$SUBPATH - if [ ! -f "$FILE" ]; then - FILE= - fi + FILE= fi fi echo "$FILE" @@ -984,6 +981,15 @@ fi readonly COMMANDS=$TMPDIR/gdb.init log "Generating GDB initialization commands file: $COMMANDS" echo -n "" > $COMMANDS +echo "set print pretty 1" >> $COMMANDS +echo "python" >> $COMMANDS +echo "import sys" >> $COMMANDS +echo "sys.path.insert(0, '$CHROMIUM_SRC/tools/gdb/')" >> $COMMANDS +echo "try:" >> $COMMANDS +echo " import gdb_chrome" >> $COMMANDS +echo "finally:" >> $COMMANDS +echo " sys.path.pop(0)" >> $COMMANDS +echo "end" >> $COMMANDS echo "file $TMPDIR/$GDBEXEC" >> $COMMANDS echo "directory $CHROMIUM_SRC" >> $COMMANDS echo "set solib-absolute-prefix $PULL_LIBS_DIR" >> $COMMANDS diff --git a/build/android/android_exports.lst b/build/android/android_exports.lst index 820d6ec169..6eee232f9f 100644 --- a/build/android/android_exports.lst +++ b/build/android/android_exports.lst @@ -7,8 +7,9 @@ # https://sourceware.org/binutils/docs-2.24/ld/VERSION.html#VERSION { - global: + global: Java_*_native*; JNI_OnLoad; + __gcov_*; local: *; }; diff --git a/build/android/android_exports.target.darwin-arm.mk b/build/android/android_exports.target.darwin-arm.mk index 14ba0b442d..dc6b9b6be3 100644 --- a/build/android/android_exports.target.darwin-arm.mk +++ b/build/android/android_exports.target.darwin-arm.mk @@ -6,7 +6,6 @@ LOCAL_MODULE_CLASS := GYP LOCAL_MODULE := build_android_android_exports_gyp LOCAL_MODULE_STEM := android_exports LOCAL_MODULE_SUFFIX := .stamp -LOCAL_MODULE_TAGS := optional LOCAL_MODULE_TARGET_ARCH := $(TARGET_$(GYP_VAR_PREFIX)ARCH) gyp_intermediate_dir := $(call local-intermediates-dir,,$(GYP_VAR_PREFIX)) gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared,,,$(GYP_VAR_PREFIX)) diff --git a/build/android/android_exports.target.darwin-arm64.mk b/build/android/android_exports.target.darwin-arm64.mk index 14ba0b442d..dc6b9b6be3 100644 --- a/build/android/android_exports.target.darwin-arm64.mk +++ b/build/android/android_exports.target.darwin-arm64.mk @@ -6,7 +6,6 @@ LOCAL_MODULE_CLASS := GYP LOCAL_MODULE := build_android_android_exports_gyp LOCAL_MODULE_STEM := android_exports LOCAL_MODULE_SUFFIX := .stamp -LOCAL_MODULE_TAGS := optional LOCAL_MODULE_TARGET_ARCH := $(TARGET_$(GYP_VAR_PREFIX)ARCH) gyp_intermediate_dir := $(call local-intermediates-dir,,$(GYP_VAR_PREFIX)) gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared,,,$(GYP_VAR_PREFIX)) diff --git a/build/android/android_exports.target.darwin-mips.mk b/build/android/android_exports.target.darwin-mips.mk index 14ba0b442d..dc6b9b6be3 100644 --- a/build/android/android_exports.target.darwin-mips.mk +++ b/build/android/android_exports.target.darwin-mips.mk @@ -6,7 +6,6 @@ LOCAL_MODULE_CLASS := GYP LOCAL_MODULE := build_android_android_exports_gyp LOCAL_MODULE_STEM := android_exports LOCAL_MODULE_SUFFIX := .stamp -LOCAL_MODULE_TAGS := optional LOCAL_MODULE_TARGET_ARCH := $(TARGET_$(GYP_VAR_PREFIX)ARCH) gyp_intermediate_dir := $(call local-intermediates-dir,,$(GYP_VAR_PREFIX)) gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared,,,$(GYP_VAR_PREFIX)) diff --git a/build/android/android_exports.target.darwin-x86.mk b/build/android/android_exports.target.darwin-x86.mk index 14ba0b442d..dc6b9b6be3 100644 --- a/build/android/android_exports.target.darwin-x86.mk +++ b/build/android/android_exports.target.darwin-x86.mk @@ -6,7 +6,6 @@ LOCAL_MODULE_CLASS := GYP LOCAL_MODULE := build_android_android_exports_gyp LOCAL_MODULE_STEM := android_exports LOCAL_MODULE_SUFFIX := .stamp -LOCAL_MODULE_TAGS := optional LOCAL_MODULE_TARGET_ARCH := $(TARGET_$(GYP_VAR_PREFIX)ARCH) gyp_intermediate_dir := $(call local-intermediates-dir,,$(GYP_VAR_PREFIX)) gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared,,,$(GYP_VAR_PREFIX)) diff --git a/build/android/android_exports.target.darwin-x86_64.mk b/build/android/android_exports.target.darwin-x86_64.mk index 14ba0b442d..dc6b9b6be3 100644 --- a/build/android/android_exports.target.darwin-x86_64.mk +++ b/build/android/android_exports.target.darwin-x86_64.mk @@ -6,7 +6,6 @@ LOCAL_MODULE_CLASS := GYP LOCAL_MODULE := build_android_android_exports_gyp LOCAL_MODULE_STEM := android_exports LOCAL_MODULE_SUFFIX := .stamp -LOCAL_MODULE_TAGS := optional LOCAL_MODULE_TARGET_ARCH := $(TARGET_$(GYP_VAR_PREFIX)ARCH) gyp_intermediate_dir := $(call local-intermediates-dir,,$(GYP_VAR_PREFIX)) gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared,,,$(GYP_VAR_PREFIX)) diff --git a/build/android/android_exports.target.linux-arm.mk b/build/android/android_exports.target.linux-arm.mk index 14ba0b442d..dc6b9b6be3 100644 --- a/build/android/android_exports.target.linux-arm.mk +++ b/build/android/android_exports.target.linux-arm.mk @@ -6,7 +6,6 @@ LOCAL_MODULE_CLASS := GYP LOCAL_MODULE := build_android_android_exports_gyp LOCAL_MODULE_STEM := android_exports LOCAL_MODULE_SUFFIX := .stamp -LOCAL_MODULE_TAGS := optional LOCAL_MODULE_TARGET_ARCH := $(TARGET_$(GYP_VAR_PREFIX)ARCH) gyp_intermediate_dir := $(call local-intermediates-dir,,$(GYP_VAR_PREFIX)) gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared,,,$(GYP_VAR_PREFIX)) diff --git a/build/android/android_exports.target.linux-arm64.mk b/build/android/android_exports.target.linux-arm64.mk index 14ba0b442d..dc6b9b6be3 100644 --- a/build/android/android_exports.target.linux-arm64.mk +++ b/build/android/android_exports.target.linux-arm64.mk @@ -6,7 +6,6 @@ LOCAL_MODULE_CLASS := GYP LOCAL_MODULE := build_android_android_exports_gyp LOCAL_MODULE_STEM := android_exports LOCAL_MODULE_SUFFIX := .stamp -LOCAL_MODULE_TAGS := optional LOCAL_MODULE_TARGET_ARCH := $(TARGET_$(GYP_VAR_PREFIX)ARCH) gyp_intermediate_dir := $(call local-intermediates-dir,,$(GYP_VAR_PREFIX)) gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared,,,$(GYP_VAR_PREFIX)) diff --git a/build/android/android_exports.target.linux-mips.mk b/build/android/android_exports.target.linux-mips.mk index 14ba0b442d..dc6b9b6be3 100644 --- a/build/android/android_exports.target.linux-mips.mk +++ b/build/android/android_exports.target.linux-mips.mk @@ -6,7 +6,6 @@ LOCAL_MODULE_CLASS := GYP LOCAL_MODULE := build_android_android_exports_gyp LOCAL_MODULE_STEM := android_exports LOCAL_MODULE_SUFFIX := .stamp -LOCAL_MODULE_TAGS := optional LOCAL_MODULE_TARGET_ARCH := $(TARGET_$(GYP_VAR_PREFIX)ARCH) gyp_intermediate_dir := $(call local-intermediates-dir,,$(GYP_VAR_PREFIX)) gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared,,,$(GYP_VAR_PREFIX)) diff --git a/build/android/android_exports.target.linux-x86.mk b/build/android/android_exports.target.linux-x86.mk index 14ba0b442d..dc6b9b6be3 100644 --- a/build/android/android_exports.target.linux-x86.mk +++ b/build/android/android_exports.target.linux-x86.mk @@ -6,7 +6,6 @@ LOCAL_MODULE_CLASS := GYP LOCAL_MODULE := build_android_android_exports_gyp LOCAL_MODULE_STEM := android_exports LOCAL_MODULE_SUFFIX := .stamp -LOCAL_MODULE_TAGS := optional LOCAL_MODULE_TARGET_ARCH := $(TARGET_$(GYP_VAR_PREFIX)ARCH) gyp_intermediate_dir := $(call local-intermediates-dir,,$(GYP_VAR_PREFIX)) gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared,,,$(GYP_VAR_PREFIX)) diff --git a/build/android/android_exports.target.linux-x86_64.mk b/build/android/android_exports.target.linux-x86_64.mk index 14ba0b442d..dc6b9b6be3 100644 --- a/build/android/android_exports.target.linux-x86_64.mk +++ b/build/android/android_exports.target.linux-x86_64.mk @@ -6,7 +6,6 @@ LOCAL_MODULE_CLASS := GYP LOCAL_MODULE := build_android_android_exports_gyp LOCAL_MODULE_STEM := android_exports LOCAL_MODULE_SUFFIX := .stamp -LOCAL_MODULE_TAGS := optional LOCAL_MODULE_TARGET_ARCH := $(TARGET_$(GYP_VAR_PREFIX)ARCH) gyp_intermediate_dir := $(call local-intermediates-dir,,$(GYP_VAR_PREFIX)) gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared,,,$(GYP_VAR_PREFIX)) diff --git a/build/android/buildbot/bb_device_status_check.py b/build/android/buildbot/bb_device_status_check.py index fe40488d8f..2eb3626a9d 100755 --- a/build/android/buildbot/bb_device_status_check.py +++ b/build/android/buildbot/bb_device_status_check.py @@ -149,14 +149,16 @@ def CheckForMissingDevices(options, adb_online_devs): bb_annotations.PrintSummaryText(devices_missing_msg) from_address = 'chrome-bot@chromium.org' - to_addresses = ['chrome-labs-tech-ticket@google.com'] + to_addresses = ['chrome-labs-tech-ticket@google.com', + 'chrome-android-device-alert@google.com'] + cc_addresses = ['chrome-android-device-alert@google.com'] subject = 'Devices offline on %s, %s, %s' % ( os.environ.get('BUILDBOT_SLAVENAME'), os.environ.get('BUILDBOT_BUILDERNAME'), os.environ.get('BUILDBOT_BUILDNUMBER')) msg = ('Please reboot the following devices:\n%s' % '\n'.join(map(str,new_missing_devs))) - SendEmail(from_address, to_addresses, subject, msg) + SendEmail(from_address, to_addresses, cc_addresses, subject, msg) all_known_devices = list(set(adb_online_devs) | set(last_devices)) device_list.WritePersistentDeviceList(last_devices_path, all_known_devices) @@ -198,9 +200,10 @@ def CheckForMissingDevices(options, adb_online_devs): 'regularly scheduled program.' % list(new_devs)) -def SendEmail(from_address, to_addresses, subject, msg): +def SendEmail(from_address, to_addresses, cc_addresses, subject, msg): msg_body = '\r\n'.join(['From: %s' % from_address, 'To: %s' % ', '.join(to_addresses), + 'CC: %s' % ', '.join(cc_addresses), 'Subject: %s' % subject, '', msg]) try: server = smtplib.SMTP('localhost') @@ -351,7 +354,7 @@ def main(): bot_name = os.environ.get('BUILDBOT_BUILDERNAME') slave_name = os.environ.get('BUILDBOT_SLAVENAME') subject = 'Device status check errors on %s, %s.' % (slave_name, bot_name) - SendEmail(from_address, to_addresses, subject, msg) + SendEmail(from_address, to_addresses, [], subject, msg) if options.device_status_dashboard: perf_tests_results_helper.PrintPerfResult('BotDevices', 'OnlineDevices', diff --git a/build/android/buildbot/bb_device_steps.py b/build/android/buildbot/bb_device_steps.py index 8ff5a20ad6..c0f9fe7842 100755 --- a/build/android/buildbot/bb_device_steps.py +++ b/build/android/buildbot/bb_device_steps.py @@ -26,6 +26,7 @@ from pylib.gtest import gtest_config CHROME_SRC_DIR = bb_utils.CHROME_SRC DIR_BUILD_ROOT = os.path.dirname(CHROME_SRC_DIR) CHROME_OUT_DIR = bb_utils.CHROME_OUT_DIR +BLINK_SCRIPTS_DIR = 'third_party/WebKit/Tools/Scripts' SLAVE_SCRIPTS_DIR = os.path.join(bb_utils.BB_BUILD_DIR, 'scripts', 'slave') LOGCAT_DIR = os.path.join(bb_utils.CHROME_OUT_DIR, 'logcat') @@ -74,9 +75,9 @@ INSTRUMENTATION_TESTS = dict((suite.name, suite) for suite in [ 'webview:android_webview/test/data/device_files'), ]) -VALID_TESTS = set(['chromedriver', 'chrome_proxy', 'gpu', 'mojo', +VALID_TESTS = set(['chromedriver', 'chrome_proxy', 'gpu', 'mojo', 'sync', 'telemetry_perf_unittests', 'ui', 'unit', 'webkit', - 'webkit_layout', 'webrtc_chromium', 'webrtc_native']) + 'webkit_layout']) RunCmd = bb_utils.RunCmd @@ -180,6 +181,15 @@ def RunChromeProxyTests(options): bb_annotations.PrintNamedStep('chrome_proxy') RunCmd(['tools/chrome_proxy/run_tests'] + args) +def RunChromeSyncShellTests(options): + """Run the chrome sync shell tests""" + test = I('ChromeSyncShell', + 'ChromeSyncShell.apk', + 'org.chromium.chrome.browser.sync', + 'ChromeSyncShellTest.apk', + 'chrome:chrome/test/data/android/device_files') + RunInstrumentationSuite(options, test) + def RunTelemetryPerfUnitTests(options): """Runs the telemetry perf unit tests. @@ -205,7 +215,7 @@ def RunMojoTests(options): None, 'org.chromium.mojo.tests', 'MojoTest', - None) + 'bindings:mojo/public/interfaces/bindings/tests/data') RunInstrumentationSuite(options, test) @@ -274,13 +284,10 @@ def RunInstrumentationSuite(options, test, flunk_on_failure=True, flunk_on_failure=flunk_on_failure) -def RunWebkitLint(target): +def RunWebkitLint(): """Lint WebKit's TestExpectation files.""" bb_annotations.PrintNamedStep('webkit_lint') - RunCmd([SrcPath('webkit/tools/layout_tests/run_webkit_tests.py'), - '--lint-test-files', - '--chromium', - '--target', target]) + RunCmd([SrcPath(os.path.join(BLINK_SCRIPTS_DIR, 'lint-test-expectations'))]) def RunWebkitLayoutTests(options): @@ -317,8 +324,8 @@ def RunWebkitLayoutTests(options): cmd_args.extend( ['--additional-expectations=%s' % os.path.join(CHROME_SRC_DIR, *f)]) - exit_code = RunCmd([SrcPath('webkit/tools/layout_tests/run_webkit_tests.py')] - + cmd_args) + exit_code = RunCmd( + [SrcPath(os.path.join(BLINK_SCRIPTS_DIR, 'run-webkit-tests'))] + cmd_args) if exit_code == 255: # test_run_results.UNEXPECTED_ERROR_EXIT_STATUS bb_annotations.PrintMsg('?? (crashed or hung)') elif exit_code == 254: # test_run_results.NO_DEVICES_EXIT_STATUS @@ -486,15 +493,7 @@ def RunInstrumentationTests(options): def RunWebkitTests(options): RunTestSuites(options, ['webkit_unit_tests', 'blink_heap_unittests']) - RunWebkitLint(options.target) - - -def RunWebRTCChromiumTests(options): - RunTestSuites(options, gtest_config.WEBRTC_CHROMIUM_TEST_SUITES) - - -def RunWebRTCNativeTests(options): - RunTestSuites(options, gtest_config.WEBRTC_NATIVE_TEST_SUITES) + RunWebkitLint() def RunGPUTests(options): @@ -538,13 +537,12 @@ def GetTestStepCmds(): ('chrome_proxy', RunChromeProxyTests), ('gpu', RunGPUTests), ('mojo', RunMojoTests), + ('sync', RunChromeSyncShellTests), ('telemetry_perf_unittests', RunTelemetryPerfUnitTests), - ('unit', RunUnitTests), ('ui', RunInstrumentationTests), + ('unit', RunUnitTests), ('webkit', RunWebkitTests), ('webkit_layout', RunWebkitLayoutTests), - ('webrtc_chromium', RunWebRTCChromiumTests), - ('webrtc_native', RunWebRTCNativeTests), ] diff --git a/build/android/buildbot/bb_run_bot.py b/build/android/buildbot/bb_run_bot.py index 7dbd211158..cba5049839 100755 --- a/build/android/buildbot/bb_run_bot.py +++ b/build/android/buildbot/bb_run_bot.py @@ -116,6 +116,7 @@ def GetCommands(options, bot_config): def GetBotStepMap(): compile_step = ['compile'] chrome_proxy_tests = ['chrome_proxy'] + chrome_sync_shell_tests = ['sync'] std_host_tests = ['check_webview_licenses', 'findbugs'] std_build_steps = ['compile', 'zip_build'] std_test_steps = ['extract_build'] @@ -157,15 +158,16 @@ def GetBotStepMap(): T(['chromedriver'], ['--install=ChromeShell', '--skip-wipe', '--cleanup'])), B('fyi-x86-builder-dbg', - H(compile_step + std_host_tests, experimental, target_arch='x86')), + H(compile_step + std_host_tests, experimental, target_arch='ia32')), B('fyi-builder-dbg', H(std_build_steps + std_host_tests, experimental, extra_gyp='emma_coverage=1')), B('x86-builder-dbg', - H(compile_step + std_host_tests, target_arch='x86')), + H(compile_step + std_host_tests, target_arch='ia32')), B('fyi-builder-rel', H(std_build_steps, experimental)), B('fyi-tests', H(std_test_steps), - T(std_tests, ['--experimental', flakiness_server, + T(std_tests + chrome_sync_shell_tests, + ['--experimental', flakiness_server, '--coverage-bucket', CHROMIUM_COVERAGE_BUCKET, '--cleanup'])), B('fyi-component-builder-tests-dbg', @@ -185,18 +187,6 @@ def GetBotStepMap(): B('webkit-latest-contentshell', H(compile_step), T(['webkit_layout'], ['--auto-reconnect'])), B('builder-unit-tests', H(compile_step), T(['unit'])), - B('webrtc-chromium-builder', - H(std_build_steps, - extra_args=['--build-targets=android_builder_chromium_webrtc'])), - B('webrtc-native-builder', - H(std_build_steps, - extra_args=['--build-targets=android_builder_webrtc'], - extra_gyp='include_tests=1 enable_tracing=1')), - B('webrtc-chromium-tests', H(std_test_steps), - T(['webrtc_chromium'], - [flakiness_server, '--gtest-filter=WebRtc*', '--cleanup'])), - B('webrtc-native-tests', H(std_test_steps), - T(['webrtc_native'], ['--cleanup', flakiness_server])), # Generic builder config (for substring match). B('builder', H(std_build_steps)), diff --git a/build/android/developer_recommended_flags.gypi b/build/android/developer_recommended_flags.gypi index 220a623e96..3a3db0a313 100644 --- a/build/android/developer_recommended_flags.gypi +++ b/build/android/developer_recommended_flags.gypi @@ -13,10 +13,10 @@ # and you'll get new settings automatically. # When using this method, you can override individual settings by setting them unconditionally (with # no %) in chrome/supplement.gypi. -# I.e. to disable optimize_jni_generation but use everything else: +# I.e. to disable gyp_managed_install but use everything else: # { # 'variables': { -# 'optimize_jni_generation': 0, +# 'gyp_managed_install': 0, # }, # 'includes': [ '../build/android/developer_recommended_flags.gypi' ] # } @@ -31,10 +31,6 @@ }, 'component%': '<(component)', - # When set to 1, only write jni generated files if they've changed. This can prevent unnecessary - # compiling/linking of native libraries when editing java files. - 'optimize_jni_generation%': 1, - # When gyp_managed_install is set to 1, building an APK will install that APK on the connected # device(/emulator). To install on multiple devices (or onto a new device), build the APK once # with each device attached. This greatly reduces the time required for incremental builds. diff --git a/build/android/findbugs_filter/findbugs_known_bugs.txt b/build/android/findbugs_filter/findbugs_known_bugs.txt index 90b59f7826..c82e62bbb0 100644 --- a/build/android/findbugs_filter/findbugs_known_bugs.txt +++ b/build/android/findbugs_filter/findbugs_known_bugs.txt @@ -17,10 +17,8 @@ M M UG: org.chromium.content.browser.JavaBridgeReturnValuesTest$TestObject.getBo M M UG: org.chromium.content.browser.JavaBridgeReturnValuesTest$TestObject.getStringValue() is unsynchronized, org.chromium.content.browser.JavaBridgeReturnValuesTest$TestObject.setStringValue(String) is synchronized At JavaBridgeReturnValuesTest.java M V EI2: org.chromium.chrome.browser.ChromeBrowserProvider$BookmarkNode.setFavicon(byte[]) may expose internal representation by storing an externally mutable object into ChromeBrowserProvider$BookmarkNode.mFavicon At ChromeBrowserProvider.java M V EI2: org.chromium.chrome.browser.ChromeBrowserProvider$BookmarkNode.setThumbnail(byte[]) may expose internal representation by storing an externally mutable object into ChromeBrowserProvider$BookmarkNode.mThumbnail At ChromeBrowserProvider.java -M V EI2: org.chromium.content.browser.LoadUrlParams.setPostData(byte[]) may expose internal representation by storing an externally mutable object into LoadUrlParams.mPostData At LoadUrlParams.java M V EI: org.chromium.chrome.browser.ChromeBrowserProvider$BookmarkNode.favicon() may expose internal representation by returning ChromeBrowserProvider$BookmarkNode.mFavicon At ChromeBrowserProvider.java M V EI: org.chromium.chrome.browser.ChromeBrowserProvider$BookmarkNode.thumbnail() may expose internal representation by returning ChromeBrowserProvider$BookmarkNode.mThumbnail At ChromeBrowserProvider.java -M V EI: org.chromium.content.browser.LoadUrlParams.getPostData() may expose internal representation by returning LoadUrlParams.mPostData At LoadUrlParams.java M M LI: Incorrect lazy initialization of static field org.chromium.chrome.browser.sync.ProfileSyncService.sSyncSetupManager in org.chromium.chrome.browser.sync.ProfileSyncService.get(Context) At ProfileSyncService.java -M V EI: org.chromium.android_webview.AwWebResourceResponse.getResponseHeaderNames() may expose internal representation by returning AwWebResourceResponse.mResponseHeaderNames At AwWebResourceResponse.java -M V EI: org.chromium.android_webview.AwWebResourceResponse.getResponseHeaderValues() may expose internal representation by returning AwWebResourceResponse.mResponseHeaderValues At AwWebResourceResponse.java +M V EI2: org.chromium.content_public.browser.LoadUrlParams.setPostData(byte[]) may expose internal representation by storing an externally mutable object into LoadUrlParams.mPostData At LoadUrlParams.java +M V EI: org.chromium.content_public.browser.LoadUrlParams.getPostData() may expose internal representation by returning LoadUrlParams.mPostData At LoadUrlParams.java diff --git a/build/android/gyp/aidl.py b/build/android/gyp/aidl.py new file mode 100755 index 0000000000..d5aa546770 --- /dev/null +++ b/build/android/gyp/aidl.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Invokes Android's aidl +""" + +import optparse +import os +import sys + +from util import build_utils + + +def main(argv): + option_parser = optparse.OptionParser() + build_utils.AddDepfileOption(option_parser) + option_parser.add_option('--aidl-path', help='Path to the aidl binary.') + option_parser.add_option('--imports', help='Files to import.') + option_parser.add_option('--includes', + help='Directories to add as import search paths.') + option_parser.add_option('--srcjar', help='Path for srcjar output.') + options, args = option_parser.parse_args(argv[1:]) + + with build_utils.TempDir() as temp_dir: + for f in args: + classname = os.path.splitext(os.path.basename(f))[0] + output = os.path.join(temp_dir, classname + '.java') + aidl_cmd = [options.aidl_path] + aidl_cmd += [ + '-p' + s for s in build_utils.ParseGypList(options.imports) + ] + if options.includes is not None: + aidl_cmd += [ + '-I' + s for s in build_utils.ParseGypList(options.includes) + ] + aidl_cmd += [ + f, + output + ] + build_utils.CheckOutput(aidl_cmd) + + build_utils.ZipDir(options.srcjar, temp_dir) + + if options.depfile: + build_utils.WriteDepfile( + options.depfile, + build_utils.GetPythonDependencies()) + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) diff --git a/build/android/gyp/apk_obfuscate.py b/build/android/gyp/apk_obfuscate.py index fb29d0ce80..fec70c8d0a 100755 --- a/build/android/gyp/apk_obfuscate.py +++ b/build/android/gyp/apk_obfuscate.py @@ -10,11 +10,9 @@ If proguard is not enabled or 'Release' is not in the configuration name, obfuscation will be a no-op. """ -import fnmatch import optparse import os import sys -import zipfile from util import build_utils @@ -86,19 +84,9 @@ def main(argv): dependency_class_filters = [ '*R.class', '*R$*.class', '*Manifest.class', '*BuildConfig.class'] - def DependencyClassFilter(name): - for name_filter in dependency_class_filters: - if fnmatch.fnmatch(name, name_filter): - return False - return True - if options.testapp: - with zipfile.ZipFile(options.test_jar_path, 'w') as test_jar: - for jar in input_jars: - with zipfile.ZipFile(jar, 'r') as jar_zip: - for name in filter(DependencyClassFilter, jar_zip.namelist()): - with jar_zip.open(name) as zip_entry: - test_jar.writestr(name, zip_entry.read()) + build_utils.MergeZips( + options.test_jar_path, input_jars, dependency_class_filters) if options.configuration_name == 'Release' and options.proguard_enabled: proguard_cmd = [ @@ -125,6 +113,7 @@ def main(argv): proguard_cmd += [ '-dontobfuscate', '-dontoptimize', + '-dontshrink', '-dontskipnonpubliclibraryclassmembers', '-libraryjars', options.tested_apk_obfuscated_jar_path, '-applymapping', options.tested_apk_obfuscated_jar_path + '.mapping', diff --git a/build/android/gyp/copy_ex.py b/build/android/gyp/copy_ex.py index 088880ce48..eee3d19174 100755 --- a/build/android/gyp/copy_ex.py +++ b/build/android/gyp/copy_ex.py @@ -44,7 +44,7 @@ def main(args): if options.depfile: build_utils.WriteDepfile( options.depfile, - options.files + build_utils.GetPythonDependencies()) + files + build_utils.GetPythonDependencies()) if options.stamp: build_utils.Touch(options.stamp) diff --git a/build/android/gyp/create_dist_jar.py b/build/android/gyp/create_dist_jar.py new file mode 100755 index 0000000000..0d31c5db93 --- /dev/null +++ b/build/android/gyp/create_dist_jar.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Merges a list of jars into a single jar.""" + +import optparse +import sys + +from util import build_utils + +def main(args): + args = build_utils.ExpandFileArgs(args) + parser = optparse.OptionParser() + build_utils.AddDepfileOption(parser) + parser.add_option('--output', help='Path to output jar.') + parser.add_option('--inputs', action='append', help='List of jar inputs.') + options, _ = parser.parse_args(args) + build_utils.CheckOptions(options, parser, ['output', 'inputs']) + + input_jars = [] + for inputs_arg in options.inputs: + input_jars.extend(build_utils.ParseGypList(inputs_arg)) + + build_utils.MergeZips(options.output, input_jars) + + if options.depfile: + build_utils.WriteDepfile( + options.depfile, + input_jars + build_utils.GetPythonDependencies()) + + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/build/android/gyp/create_placeholder_files.py b/build/android/gyp/create_placeholder_files.py new file mode 100755 index 0000000000..103e1df7f2 --- /dev/null +++ b/build/android/gyp/create_placeholder_files.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Create placeholder files. +""" + +import optparse +import os +import sys + +from util import build_utils + +def main(): + parser = optparse.OptionParser() + parser.add_option( + '--dest-lib-dir', + help='Destination directory to have placeholder files.') + parser.add_option( + '--stamp', + help='Path to touch on success') + + options, args = parser.parse_args() + + for name in args: + target_path = os.path.join(options.dest_lib_dir, name) + build_utils.Touch(target_path) + + if options.stamp: + build_utils.Touch(options.stamp) + +if __name__ == '__main__': + sys.exit(main()) + diff --git a/build/android/gyp/generate_v14_compatible_resources.py b/build/android/gyp/generate_v14_compatible_resources.py index 2f1d81212e..1961622b7a 100755 --- a/build/android/gyp/generate_v14_compatible_resources.py +++ b/build/android/gyp/generate_v14_compatible_resources.py @@ -226,18 +226,18 @@ def VerifyV14ResourcesInDir(input_dir, resource_type): don't use attributes that cause crashes on certain devices. Print an error if they have.""" for input_filename in build_utils.FindInDirectory(input_dir, '*.xml'): - warning_message = ('warning : ' + input_filename + ' has an RTL attribute, ' - 'i.e., attribute that has "start" or "end" in its name.' - ' Pre-v17 resources should not include it because it ' - 'can cause crashes on certain devices. Please refer to ' - 'http://crbug.com/243952 for the details.') + exception_message = ('error : ' + input_filename + ' has an RTL attribute, ' + 'i.e., attribute that has "start" or "end" in its name.' + ' Pre-v17 resources should not include it because it ' + 'can cause crashes on certain devices. Please refer to ' + 'http://crbug.com/243952 for the details.') dom = minidom.parse(input_filename) if resource_type in ('layout', 'xml'): if GenerateV14LayoutResourceDom(dom, input_filename, False): - print warning_message + raise Exception(exception_message) elif resource_type == 'values': if GenerateV14StyleResourceDom(dom, input_filename, False): - print warning_message + raise Exception(exception_message) def AssertNoDeprecatedAttributesInDir(input_dir, resource_type): diff --git a/build/android/gyp/jar.py b/build/android/gyp/jar.py index d3636d7141..17f968c3e8 100755 --- a/build/android/gyp/jar.py +++ b/build/android/gyp/jar.py @@ -12,7 +12,8 @@ import sys from util import build_utils from util import md5_check -def Jar(class_files, classes_dir, jar_path): + +def Jar(class_files, classes_dir, jar_path, manifest_file=None): jar_path = os.path.abspath(jar_path) # The paths of the files in the jar will be the same as they are passed in to @@ -20,7 +21,11 @@ def Jar(class_files, classes_dir, jar_path): # options.classes_dir so the .class file paths in the jar are correct. jar_cwd = classes_dir class_files_rel = [os.path.relpath(f, jar_cwd) for f in class_files] - jar_cmd = ['jar', 'cf0', jar_path] + class_files_rel + jar_cmd = ['jar', 'cf0', jar_path] + if manifest_file: + jar_cmd[1] += 'm' + jar_cmd.append(os.path.abspath(manifest_file)) + jar_cmd.extend(class_files_rel) record_path = '%s.md5.stamp' % jar_path md5_check.CallAndRecordIfStale( @@ -34,13 +39,14 @@ def Jar(class_files, classes_dir, jar_path): build_utils.Touch(jar_path, fail_if_missing=True) -def JarDirectory(classes_dir, excluded_classes, jar_path): +def JarDirectory(classes_dir, excluded_classes, jar_path, manifest_file=None): class_files = build_utils.FindInDirectory(classes_dir, '*.class') for exclude in excluded_classes: class_files = filter( lambda f: not fnmatch.fnmatch(f, exclude), class_files) - Jar(class_files, classes_dir, jar_path) + Jar(class_files, classes_dir, jar_path, manifest_file=manifest_file) + def main(): parser = optparse.OptionParser() @@ -52,8 +58,12 @@ def main(): options, _ = parser.parse_args() + if options.excluded_classes: + excluded_classes = build_utils.ParseGypList(options.excluded_classes) + else: + excluded_classes = [] JarDirectory(options.classes_dir, - build_utils.ParseGypList(options.excluded_classes), + excluded_classes, options.jar_path) if options.stamp: diff --git a/build/android/gyp/java_cpp_enum.py b/build/android/gyp/java_cpp_enum.py new file mode 100755 index 0000000000..ad0974232a --- /dev/null +++ b/build/android/gyp/java_cpp_enum.py @@ -0,0 +1,237 @@ +#!/usr/bin/env python +# +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import collections +import re +import optparse +import os +from string import Template +import sys + +from util import build_utils + +class EnumDefinition(object): + def __init__(self, class_name=None, class_package=None, entries=None): + self.class_name = class_name + self.class_package = class_package + self.entries = collections.OrderedDict(entries or []) + self.prefix_to_strip = '' + + def AppendEntry(self, key, value): + if key in self.entries: + raise Exception('Multiple definitions of key %s found.' % key) + self.entries[key] = value + + def Finalize(self): + self._Validate() + self._AssignEntryIndices() + self._StripPrefix() + + def _Validate(self): + assert self.class_name + assert self.class_package + assert self.entries + + def _AssignEntryIndices(self): + # Supporting the same set enum value assignments the compiler does is rather + # complicated, so we limit ourselves to these cases: + # - all the enum constants have values assigned, + # - enum constants reference other enum constants or have no value assigned. + + if not all(self.entries.values()): + index = 0 + for key, value in self.entries.iteritems(): + if not value: + self.entries[key] = index + index = index + 1 + elif value in self.entries: + self.entries[key] = self.entries[value] + else: + raise Exception('You can only reference other enum constants unless ' + 'you assign values to all of the constants.') + + def _StripPrefix(self): + if not self.prefix_to_strip: + prefix_to_strip = re.sub('(?!^)([A-Z]+)', r'_\1', self.class_name).upper() + prefix_to_strip += '_' + if not all([w.startswith(prefix_to_strip) for w in self.entries.keys()]): + prefix_to_strip = '' + else: + prefix_to_strip = self.prefix_to_strip + entries = ((k.replace(prefix_to_strip, '', 1), v) for (k, v) in + self.entries.iteritems()) + self.entries = collections.OrderedDict(entries) + +class HeaderParser(object): + single_line_comment_re = re.compile(r'\s*//') + multi_line_comment_start_re = re.compile(r'\s*/\*') + enum_start_re = re.compile(r'^\s*enum\s+(\w+)\s+{\s*$') + enum_line_re = re.compile(r'^\s*(\w+)(\s*\=\s*([^,\n]+))?,?\s*$') + enum_end_re = re.compile(r'^\s*}\s*;\s*$') + generator_directive_re = re.compile( + r'^\s*//\s+GENERATED_JAVA_(\w+)\s*:\s*([\.\w]+)$') + + def __init__(self, lines): + self._lines = lines + self._enum_definitions = [] + self._in_enum = False + self._current_definition = None + self._generator_directives = {} + + def ParseDefinitions(self): + for line in self._lines: + self._ParseLine(line) + return self._enum_definitions + + def _ParseLine(self, line): + if not self._in_enum: + self._ParseRegularLine(line) + else: + self._ParseEnumLine(line) + + def _ParseEnumLine(self, line): + if HeaderParser.single_line_comment_re.match(line): + return + if HeaderParser.multi_line_comment_start_re.match(line): + raise Exception('Multi-line comments in enums are not supported.') + enum_end = HeaderParser.enum_end_re.match(line) + enum_entry = HeaderParser.enum_line_re.match(line) + if enum_end: + self._ApplyGeneratorDirectives() + self._current_definition.Finalize() + self._enum_definitions.append(self._current_definition) + self._in_enum = False + elif enum_entry: + enum_key = enum_entry.groups()[0] + enum_value = enum_entry.groups()[2] + self._current_definition.AppendEntry(enum_key, enum_value) + + def _GetCurrentEnumPackageName(self): + return self._generator_directives.get('ENUM_PACKAGE') + + def _GetCurrentEnumPrefixToStrip(self): + return self._generator_directives.get('PREFIX_TO_STRIP', '') + + def _ApplyGeneratorDirectives(self): + current_definition = self._current_definition + current_definition.class_package = self._GetCurrentEnumPackageName() + current_definition.prefix_to_strip = self._GetCurrentEnumPrefixToStrip() + self._generator_directives = {} + + def _ParseRegularLine(self, line): + enum_start = HeaderParser.enum_start_re.match(line) + generator_directive = HeaderParser.generator_directive_re.match(line) + if enum_start: + if not self._GetCurrentEnumPackageName(): + return + self._current_definition = EnumDefinition() + self._current_definition.class_name = enum_start.groups()[0] + self._in_enum = True + elif generator_directive: + directive_name = generator_directive.groups()[0] + directive_value = generator_directive.groups()[1] + self._generator_directives[directive_name] = directive_value + + +def GetScriptName(): + script_components = os.path.abspath(sys.argv[0]).split(os.path.sep) + build_index = script_components.index('build') + return os.sep.join(script_components[build_index:]) + + +def DoGenerate(options, source_paths): + output_paths = [] + for source_path in source_paths: + enum_definitions = DoParseHeaderFile(source_path) + for enum_definition in enum_definitions: + package_path = enum_definition.class_package.replace('.', os.path.sep) + file_name = enum_definition.class_name + '.java' + output_path = os.path.join(options.output_dir, package_path, file_name) + output_paths.append(output_path) + if not options.print_output_only: + build_utils.MakeDirectory(os.path.dirname(output_path)) + DoWriteOutput(source_path, output_path, enum_definition) + return output_paths + + +def DoParseHeaderFile(path): + with open(path) as f: + return HeaderParser(f.readlines()).ParseDefinitions() + + +def GenerateOutput(source_path, enum_definition): + template = Template(""" +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file is autogenerated by +// ${SCRIPT_NAME} +// From +// ${SOURCE_PATH} + +package ${PACKAGE}; + +public class ${CLASS_NAME} { +${ENUM_ENTRIES} +} +""") + + enum_template = Template(' public static final int ${NAME} = ${VALUE};') + enum_entries_string = [] + for enum_name, enum_value in enum_definition.entries.iteritems(): + values = { + 'NAME': enum_name, + 'VALUE': enum_value, + } + enum_entries_string.append(enum_template.substitute(values)) + enum_entries_string = '\n'.join(enum_entries_string) + + values = { + 'CLASS_NAME': enum_definition.class_name, + 'ENUM_ENTRIES': enum_entries_string, + 'PACKAGE': enum_definition.class_package, + 'SCRIPT_NAME': GetScriptName(), + 'SOURCE_PATH': source_path, + } + return template.substitute(values) + + +def DoWriteOutput(source_path, output_path, enum_definition): + with open(output_path, 'w') as out_file: + out_file.write(GenerateOutput(source_path, enum_definition)) + +def AssertFilesList(output_paths, assert_files_list): + actual = set(output_paths) + expected = set(assert_files_list) + if not actual == expected: + need_to_add = list(actual - expected) + need_to_remove = list(expected - actual) + raise Exception('Output files list does not match expectations. Please ' + 'add %s and remove %s.' % (need_to_add, need_to_remove)) + +def DoMain(argv): + parser = optparse.OptionParser() + + parser.add_option('--assert_file', action="append", default=[], + dest="assert_files_list", help='Assert that the given ' + 'file is an output. There can be multiple occurrences of ' + 'this flag.') + parser.add_option('--output_dir', help='Base path for generated files.') + parser.add_option('--print_output_only', help='Only print output paths.', + action='store_true') + + options, args = parser.parse_args(argv) + + output_paths = DoGenerate(options, args) + + if options.assert_files_list: + AssertFilesList(output_paths, options.assert_files_list) + + return " ".join(output_paths) + +if __name__ == '__main__': + DoMain(sys.argv[1:]) diff --git a/build/android/gyp/java_cpp_enum_tests.py b/build/android/gyp/java_cpp_enum_tests.py new file mode 100755 index 0000000000..24da05fd44 --- /dev/null +++ b/build/android/gyp/java_cpp_enum_tests.py @@ -0,0 +1,163 @@ +#!/usr/bin/env python +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Tests for enum_preprocess.py. + +This test suite containss various tests for the C++ -> Java enum generator. +""" + +import collections +import unittest +from java_cpp_enum import EnumDefinition, GenerateOutput, HeaderParser + +class TestPreprocess(unittest.TestCase): + def testOutput(self): + definition = EnumDefinition(class_name='ClassName', + class_package='some.package', + entries=[('E1', 1), ('E2', '2 << 2')]) + output = GenerateOutput('path/to/file', definition) + expected = """ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file is autogenerated by +// build/android/gyp/java_cpp_enum_tests.py +// From +// path/to/file + +package some.package; + +public class ClassName { + public static final int E1 = 1; + public static final int E2 = 2 << 2; +} +""" + self.assertEqual(expected, output) + + def testParseSimpleEnum(self): + test_data = """ + // GENERATED_JAVA_ENUM_PACKAGE: test.namespace + enum EnumName { + VALUE_ZERO, + VALUE_ONE, + }; + """.split('\n') + definitions = HeaderParser(test_data).ParseDefinitions() + self.assertEqual(1, len(definitions)) + definition = definitions[0] + self.assertEqual('EnumName', definition.class_name) + self.assertEqual('test.namespace', definition.class_package) + self.assertEqual(collections.OrderedDict([('VALUE_ZERO', 0), + ('VALUE_ONE', 1)]), + definition.entries) + + def testParseTwoEnums(self): + test_data = """ + // GENERATED_JAVA_ENUM_PACKAGE: test.namespace + enum EnumOne { + ENUM_ONE_A = 1, + // Comment there + ENUM_ONE_B = A, + }; + + enum EnumIgnore { + C, D, E + }; + + // GENERATED_JAVA_ENUM_PACKAGE: other.package + // GENERATED_JAVA_PREFIX_TO_STRIP: P_ + enum EnumTwo { + P_A, + P_B + }; + """.split('\n') + definitions = HeaderParser(test_data).ParseDefinitions() + self.assertEqual(2, len(definitions)) + definition = definitions[0] + self.assertEqual('EnumOne', definition.class_name) + self.assertEqual('test.namespace', definition.class_package) + self.assertEqual(collections.OrderedDict([('A', '1'), + ('B', 'A')]), + definition.entries) + + definition = definitions[1] + self.assertEqual('EnumTwo', definition.class_name) + self.assertEqual('other.package', definition.class_package) + self.assertEqual(collections.OrderedDict([('A', 0), + ('B', 1)]), + definition.entries) + + def testEnumValueAssignmentNoneDefined(self): + definition = EnumDefinition('c', 'p', []) + definition.AppendEntry('A', None) + definition.AppendEntry('B', None) + definition.AppendEntry('C', None) + definition.Finalize() + self.assertEqual(collections.OrderedDict([('A', 0), + ('B', 1), + ('C', 2)]), + definition.entries) + + def testEnumValueAssignmentAllDefined(self): + definition = EnumDefinition('c', 'p', []) + definition.AppendEntry('A', '1') + definition.AppendEntry('B', '2') + definition.AppendEntry('C', '3') + definition.Finalize() + self.assertEqual(collections.OrderedDict([('A', '1'), + ('B', '2'), + ('C', '3')]), + definition.entries) + + def testEnumValueAssignmentReferences(self): + definition = EnumDefinition('c', 'p', []) + definition.AppendEntry('A', None) + definition.AppendEntry('B', 'A') + definition.AppendEntry('C', None) + definition.AppendEntry('D', 'C') + definition.Finalize() + self.assertEqual(collections.OrderedDict([('A', 0), + ('B', 0), + ('C', 1), + ('D', 1)]), + definition.entries) + + def testEnumValueAssignmentRaises(self): + definition = EnumDefinition('c', 'p', []) + definition.AppendEntry('A', None) + definition.AppendEntry('B', '1') + definition.AppendEntry('C', None) + with self.assertRaises(Exception): + definition.Finalize() + + def testExplicitPrefixStripping(self): + definition = EnumDefinition('c', 'p', []) + definition.AppendEntry('P_A', None) + definition.AppendEntry('B', None) + definition.AppendEntry('P_C', None) + definition.prefix_to_strip = 'P_' + definition.Finalize() + self.assertEqual(['A', 'B', 'C'], definition.entries.keys()) + + def testImplicitPrefixStripping(self): + definition = EnumDefinition('ClassName', 'p', []) + definition.AppendEntry('CLASS_NAME_A', None) + definition.AppendEntry('CLASS_NAME_B', None) + definition.AppendEntry('CLASS_NAME_C', None) + definition.Finalize() + self.assertEqual(['A', 'B', 'C'], definition.entries.keys()) + + def testImplicitPrefixStrippingRequiresAllConstantsToBePrefixed(self): + definition = EnumDefinition('Name', 'p', []) + definition.AppendEntry('A', None) + definition.AppendEntry('B', None) + definition.AppendEntry('NAME_LAST', None) + definition.Finalize() + self.assertEqual(['A', 'B', 'NAME_LAST'], definition.entries.keys()) + + +if __name__ == '__main__': + unittest.main() diff --git a/build/android/gyp/javac.py b/build/android/gyp/javac.py index 9dabf70fb6..6a3024be33 100755 --- a/build/android/gyp/javac.py +++ b/build/android/gyp/javac.py @@ -10,6 +10,7 @@ import os import shutil import re import sys +import textwrap from util import build_utils from util import md5_check @@ -62,13 +63,6 @@ def DoJavac( checking will be enabled. """ - # Compiling guava with certain orderings of input files causes a compiler - # crash... Sorted order works, so use that. - # See https://code.google.com/p/guava-libraries/issues/detail?id=950 - # TODO(cjhopman): Remove this when we have update guava or the compiler to a - # version without this problem. - java_files.sort() - jar_inputs = [] for path in classpath: if os.path.exists(path + '.TOC'): @@ -78,8 +72,8 @@ def DoJavac( javac_args = [ '-g', - '-source', '1.5', - '-target', '1.5', + '-source', '1.7', + '-target', '1.7', '-classpath', ':'.join(classpath), '-d', classes_dir] if chromium_code: @@ -106,6 +100,43 @@ def DoJavac( input_strings=javac_cmd) +_MAX_MANIFEST_LINE_LEN = 72 + + +def CreateManifest(manifest_path, classpath, main_class=None): + """Creates a manifest file with the given parameters. + + This generates a manifest file that compiles with the spec found at + http://docs.oracle.com/javase/7/docs/technotes/guides/jar/jar.html#JAR_Manifest + + Args: + manifest_path: The path to the manifest file that should be created. + classpath: The JAR files that should be listed on the manifest file's + classpath. + main_class: If present, the class containing the main() function. + + """ + output = ['Manifest-Version: 1.0'] + if main_class: + output.append('Main-Class: %s' % main_class) + if classpath: + sanitized_paths = [] + for path in classpath: + sanitized_paths.append(os.path.basename(path.strip('"'))) + output.append('Class-Path: %s' % ' '.join(sanitized_paths)) + output.append('Created-By: ') + output.append('') + + wrapper = textwrap.TextWrapper(break_long_words=True, + drop_whitespace=False, + subsequent_indent=' ', + width=_MAX_MANIFEST_LINE_LEN - 2) + output = '\r\n'.join(w for l in output for w in wrapper.wrap(l)) + + with open(manifest_path, 'w') as f: + f.write(output) + + def main(argv): colorama.init() @@ -146,11 +177,17 @@ def main(argv): '--classes-dir', help='Directory for compiled .class files.') parser.add_option('--jar-path', help='Jar output path.') + parser.add_option( + '--main-class', + help='The class containing the main method.') parser.add_option('--stamp', help='Path to touch on success.') options, args = parser.parse_args(argv) + if options.main_class and not options.jar_path: + parser.error('--main-class requires --jar-path') + classpath = [] for arg in options.classpath: classpath += build_utils.ParseGypList(arg) @@ -172,7 +209,7 @@ def main(argv): java_dir = os.path.join(temp_dir, 'java') os.makedirs(java_dir) for srcjar in java_srcjars: - build_utils.ExtractAll(srcjar, path=java_dir) + build_utils.ExtractAll(srcjar, path=java_dir, pattern='*.java') java_files += build_utils.FindInDirectory(java_dir, '*.java') if options.javac_includes: @@ -192,9 +229,16 @@ def main(argv): java_files) if options.jar_path: + if options.main_class: + manifest_file = os.path.join(temp_dir, 'manifest') + CreateManifest(manifest_file, classpath, + options.main_class) + else: + manifest_file = None jar.JarDirectory(classes_dir, build_utils.ParseGypList(options.jar_excluded_classes), - options.jar_path) + options.jar_path, + manifest_file=manifest_file) if options.classes_dir: # Delete the old classes directory. This ensures that all .class files in diff --git a/build/android/gyp/package_resources.py b/build/android/gyp/package_resources.py index 1f0685028d..f34578f72e 100755 --- a/build/android/gyp/package_resources.py +++ b/build/android/gyp/package_resources.py @@ -88,6 +88,27 @@ def MoveImagesToNonMdpiFolders(res_root): shutil.move(src_file, dst_file) +def PackageArgsForExtractedZip(d): + """Returns the aapt args for an extracted resources zip. + + A resources zip either contains the resources for a single target or for + multiple targets. If it is multiple targets merged into one, the actual + resource directories will be contained in the subdirectories 0, 1, 2, ... + """ + res_dirs = [] + subdirs = [os.path.join(d, s) for s in os.listdir(d)] + subdirs = sorted([s for s in subdirs if os.path.isdir(s)]) + if subdirs and os.path.basename(subdirs[0]) == '0': + res_dirs = subdirs + else: + res_dirs = [d] + package_command = [] + for d in res_dirs: + MoveImagesToNonMdpiFolders(d) + package_command += ['-S', d] + return package_command + + def main(): options = ParseArgs() android_jar = os.path.join(options.android_sdk, 'android.jar') @@ -120,8 +141,7 @@ def main(): if os.path.exists(subdir): raise Exception('Resource zip name conflict: ' + os.path.basename(z)) build_utils.ExtractAll(z, path=subdir) - MoveImagesToNonMdpiFolders(subdir) - package_command += ['-S', subdir] + package_command += PackageArgsForExtractedZip(subdir) if 'Debug' in options.configuration_name: package_command += ['--debug-mode'] diff --git a/build/android/gyp/process_resources.py b/build/android/gyp/process_resources.py index 0fe02dfa84..fd3206437d 100755 --- a/build/android/gyp/process_resources.py +++ b/build/android/gyp/process_resources.py @@ -64,6 +64,8 @@ def ParseArgs(args): parser.add_option( '--extra-res-packages', help='Additional package names to generate R.java files for') + # TODO(cjhopman): Actually use --extra-r-text-files. We currently include all + # the resources in all R.java files for a particular apk. parser.add_option( '--extra-r-text-files', help='For each additional package, the R.txt file should contain a ' @@ -99,12 +101,7 @@ def ParseArgs(args): return options -def CreateExtraRJavaFiles( - r_dir, extra_packages, extra_r_text_files): - if len(extra_packages) != len(extra_r_text_files): - raise Exception('--extra-res-packages and --extra-r-text-files' - 'should have the same length') - +def CreateExtraRJavaFiles(r_dir, extra_packages): java_files = build_utils.FindInDirectory(r_dir, "R.java") if len(java_files) != 1: return @@ -155,6 +152,20 @@ def ZipResources(resource_dirs, zip_path): outzip.write(path, archive_path) +def CombineZips(zip_files, output_path): + # When packaging resources, if the top-level directories in the zip file are + # of the form 0, 1, ..., then each subdirectory will be passed to aapt as a + # resources directory. While some resources just clobber others (image files, + # etc), other resources (particularly .xml files) need to be more + # intelligently merged. That merging is left up to aapt. + with zipfile.ZipFile(output_path, 'w') as outzip: + for i, z in enumerate(zip_files): + with zipfile.ZipFile(z, 'r') as inzip: + for name in inzip.namelist(): + new_name = '%d/%s' % (i, name) + outzip.writestr(new_name, inzip.read(name)) + + def main(): args = build_utils.ExpandFileArgs(sys.argv[1:]) @@ -222,8 +233,7 @@ def main(): if options.extra_res_packages: CreateExtraRJavaFiles( gen_dir, - build_utils.ParseGypList(options.extra_res_packages), - build_utils.ParseGypList(options.extra_r_text_files)) + build_utils.ParseGypList(options.extra_res_packages)) # This is the list of directories with resources to put in the final .zip # file. The order of these is important so that crunched/v14 resources @@ -248,8 +258,8 @@ def main(): ZipResources(zip_resource_dirs, options.resource_zip_out) if options.all_resources_zip_out: - ZipResources( - zip_resource_dirs + dep_subdirs, options.all_resources_zip_out) + CombineZips([options.resource_zip_out] + dep_zips, + options.all_resources_zip_out) if options.R_dir: build_utils.DeleteDirectory(options.R_dir) diff --git a/build/android/gyp/util/build_utils.py b/build/android/gyp/util/build_utils.py index f4a43a753e..e3a3525e52 100644 --- a/build/android/gyp/util/build_utils.py +++ b/build/android/gyp/util/build_utils.py @@ -191,7 +191,7 @@ def CheckZipPath(name): raise Exception('Absolute zip path: %s' % name) -def ExtractAll(zip_path, path=None, no_clobber=True): +def ExtractAll(zip_path, path=None, no_clobber=True, pattern=None): if path is None: path = os.getcwd() elif not os.path.exists(path): @@ -201,6 +201,9 @@ def ExtractAll(zip_path, path=None, no_clobber=True): for name in z.namelist(): if name.endswith('/'): continue + if pattern is not None: + if not fnmatch.fnmatch(name, pattern): + continue CheckZipPath(name) if no_clobber: output_path = os.path.join(path, name) @@ -229,6 +232,22 @@ def ZipDir(output, base_dir): outfile.write(path, archive_path) +def MergeZips(output, inputs, exclude_patterns=None): + def Allow(name): + if exclude_patterns is not None: + for p in exclude_patterns: + if fnmatch.fnmatch(name, p): + return False + return True + + with zipfile.ZipFile(output, 'w') as out_zip: + for in_file in inputs: + with zipfile.ZipFile(in_file, 'r') as in_zip: + for name in in_zip.namelist(): + if Allow(name): + out_zip.writestr(name, in_zip.read(name)) + + def PrintWarning(message): print 'WARNING: ' + message diff --git a/build/android/gyp/write_build_config.py b/build/android/gyp/write_build_config.py index 04437b6047..ab70a79056 100755 --- a/build/android/gyp/write_build_config.py +++ b/build/android/gyp/write_build_config.py @@ -69,9 +69,12 @@ def main(argv): 'dependencies may not write build_config files. Missing build_config ' 'files are handled differently based on the type of this target.') - # android_resources/apk options + # android_resources options parser.add_option('--srcjar', help='Path to target\'s resources srcjar.') parser.add_option('--resources-zip', help='Path to target\'s resources zip.') + parser.add_option('--package-name', + help='Java package name for these resources.') + parser.add_option('--android-manifest', help='Path to android manifest.') # android_library/apk options parser.add_option('--jar-path', help='Path to target\'s jar output.') @@ -111,7 +114,7 @@ def main(argv): unknown_deps = [ c for c in possible_deps_config_paths if not os.path.exists(c)] if unknown_deps and not allow_unknown_deps: - raise Exception('Unknown deps: ' + unknown_deps) + raise Exception('Unknown deps: ' + str(unknown_deps)) direct_deps_config_paths = [ c for c in possible_deps_config_paths if not c in unknown_deps] @@ -121,9 +124,11 @@ def main(argv): all_deps_configs = [GetDepConfig(p) for p in all_deps_config_paths] direct_library_deps = DepsOfType('android_library', direct_deps_configs) - all_resources_deps = DepsOfType('android_resources', all_deps_configs) all_library_deps = DepsOfType('android_library', all_deps_configs) + direct_resources_deps = DepsOfType('android_resources', direct_deps_configs) + all_resources_deps = DepsOfType('android_resources', all_deps_configs) + # Initialize some common config. config = { 'deps_info': { @@ -142,21 +147,33 @@ def main(argv): config['javac'] = { 'classpath': javac_classpath, } + + if options.type == 'android_library': # Only resources might have srcjars (normal srcjar targets are listed in # srcjar_deps). A resource's srcjar contains the R.java file for those # resources, and (like Android's default build system) we allow a library to # refer to the resources in any of its dependents. config['javac']['srcjars'] = [ - c['srcjar'] for c in all_resources_deps if 'srcjar' in c] + c['srcjar'] for c in direct_resources_deps if 'srcjar' in c] - if options.type == 'android_resources' or options.type == 'android_apk': + if options.type == 'android_apk': + config['javac']['srcjars'] = [] + + + if options.type == 'android_resources': deps_info['resources_zip'] = options.resources_zip if options.srcjar: deps_info['srcjar'] = options.srcjar + if options.package_name: + deps_info['package_name'] = options.package_name + if options.type == 'android_resources' or options.type == 'android_apk': config['resources'] = {} config['resources']['dependency_zips'] = [ c['resources_zip'] for c in all_resources_deps] + config['resources']['extra_package_names'] = [ + c['package_name'] for c in all_resources_deps if 'package_name' in c] + if options.type == 'android_apk': config['apk_dex'] = {} @@ -165,25 +182,34 @@ def main(argv): dex_deps_files = [c['dex_path'] for c in all_library_deps] dex_config['dependency_dex_files'] = dex_deps_files + config['dist_jar'] = { + 'dependency_jars': [ + c['jar_path'] for c in all_library_deps + ] + } + library_paths = [] java_libraries_list = [] if options.native_libs: libraries = build_utils.ParseGypList(options.native_libs) - libraries_dir = os.path.dirname(libraries[0]) - write_ordered_libraries.SetReadelfPath(options.readelf_path) - write_ordered_libraries.SetLibraryDirs([libraries_dir]) - all_native_library_deps = ( - write_ordered_libraries.GetSortedTransitiveDependenciesForBinaries( - libraries)) - java_libraries_list = '{%s}' % ','.join( - ['"%s"' % s for s in all_native_library_deps]) - library_paths = map( - write_ordered_libraries.FullLibraryPath, all_native_library_deps) - - config['native'] = { - 'libraries': library_paths, - 'java_libraries_list': java_libraries_list - } + if libraries: + libraries_dir = os.path.dirname(libraries[0]) + write_ordered_libraries.SetReadelfPath(options.readelf_path) + write_ordered_libraries.SetLibraryDirs([libraries_dir]) + all_native_library_deps = ( + write_ordered_libraries.GetSortedTransitiveDependenciesForBinaries( + libraries)) + # Create a java literal array with the "base" library names: + # e.g. libfoo.so -> foo + java_libraries_list = '{%s}' % ','.join( + ['"%s"' % s[3:-3] for s in all_native_library_deps]) + library_paths = map( + write_ordered_libraries.FullLibraryPath, all_native_library_deps) + + config['native'] = { + 'libraries': library_paths, + 'java_libraries_list': java_libraries_list + } build_utils.WriteJson(config, options.build_config, only_if_changed=True) diff --git a/build/android/gyp/write_ordered_libraries.py b/build/android/gyp/write_ordered_libraries.py index 954f12daef..b361bc3616 100755 --- a/build/android/gyp/write_ordered_libraries.py +++ b/build/android/gyp/write_ordered_libraries.py @@ -96,6 +96,7 @@ def GetSortedTransitiveDependenciesForBinaries(binaries): def main(): parser = optparse.OptionParser() + build_utils.AddDepfileOption(parser) parser.add_option('--input-libraries', help='A list of top-level input libraries.') @@ -126,6 +127,12 @@ def main(): if options.stamp: build_utils.Touch(options.stamp) + if options.depfile: + print libraries + build_utils.WriteDepfile( + options.depfile, + libraries + build_utils.GetPythonDependencies()) + if __name__ == '__main__': sys.exit(main()) diff --git a/build/android/increase_size_for_speed.gypi b/build/android/increase_size_for_speed.gypi new file mode 100644 index 0000000000..f5f2d62633 --- /dev/null +++ b/build/android/increase_size_for_speed.gypi @@ -0,0 +1,26 @@ +# Copyright (c) 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This file is meant to be included to optimize a target for speed +# rather than for size on Android. +# This is used in some carefully tailored targets and is not meant +# to be included everywhere. Before adding the template to another target, +# please ask in chromium-dev@. See crbug.com/411909 + +{ + 'configurations': { + 'Release': { + 'target_conditions': [ + ['_toolset=="target"', { + 'conditions': [ + ['OS=="android"', { + 'cflags!': ['-Os'], + 'cflags': ['-O2'], + }], + ], + }], + ], + }, + }, +} diff --git a/build/android/java_cpp_enum.gypi b/build/android/java_cpp_enum.gypi new file mode 100644 index 0000000000..3d6b3266af --- /dev/null +++ b/build/android/java_cpp_enum.gypi @@ -0,0 +1,59 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This file is meant to be included into a target to provide an action +# to generate Java source files from a C++ header file containing annotated +# enum definitions using a Python script. +# +# To use this, create a gyp target with the following form: +# { +# 'target_name': 'bitmap_format_java', +# 'type': 'none', +# 'variables': { +# 'source_file': 'ui/android/bitmap_format.h', +# }, +# 'includes': [ '../build/android/java_cpp_enum.gypi' ], +# }, +# +# Then have the gyp target which compiles the java code depend on the newly +# created target. + +{ + 'variables': { + # Location where all generated Java sources will be placed. + 'output_dir': '<(SHARED_INTERMEDIATE_DIR)/enums/<(_target_name)', + 'generator_path': '<(DEPTH)/build/android/gyp/java_cpp_enum.py', + 'generator_args': '--output_dir=<(output_dir) <(source_file)', + }, + 'direct_dependent_settings': { + 'variables': { + # Ensure that the output directory is used in the class path + # when building targets that depend on this one. + 'generated_src_dirs': [ + '<(output_dir)/', + ], + }, + }, + 'actions': [ + { + 'action_name': 'generate_java_constants', + 'inputs': [ + '<(DEPTH)/build/android/gyp/util/build_utils.py', + '<(generator_path)', + '<(source_file)', + ], + 'outputs': [ + # This is the main reason this is an action and not a rule. Gyp doesn't + # properly expand RULE_INPUT_PATH here and so it's impossible to + # calculate the list of outputs. + '<!@pymod_do_main(java_cpp_enum --print_output_only ' + '<@(generator_args))', + ], + 'action': [ + 'python', '<(generator_path)', '<@(generator_args)' + ], + 'message': 'Generating Java from cpp header <(source_file)', + }, + ], +} diff --git a/build/android/lint/suppressions.xml b/build/android/lint/suppressions.xml index ea4f0aec48..d8422a74e4 100644 --- a/build/android/lint/suppressions.xml +++ b/build/android/lint/suppressions.xml @@ -41,67 +41,14 @@ Still reading? <issue id="HandlerLeak"> <ignore path="remoting/android/java/src/org/chromium/chromoting/TapGestureDetector.java"/> </issue> - <issue id="InlinedApi"> - <ignore path="base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java"/> - <ignore path="base/android/java/src/org/chromium/base/MemoryPressureListener.java"/> - <ignore path="chrome/android/java/src/org/chromium/chrome/browser/printing/PrintingControllerFactory.java"/> - <ignore path="content/public/android/java/src/org/chromium/content/browser/DeviceUtils.java"/> - <ignore path="content/public/android/java/src/org/chromium/content/browser/ScreenOrientationListener.java"/> - <ignore path="content/public/android/java/src/org/chromium/content/browser/accessibility/BrowserAccessibilityManager.java"/> - <ignore path="content/public/android/java/src/org/chromium/content/browser/accessibility/JellyBeanAccessibilityInjector.java"/> - <ignore path="media/base/android/java/src/org/chromium/media/AudioManagerAndroid.java"/> - <ignore path="media/base/android/java/src/org/chromium/media/MediaCodecBridge.java"/> - <ignore path="media/base/android/java/src/org/chromium/media/MediaDrmBridge.java"/> - <ignore path="media/base/android/java/src/org/chromium/media/WebAudioMediaCodecBridge.java"/> - <ignore path="net/android/java/src/org/chromium/net/X509Util.java"/> - <ignore path="printing/android/java/src/org/chromium/printing/PrintingControllerImpl.java"/> - <ignore path="printing/android/java/src/org/chromium/printing/PrintManagerDelegateImpl.java"/> - <ignore path="ui/android/java/src/org/chromium/ui/base/LocalizationUtils.java"/> - </issue> <issue id="MissingApplicationIcon" severity="ignore"/> <issue id="MissingRegistered" severity="ignore"/> <issue id="MissingVersion"> <ignore path="AndroidManifest.xml"/> </issue> - <issue id="NewApi"> - <ignore path="PRODUCT_DIR/chrome_shell_test_apk/classes/org/chromium/printing/PrintingControllerTest$6.class"/> - <ignore path="PRODUCT_DIR/chrome_shell_test_apk/classes/org/chromium/printing/PrintingControllerTest$7.class"/> - <ignore path="PRODUCT_DIR/chrome_shell_test_apk/classes/org/chromium/printing/PrintingControllerTest.class"/> - <ignore path="PRODUCT_DIR/content_shell_test_apk/classes/org/chromium/content/browser/ClipboardTest.class"/> - <ignore path="android_webview/java/src/org/chromium/android_webview/AwPdfExporter.java"/> - <ignore path="android_webview/java/src/org/chromium/android_webview/AwPrintDocumentAdapter.java"/> - <ignore path="android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java"/> - <ignore path="android_webview/test/shell/src/org/chromium/android_webview/test/AwTestContainerView.java"/> - <ignore path="base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java"/> - <ignore path="chrome/android/java/src/org/chromium/chrome/browser/BookmarkUtils.java"/> - <ignore path="chrome/android/java/src/org/chromium/chrome/browser/TtsPlatformImpl.java"/> - <ignore path="chrome/android/java/src/org/chromium/chrome/browser/infobar/AnimationHelper.java"/> - <ignore path="chrome/android/java/src/org/chromium/chrome/browser/signin/SigninManager.java"/> - <ignore path="chrome/test/chromedriver/test/webview_shell/java/src/org/chromium/chromedriver_webview_shell/Main.java"/> - <ignore path="content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java"/> - <ignore path="content/public/android/java/src/org/chromium/content/browser/GenericTouchGesture.java"/> - <ignore path="content/public/android/java/src/org/chromium/content/browser/VSyncMonitor.java"/> - <ignore path="content/public/android/java/src/org/chromium/content/browser/accessibility/BrowserAccessibilityManager.java"/> - <ignore path="content/public/android/java/src/org/chromium/content/browser/accessibility/JellyBeanAccessibilityInjector.java"/> - <ignore path="content/public/android/java/src/org/chromium/content/browser/accessibility/JellyBeanBrowserAccessibilityManager.java"/> - <ignore path="content/public/android/java/src/org/chromium/content/browser/accessibility/KitKatBrowserAccessibilityManager.java"/> - <ignore path="content/public/android/java/src/org/chromium/content/browser/input/InputDialogContainer.java"/> - <ignore path="content/public/android/javatests/src/org/chromium/content/browser/ClipboardTest.java"/> - <ignore path="media/base/android/java/src/org/chromium/media/AudioManagerAndroid.java"/> - <ignore path="media/base/android/java/src/org/chromium/media/MediaCodecBridge.java"/> - <ignore path="media/base/android/java/src/org/chromium/media/MediaDrmBridge.java"/> - <ignore path="media/base/android/java/src/org/chromium/media/VideoCapture.java"/> - <ignore path="media/base/android/java/src/org/chromium/media/WebAudioMediaCodecBridge.java"/> - <ignore path="printing/android/java/src/org/chromium/printing/PrintDocumentAdapterWrapper.java"/> - <ignore path="printing/android/java/src/org/chromium/printing/PrintManagerDelegateImpl.java"/> - <ignore path="printing/android/java/src/org/chromium/printing/PrintingControllerImpl.java"/> - <ignore path="tools/android/memconsumer/java/src/org/chromium/memconsumer/ResidentService.java"/> - <ignore path="ui/android/java/src/org/chromium/ui/ColorPickerAdvancedComponent.java"/> - <ignore path="ui/android/java/src/org/chromium/ui/base/Clipboard.java"/> - <ignore path="ui/android/java/src/org/chromium/ui/base/LocalizationUtils.java"/> - <ignore path="ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java"/> - <ignore path="ui/android/java/src/org/chromium/ui/gl/SurfaceTexturePlatformWrapper.java"/> - </issue> + <!-- Disabling is InlinedApi and NewApi is bad but we have too many of these errors and nobody is fixing it. crbug.com/411461 --> + <issue id="InlinedApi" severity="ignore"/> + <issue id="NewApi" severity="ignore"/> <issue id="OldTargetApi"> <ignore path="AndroidManifest.xml"/> </issue> diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py index 7c73b526da..0a4b2f0e47 100644 --- a/build/android/pylib/android_commands.py +++ b/build/android/pylib/android_commands.py @@ -701,8 +701,7 @@ class AndroidCommands(object): """Send a command to the adb shell and return the result. Args: - command: String containing the shell command to send. Must not include - the single quotes as we use them to escape the whole command. + command: String containing the shell command to send. timeout_time: Number of seconds to wait for command to respond before retrying, used by AdbInterface.SendShellCommand. log_result: Boolean to indicate whether we should log the result of the diff --git a/build/android/pylib/base/base_test_result.py b/build/android/pylib/base/base_test_result.py index c425d5cd58..1f45214d2c 100644 --- a/build/android/pylib/base/base_test_result.py +++ b/build/android/pylib/base/base_test_result.py @@ -7,6 +7,7 @@ class ResultType(object): """Class enumerating test types.""" PASS = 'PASS' + SKIP = 'SKIP' FAIL = 'FAIL' CRASH = 'CRASH' TIMEOUT = 'TIMEOUT' @@ -15,8 +16,8 @@ class ResultType(object): @staticmethod def GetTypes(): """Get a list of all test types.""" - return [ResultType.PASS, ResultType.FAIL, ResultType.CRASH, - ResultType.TIMEOUT, ResultType.UNKNOWN] + return [ResultType.PASS, ResultType.SKIP, ResultType.FAIL, + ResultType.CRASH, ResultType.TIMEOUT, ResultType.UNKNOWN] class BaseTestResult(object): @@ -97,19 +98,26 @@ class TestRunResults(object): s.append('[==========] %s ran.' % (tests(len(self.GetAll())))) s.append('[ PASSED ] %s.' % (tests(len(self.GetPass())))) - not_passed = self.GetNotPass() - if len(not_passed) > 0: - s.append('[ FAILED ] %s, listed below:' % tests(len(self.GetNotPass()))) - for t in self.GetFail(): + skipped = self.GetSkip() + if skipped: + s.append('[ SKIPPED ] Skipped %s, listed below:' % tests(len(skipped))) + for t in sorted(skipped): + s.append('[ SKIPPED ] %s' % str(t)) + + all_failures = self.GetFail().union(self.GetCrash(), self.GetTimeout(), + self.GetUnknown()) + if all_failures: + s.append('[ FAILED ] %s, listed below:' % tests(len(all_failures))) + for t in sorted(self.GetFail()): s.append('[ FAILED ] %s' % str(t)) - for t in self.GetCrash(): + for t in sorted(self.GetCrash()): s.append('[ FAILED ] %s (CRASHED)' % str(t)) - for t in self.GetTimeout(): + for t in sorted(self.GetTimeout()): s.append('[ FAILED ] %s (TIMEOUT)' % str(t)) - for t in self.GetUnknown(): + for t in sorted(self.GetUnknown()): s.append('[ FAILED ] %s (UNKNOWN)' % str(t)) s.append('') - s.append(plural(len(not_passed), 'FAILED TEST', 'FAILED TESTS')) + s.append(plural(len(all_failures), 'FAILED TEST', 'FAILED TESTS')) return '\n'.join(s) def GetShortForm(self): @@ -163,6 +171,10 @@ class TestRunResults(object): """Get the set of all passed test results.""" return self._GetType(ResultType.PASS) + def GetSkip(self): + """Get the set of all skipped test results.""" + return self._GetType(ResultType.SKIP) + def GetFail(self): """Get the set of all failed test results.""" return self._GetType(ResultType.FAIL) @@ -185,4 +197,5 @@ class TestRunResults(object): def DidRunPass(self): """Return whether the test run was successful.""" - return not self.GetNotPass() + return not (self.GetNotPass() - self.GetSkip()) + diff --git a/build/android/pylib/constants.py b/build/android/pylib/constants.py index 3d0dfbc941..8b800ab5dc 100644 --- a/build/android/pylib/constants.py +++ b/build/android/pylib/constants.py @@ -11,8 +11,9 @@ import os import subprocess -DIR_SOURCE_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), - os.pardir, os.pardir, os.pardir)) +DIR_SOURCE_ROOT = os.environ.get('CHECKOUT_SOURCE_ROOT', + os.path.abspath(os.path.join(os.path.dirname(__file__), + os.pardir, os.pardir, os.pardir))) ISOLATE_DEPS_DIR = os.path.join(DIR_SOURCE_ROOT, 'isolate_deps_dir') CHROME_SHELL_HOST_DRIVEN_DIR = os.path.join( diff --git a/build/android/pylib/device/device_utils.py b/build/android/pylib/device/device_utils.py index 8a8de22519..fccdd619d0 100644 --- a/build/android/pylib/device/device_utils.py +++ b/build/android/pylib/device/device_utils.py @@ -8,6 +8,7 @@ Eventually, this will be based on adb_wrapper. """ # pylint: disable=W0613 +import pipes import sys import time @@ -364,20 +365,20 @@ class DeviceUtils(object): CommandTimeoutError on timeout. DeviceUnreachableError on missing device. """ - pids = self.old_interface.ExtractPid(process_name) - if len(pids) == 0: + pids = self._GetPidsImpl(process_name) + if not pids: raise device_errors.CommandFailedError( 'No process "%s"' % process_name, device=str(self)) + cmd = 'kill -%d %s' % (signum, ' '.join(pids.values())) + self._RunShellCommandImpl(cmd, as_root=as_root) + if blocking: - total_killed = self.old_interface.KillAllBlocking( - process_name, signum=signum, with_su=as_root, timeout_sec=timeout) - else: - total_killed = self.old_interface.KillAll( - process_name, signum=signum, with_su=as_root) - if total_killed == 0: - raise device_errors.CommandFailedError( - 'Failed to kill "%s"' % process_name, device=str(self)) + wait_period = 0.1 + while self._GetPidsImpl(process_name): + time.sleep(wait_period) + + return len(pids) @decorators.WithTimeoutAndRetriesFromInstance() def StartActivity(self, intent, blocking=False, trace_file_name=None, @@ -635,6 +636,31 @@ class DeviceUtils(object): self.old_interface.SetFileContents(device_path, contents) @decorators.WithTimeoutAndRetriesFromInstance() + def WriteTextFile(self, device_path, text, as_root=False, timeout=None, + retries=None): + """Writes |text| to a file on the device. + + Assuming that |text| is a small string, this is typically more efficient + than |WriteFile|, as no files are pushed into the device. + + Args: + device_path: A string containing the absolute path to the file to write + on the device. + text: A short string of text to write to the file on the device. + as_root: A boolean indicating whether the write should be executed with + root privileges. + timeout: timeout in seconds + retries: number of retries + + Raises: + CommandFailedError if the file could not be written on the device. + CommandTimeoutError on timeout. + DeviceUnreachableError on missing device. + """ + self._RunShellCommandImpl('echo {1} > {0}'.format(device_path, + pipes.quote(text)), check_return=True, as_root=as_root) + + @decorators.WithTimeoutAndRetriesFromInstance() def Ls(self, device_path, timeout=None, retries=None): """Lists the contents of a directory on the device. @@ -663,10 +689,14 @@ class DeviceUtils(object): timeout: timeout in seconds retries: number of retries + Returns: + True if the device-side property changed and a restart is required as a + result, False otherwise. + Raises: CommandTimeoutError on timeout. """ - self.old_interface.SetJavaAssertsEnabled(enabled) + return self.old_interface.SetJavaAssertsEnabled(enabled) @decorators.WithTimeoutAndRetriesFromInstance() def GetProp(self, property_name, timeout=None, retries=None): @@ -722,6 +752,24 @@ class DeviceUtils(object): CommandTimeoutError on timeout. DeviceUnreachableError on missing device. """ + return self._GetPidsImpl(process_name) + + def _GetPidsImpl(self, process_name): + """Implementation of GetPids. + + This is split from GetPids to allow other DeviceUtils methods to call + GetPids without spawning a new timeout thread. + + Args: + process_name: A string containing the process name to get the PIDs for. + + Returns: + A dict mapping process name to PID for each process that contained the + provided |process_name|. + + Raises: + DeviceUnreachableError on missing device. + """ procs_pids = {} for line in self._RunShellCommandImpl('ps'): try: diff --git a/build/android/pylib/device/device_utils_test.py b/build/android/pylib/device/device_utils_test.py index 2692e1255b..42dc5b2ccb 100755 --- a/build/android/pylib/device/device_utils_test.py +++ b/build/android/pylib/device/device_utils_test.py @@ -557,12 +557,9 @@ class DeviceUtilsKillAllTest(DeviceUtilsOldImplTest): 'USER PID PPID VSIZE RSS WCHAN PC NAME\r\n' 'u0_a1 1234 174 123456 54321 ffffffff 456789ab ' 'this.is.a.test.process\r\n'), - ("adb -s 0123456789abcdef shell 'ps'", - 'USER PID PPID VSIZE RSS WCHAN PC NAME\r\n' - 'u0_a1 1234 174 123456 54321 ffffffff 456789ab ' - 'this.is.a.test.process\r\n'), ("adb -s 0123456789abcdef shell 'kill -9 1234'", '')]): - self.device.KillAll('this.is.a.test.process', blocking=False) + self.assertEquals(1, + self.device.KillAll('this.is.a.test.process', blocking=False)) def testKillAll_blocking(self): with mock.patch('time.sleep'): @@ -571,10 +568,6 @@ class DeviceUtilsKillAllTest(DeviceUtilsOldImplTest): 'USER PID PPID VSIZE RSS WCHAN PC NAME\r\n' 'u0_a1 1234 174 123456 54321 ffffffff 456789ab ' 'this.is.a.test.process\r\n'), - ("adb -s 0123456789abcdef shell 'ps'", - 'USER PID PPID VSIZE RSS WCHAN PC NAME\r\n' - 'u0_a1 1234 174 123456 54321 ffffffff 456789ab ' - 'this.is.a.test.process\r\n'), ("adb -s 0123456789abcdef shell 'kill -9 1234'", ''), ("adb -s 0123456789abcdef shell 'ps'", 'USER PID PPID VSIZE RSS WCHAN PC NAME\r\n' @@ -582,7 +575,8 @@ class DeviceUtilsKillAllTest(DeviceUtilsOldImplTest): 'this.is.a.test.process\r\n'), ("adb -s 0123456789abcdef shell 'ps'", 'USER PID PPID VSIZE RSS WCHAN PC NAME\r\n')]): - self.device.KillAll('this.is.a.test.process', blocking=True) + self.assertEquals(1, + self.device.KillAll('this.is.a.test.process', blocking=True)) def testKillAll_root(self): with self.assertCallsSequence([ @@ -590,12 +584,10 @@ class DeviceUtilsKillAllTest(DeviceUtilsOldImplTest): 'USER PID PPID VSIZE RSS WCHAN PC NAME\r\n' 'u0_a1 1234 174 123456 54321 ffffffff 456789ab ' 'this.is.a.test.process\r\n'), - ("adb -s 0123456789abcdef shell 'ps'", - 'USER PID PPID VSIZE RSS WCHAN PC NAME\r\n' - 'u0_a1 1234 174 123456 54321 ffffffff 456789ab ' - 'this.is.a.test.process\r\n'), + ("adb -s 0123456789abcdef shell 'ls /root'", 'Permission denied\r\n'), ("adb -s 0123456789abcdef shell 'su -c kill -9 1234'", '')]): - self.device.KillAll('this.is.a.test.process', as_root=True) + self.assertEquals(1, + self.device.KillAll('this.is.a.test.process', as_root=True)) def testKillAll_sigterm(self): with self.assertCallsSequence([ @@ -603,12 +595,9 @@ class DeviceUtilsKillAllTest(DeviceUtilsOldImplTest): 'USER PID PPID VSIZE RSS WCHAN PC NAME\r\n' 'u0_a1 1234 174 123456 54321 ffffffff 456789ab ' 'this.is.a.test.process\r\n'), - ("adb -s 0123456789abcdef shell 'ps'", - 'USER PID PPID VSIZE RSS WCHAN PC NAME\r\n' - 'u0_a1 1234 174 123456 54321 ffffffff 456789ab ' - 'this.is.a.test.process\r\n'), ("adb -s 0123456789abcdef shell 'kill -15 1234'", '')]): - self.device.KillAll('this.is.a.test.process', signum=signal.SIGTERM) + self.assertEquals(1, + self.device.KillAll('this.is.a.test.process', signum=signal.SIGTERM)) class DeviceUtilsStartActivityTest(DeviceUtilsOldImplTest): @@ -1207,6 +1196,44 @@ class DeviceUtilsWriteFileTest(DeviceUtilsOldImplTest): self.device.WriteFile('/test/file/no.permissions.to.write', 'new test file contents', as_root=True) +class DeviceUtilsWriteTextFileTest(DeviceUtilsOldImplTest): + + def testWriteTextFileTest_basic(self): + with self.assertCalls( + "adb -s 0123456789abcdef shell 'echo some.string" + " > /test/file/to.write; echo %$?'", '%0\r\n'): + self.device.WriteTextFile('/test/file/to.write', 'some.string') + + def testWriteTextFileTest_stringWithSpaces(self): + with self.assertCalls( + "adb -s 0123456789abcdef shell 'echo '\\''some other string'\\''" + " > /test/file/to.write; echo %$?'", '%0\r\n'): + self.device.WriteTextFile('/test/file/to.write', 'some other string') + + def testWriteTextFileTest_asRoot_withSu(self): + with self.assertCallsSequence([ + ("adb -s 0123456789abcdef shell 'ls /root'", 'Permission denied\r\n'), + ("adb -s 0123456789abcdef shell 'su -c echo some.string" + " > /test/file/to.write; echo %$?'", '%0\r\n')]): + self.device.WriteTextFile('/test/file/to.write', 'some.string', + as_root=True) + + def testWriteTextFileTest_asRoot_withRoot(self): + with self.assertCallsSequence([ + ("adb -s 0123456789abcdef shell 'ls /root'", 'hello\r\nworld\r\n'), + ("adb -s 0123456789abcdef shell 'echo some.string" + " > /test/file/to.write; echo %$?'", '%0\r\n')]): + self.device.WriteTextFile('/test/file/to.write', 'some.string', + as_root=True) + + def testWriteTextFileTest_asRoot_rejected(self): + with self.assertCallsSequence([ + ("adb -s 0123456789abcdef shell 'ls /root'", 'Permission denied\r\n'), + ("adb -s 0123456789abcdef shell 'su -c echo some.string" + " > /test/file/to.write; echo %$?'", '%1\r\n')]): + with self.assertRaises(device_errors.CommandFailedError): + self.device.WriteTextFile('/test/file/to.write', 'some.string', + as_root=True) class DeviceUtilsLsTest(DeviceUtilsOldImplTest): @@ -1285,7 +1312,7 @@ class DeviceUtilsSetJavaAssertsTest(DeviceUtilsOldImplTest): ('adb -s 0123456789abcdef shell ' 'setprop dalvik.vm.enableassertions "all"', '')]): - self.device.SetJavaAsserts(True) + self.assertTrue(self.device.SetJavaAsserts(True)) def testSetJavaAsserts_disable(self): mock_file = self.mockNamedTemporary( @@ -1309,7 +1336,7 @@ class DeviceUtilsSetJavaAssertsTest(DeviceUtilsOldImplTest): ('adb -s 0123456789abcdef shell ' 'setprop dalvik.vm.enableassertions ""', '')]): - self.device.SetJavaAsserts(False) + self.assertTrue(self.device.SetJavaAsserts(False)) def testSetJavaAsserts_alreadyEnabled(self): mock_file = self.mockNamedTemporary( diff --git a/build/android/pylib/gtest/filter/webkit_unit_tests_disabled b/build/android/pylib/gtest/filter/webkit_unit_tests_disabled index 1ffa325899..50292aa4ff 100644 --- a/build/android/pylib/gtest/filter/webkit_unit_tests_disabled +++ b/build/android/pylib/gtest/filter/webkit_unit_tests_disabled @@ -23,3 +23,6 @@ DeferredImageDecoderTest.drawIntoSkPictureProgressive # crbug.com/320005 CoreAnimationCompositorAnimationsTest.ConvertTimingForCompositorIterationCount + +# crbug.com/412145 +TouchActionTest.Pan diff --git a/build/android/pylib/gtest/gtest_config.py b/build/android/pylib/gtest/gtest_config.py index ce3aef4170..aeca27e5d9 100644 --- a/build/android/pylib/gtest/gtest_config.py +++ b/build/android/pylib/gtest/gtest_config.py @@ -8,6 +8,7 @@ EXPERIMENTAL_TEST_SUITES = [ 'content_gl_tests', 'heap_profiler_unittests', + 'devtools_bridge_tests', ] # Do not modify this list without approval of an android owner. @@ -41,20 +42,3 @@ ASAN_EXCLUDED_TEST_SUITES = [ 'breakpad_unittests', 'sandbox_linux_unittests' ] - -WEBRTC_CHROMIUM_TEST_SUITES = [ - 'content_browsertests', -] - -WEBRTC_NATIVE_TEST_SUITES = [ - 'audio_decoder_unittests', - 'common_audio_unittests', - 'common_video_unittests', - 'modules_tests', - 'modules_unittests', - 'system_wrappers_unittests', - 'test_support_unittests', - 'tools_unittests', - 'video_engine_core_unittests', - 'voice_engine_unittests', -] diff --git a/build/android/pylib/gtest/setup.py b/build/android/pylib/gtest/setup.py index 00a575350a..6a9e65b946 100644 --- a/build/android/pylib/gtest/setup.py +++ b/build/android/pylib/gtest/setup.py @@ -40,35 +40,12 @@ _ISOLATE_FILE_PATHS = { 'media_unittests': 'media/media_unittests.isolate', 'net_unittests': 'net/net_unittests.isolate', 'sql_unittests': 'sql/sql_unittests.isolate', - 'ui_unittests': 'ui/ui_unittests.isolate', + 'ui_unittests': 'ui/base/ui_base_tests.isolate', 'unit_tests': 'chrome/unit_tests.isolate', 'webkit_unit_tests': 'third_party/WebKit/Source/web/WebKitUnitTests.isolate', } -# Paths relative to third_party/webrtc/ (kept separate for readability). -_WEBRTC_ISOLATE_FILE_PATHS = { - 'audio_decoder_unittests': - 'modules/audio_coding/neteq/audio_decoder_unittests.isolate', - 'common_audio_unittests': 'common_audio/common_audio_unittests.isolate', - 'common_video_unittests': 'common_video/common_video_unittests.isolate', - 'modules_tests': 'modules/modules_tests.isolate', - 'modules_unittests': 'modules/modules_unittests.isolate', - 'system_wrappers_unittests': - 'system_wrappers/source/system_wrappers_unittests.isolate', - 'test_support_unittests': 'test/test_support_unittests.isolate', - 'tools_unittests': 'tools/tools_unittests.isolate', - 'video_engine_tests': 'video_engine_tests.isolate', - 'video_engine_core_unittests': - 'video_engine/video_engine_core_unittests.isolate', - 'voice_engine_unittests': 'voice_engine/voice_engine_unittests.isolate', - 'webrtc_perf_tests': 'webrtc_perf_tests.isolate', -} - -# Append the WebRTC tests with the full path from Chromium's src/ root. -for webrtc_test, isolate_path in _WEBRTC_ISOLATE_FILE_PATHS.items(): - _ISOLATE_FILE_PATHS[webrtc_test] = 'third_party/webrtc/%s' % isolate_path - # Used for filtering large data deps at a finer grain than what's allowed in # isolate files since pushing deps to devices is expensive. # Wildcards are allowed. @@ -121,7 +98,7 @@ def _GenerateDepsDirUsingIsolate(suite_name, isolate_file_path=None): isolated_abs_path = os.path.join( constants.GetOutDirectory(), '%s.isolated' % suite_name) - assert os.path.exists(isolate_abs_path) + assert os.path.exists(isolate_abs_path), 'Cannot find %s' % isolate_abs_path # This needs to be kept in sync with the cmd line options for isolate.py # in src/build/isolate.gypi. isolate_cmd = [ @@ -136,12 +113,15 @@ def _GenerateDepsDirUsingIsolate(suite_name, isolate_file_path=None): '--config-variable', 'OS', 'android', '--config-variable', 'CONFIGURATION_NAME', constants.GetBuildType(), + '--config-variable', 'asan', '0', '--config-variable', 'chromeos', '0', '--config-variable', 'component', 'static_library', + '--config-variable', 'fastbuild', '0', '--config-variable', 'icu_use_data_file_flag', '1', # TODO(maruel): This may not be always true. '--config-variable', 'target_arch', 'arm', '--config-variable', 'use_openssl', '0', + '--config-variable', 'use_ozone', '0', ] assert not cmd_helper.RunCmd(isolate_cmd) @@ -236,6 +216,11 @@ def _GetTests(test_options, test_package, devices): """ def TestListerRunnerFactory(device, _shard_index): class TestListerRunner(test_runner.TestRunner): + #override + def PushDataDeps(self): + pass + + #override def RunTest(self, _test): result = base_test_result.BaseTestResult( 'gtest_list_tests', base_test_result.ResultType.PASS) @@ -317,12 +302,16 @@ def Setup(test_options, devices): """ test_package = test_package_apk.TestPackageApk(test_options.suite_name) if not os.path.exists(test_package.suite_path): - test_package = test_package_exe.TestPackageExecutable( + exe_test_package = test_package_exe.TestPackageExecutable( test_options.suite_name) - if not os.path.exists(test_package.suite_path): + if not os.path.exists(exe_test_package.suite_path): raise Exception( - 'Did not find %s target. Ensure it has been built.' - % test_options.suite_name) + 'Did not find %s target. Ensure it has been built.\n' + '(not found at %s or %s)' + % (test_options.suite_name, + test_package.suite_path, + exe_test_package.suite_path)) + test_package = exe_test_package logging.warning('Found target %s', test_package.suite_path) _GenerateDepsDirUsingIsolate(test_options.suite_name, diff --git a/build/android/pylib/instrumentation/test_runner.py b/build/android/pylib/instrumentation/test_runner.py index 0a448c3384..4f8cdcf304 100644 --- a/build/android/pylib/instrumentation/test_runner.py +++ b/build/android/pylib/instrumentation/test_runner.py @@ -10,7 +10,6 @@ import re import sys import time -from pylib import android_commands from pylib import constants from pylib import flag_changer from pylib import valgrind_tools @@ -20,8 +19,7 @@ from pylib.device import device_errors from pylib.instrumentation import json_perf_parser from pylib.instrumentation import test_result -sys.path.append(os.path.join(sys.path[0], - os.pardir, os.pardir, 'build', 'util', 'lib', +sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib', 'common')) import perf_tests_results_helper # pylint: disable=F0401 @@ -219,7 +217,7 @@ class TestRunner(base_test_runner.BaseTestRunner): 'shell rm ' + TestRunner._DEVICE_PERF_OUTPUT_SEARCH_PREFIX) self.device.old_interface.StartMonitoringLogcat() - def TestTeardown(self, test, raw_result): + def TestTeardown(self, test, result): """Cleans up the test harness after running a particular test. Depending on the options of this TestRunner this might handle performance @@ -227,13 +225,13 @@ class TestRunner(base_test_runner.BaseTestRunner): Args: test: The name of the test that was just run. - raw_result: result for this test. + result: result for this test. """ self.tool.CleanUpEnvironment() # The logic below relies on the test passing. - if not raw_result or raw_result.GetStatusCode(): + if not result or not result.DidRunPass(): return self.TearDownPerfMonitoring(test) @@ -341,64 +339,131 @@ class TestRunner(base_test_runner.BaseTestRunner): "1 minute for timeout.").format(test)) return 1 * 60 - def RunInstrumentationTest(self, test, test_package, instr_args, timeout): + def _RunTest(self, test, timeout): """Runs a single instrumentation test. Args: test: Test class/method. - test_package: Package name of test apk. - instr_args: Extra key/value to pass to am instrument. timeout: Timeout time in seconds. Returns: - An instance of am_instrument_parser.TestResult object. + The raw output of am instrument as a list of lines. """ + # Build the 'am instrument' command instrumentation_path = ( - '%s/%s' % (test_package, self.options.test_runner)) - args_with_filter = dict(instr_args) - args_with_filter['class'] = test - logging.info(args_with_filter) - (raw_results, _) = self.device.old_interface.Adb().StartInstrumentation( - instrumentation_path=instrumentation_path, - instrumentation_args=args_with_filter, - timeout_time=timeout) - assert len(raw_results) == 1 - return raw_results[0] + '%s/%s' % (self.test_pkg.GetPackageName(), self.options.test_runner)) + cmd = ['am', 'instrument', '-r'] + for k, v in self._GetInstrumentationArgs().iteritems(): + cmd.extend(['-e', k, "'%s'" % v]) + cmd.extend(['-e', 'class', "'%s'" % test]) + cmd.extend(['-w', instrumentation_path]) + return self.device.RunShellCommand(cmd, timeout=timeout, retries=0) - def _RunTest(self, test, timeout): - try: - return self.RunInstrumentationTest( - test, self.test_pkg.GetPackageName(), - self._GetInstrumentationArgs(), timeout) - except (device_errors.CommandTimeoutError, - # TODO(jbudorick) Remove this once the underlying implementations - # for the above are switched or wrapped. - android_commands.errors.WaitForResponseTimedOutError): - logging.info('Ran the test with timeout of %ds.' % timeout) - raise + @staticmethod + def _ParseAmInstrumentRawOutput(raw_output): + """Parses the output of an |am instrument -r| call. - #override - def RunTest(self, test): - raw_result = None - start_date_ms = None - results = base_test_result.TestRunResults() - timeout = (self._GetIndividualTestTimeoutSecs(test) * - self._GetIndividualTestTimeoutScale(test) * - self.tool.GetTimeoutScale()) - try: - self.TestSetup(test) - start_date_ms = int(time.time()) * 1000 - raw_result = self._RunTest(test, timeout) - duration_ms = int(time.time()) * 1000 - start_date_ms - status_code = raw_result.GetStatusCode() - if status_code: - if self.options.screenshot_failures: - self._TakeScreenshot(test) - log = raw_result.GetFailureReason() - if not log: - log = 'No information.' + Args: + raw_output: the output of an |am instrument -r| call as a list of lines + Returns: + A 3-tuple containing: + - the instrumentation code as an integer + - the instrumentation result as a list of lines + - the instrumentation statuses received as a list of 2-tuples + containing: + - the status code as an integer + - the bundle dump as a dict mapping string keys to a list of + strings, one for each line. + """ + INSTR_STATUS = 'INSTRUMENTATION_STATUS: ' + INSTR_STATUS_CODE = 'INSTRUMENTATION_STATUS_CODE: ' + INSTR_RESULT = 'INSTRUMENTATION_RESULT: ' + INSTR_CODE = 'INSTRUMENTATION_CODE: ' + + last = None + instr_code = None + instr_result = [] + instr_statuses = [] + bundle = {} + for line in raw_output: + if line.startswith(INSTR_STATUS): + instr_var = line[len(INSTR_STATUS):] + if '=' in instr_var: + k, v = instr_var.split('=', 1) + bundle[k] = [v] + last = INSTR_STATUS + last_key = k + else: + logging.debug('Unknown "%s" line: %s' % (INSTR_STATUS, line)) + + elif line.startswith(INSTR_STATUS_CODE): + instr_status = line[len(INSTR_STATUS_CODE):] + instr_statuses.append((int(instr_status), bundle)) + bundle = {} + last = INSTR_STATUS_CODE + + elif line.startswith(INSTR_RESULT): + instr_result.append(line[len(INSTR_RESULT):]) + last = INSTR_RESULT + + elif line.startswith(INSTR_CODE): + instr_code = int(line[len(INSTR_CODE):]) + last = INSTR_CODE + + elif last == INSTR_STATUS: + bundle[last_key].append(line) + + elif last == INSTR_RESULT: + instr_result.append(line) + + return (instr_code, instr_result, instr_statuses) + + def _GenerateTestResult(self, test, instr_statuses, start_ms, duration_ms): + """Generate the result of |test| from |instr_statuses|. + + Args: + instr_statuses: A list of 2-tuples containing: + - the status code as an integer + - the bundle dump as a dict mapping string keys to string values + Note that this is the same as the third item in the 3-tuple returned by + |_ParseAmInstrumentRawOutput|. + start_ms: The start time of the test in milliseconds. + duration_ms: The duration of the test in milliseconds. + Returns: + An InstrumentationTestResult object. + """ + INSTR_STATUS_CODE_START = 1 + INSTR_STATUS_CODE_OK = 0 + INSTR_STATUS_CODE_ERROR = -1 + INSTR_STATUS_CODE_FAIL = -2 + + log = '' + result_type = base_test_result.ResultType.UNKNOWN + + for status_code, bundle in instr_statuses: + if status_code == INSTR_STATUS_CODE_START: + pass + elif status_code == INSTR_STATUS_CODE_OK: + bundle_test = '%s#%s' % ( + ''.join(bundle.get('class', [''])), + ''.join(bundle.get('test', ['']))) + skipped = ''.join(bundle.get('test_skipped', [''])) + + if (test == bundle_test and + result_type == base_test_result.ResultType.UNKNOWN): + result_type = base_test_result.ResultType.PASS + elif skipped.lower() in ('true', '1', 'yes'): + result_type = base_test_result.ResultType.SKIP + logging.info('Skipped ' + test) + else: + if status_code not in (INSTR_STATUS_CODE_ERROR, + INSTR_STATUS_CODE_FAIL): + logging.info('Unrecognized status code %d. Handling as an error.', + status_code) result_type = base_test_result.ResultType.FAIL + if 'stack' in bundle: + log = '\n'.join(bundle['stack']) # Dismiss any error dialogs. Limit the number in case we have an error # loop or we are failing to dismiss. for _ in xrange(10): @@ -409,32 +474,38 @@ class TestRunner(base_test_runner.BaseTestRunner): if package in self.test_pkg.GetPackageName(): result_type = base_test_result.ResultType.CRASH break - result = test_result.InstrumentationTestResult( - test, result_type, start_date_ms, duration_ms, log=log) - else: - result = test_result.InstrumentationTestResult( - test, base_test_result.ResultType.PASS, start_date_ms, duration_ms) + + return test_result.InstrumentationTestResult( + test, result_type, start_ms, duration_ms, log=log) + + #override + def RunTest(self, test): + results = base_test_result.TestRunResults() + timeout = (self._GetIndividualTestTimeoutSecs(test) * + self._GetIndividualTestTimeoutScale(test) * + self.tool.GetTimeoutScale()) + + start_ms = 0 + duration_ms = 0 + try: + self.TestSetup(test) + + time_ms = lambda: int(time.time() * 1000) + start_ms = time_ms() + raw_output = self._RunTest(test, timeout) + duration_ms = time_ms() - start_ms + + # Parse the test output + _, _, statuses = self._ParseAmInstrumentRawOutput(raw_output) + result = self._GenerateTestResult(test, statuses, start_ms, duration_ms) results.AddResult(result) - # Catch exceptions thrown by StartInstrumentation(). - # See ../../third_party/android/testrunner/adb_interface.py - except (device_errors.CommandTimeoutError, - device_errors.DeviceUnreachableError, - # TODO(jbudorick) Remove these once the underlying implementations - # for the above are switched or wrapped. - android_commands.errors.WaitForResponseTimedOutError, - android_commands.errors.DeviceUnresponsiveError, - android_commands.errors.InstrumentationError), e: - if start_date_ms: - duration_ms = int(time.time()) * 1000 - start_date_ms - else: - start_date_ms = int(time.time()) * 1000 - duration_ms = 0 - message = str(e) - if not message: - message = 'No information.' + except device_errors.CommandTimeoutError as e: + results.AddResult(test_result.InstrumentationTestResult( + test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, + log=str(e) or 'No information')) + except device_errors.DeviceUnreachableError as e: results.AddResult(test_result.InstrumentationTestResult( - test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, - log=message)) - raw_result = None - self.TestTeardown(test, raw_result) + test, base_test_result.ResultType.CRASH, start_ms, duration_ms, + log=str(e) or 'No information')) + self.TestTeardown(test, results) return (results, None if results.DidRunPass() else test) diff --git a/build/android/pylib/instrumentation/test_runner_test.py b/build/android/pylib/instrumentation/test_runner_test.py new file mode 100755 index 0000000000..1a2b40f29a --- /dev/null +++ b/build/android/pylib/instrumentation/test_runner_test.py @@ -0,0 +1,271 @@ +#!/usr/bin/env python +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +"""Unit tests for instrumentation.TestRunner.""" + +# pylint: disable=W0212 + +import os +import sys +import unittest + +from pylib import constants +from pylib.base import base_test_result +from pylib.instrumentation import test_runner + +sys.path.append(os.path.join( + constants.DIR_SOURCE_ROOT, 'third_party', 'pymock')) +import mock # pylint: disable=F0401 + + +class InstrumentationTestRunnerTest(unittest.TestCase): + + def setUp(self): + options = mock.Mock() + options.tool = '' + package = mock.Mock() + self.instance = test_runner.TestRunner(options, None, 0, package) + + def testParseAmInstrumentRawOutput_nothing(self): + code, result, statuses = ( + test_runner.TestRunner._ParseAmInstrumentRawOutput([''])) + self.assertEqual(None, code) + self.assertEqual([], result) + self.assertEqual([], statuses) + + def testParseAmInstrumentRawOutput_noMatchingStarts(self): + raw_output = [ + '', + 'this.is.a.test.package.TestClass:.', + 'Test result for =.', + 'Time: 1.234', + '', + 'OK (1 test)', + ] + + code, result, statuses = ( + test_runner.TestRunner._ParseAmInstrumentRawOutput(raw_output)) + self.assertEqual(None, code) + self.assertEqual([], result) + self.assertEqual([], statuses) + + def testParseAmInstrumentRawOutput_resultAndCode(self): + raw_output = [ + 'INSTRUMENTATION_RESULT: foo', + 'bar', + 'INSTRUMENTATION_CODE: -1', + ] + + code, result, _ = ( + test_runner.TestRunner._ParseAmInstrumentRawOutput(raw_output)) + self.assertEqual(-1, code) + self.assertEqual(['foo', 'bar'], result) + + def testParseAmInstrumentRawOutput_oneStatus(self): + raw_output = [ + 'INSTRUMENTATION_STATUS: foo=1', + 'INSTRUMENTATION_STATUS: bar=hello', + 'INSTRUMENTATION_STATUS: world=false', + 'INSTRUMENTATION_STATUS: class=this.is.a.test.package.TestClass', + 'INSTRUMENTATION_STATUS: test=testMethod', + 'INSTRUMENTATION_STATUS_CODE: 0', + ] + + _, _, statuses = ( + test_runner.TestRunner._ParseAmInstrumentRawOutput(raw_output)) + + expected = [ + (0, { + 'foo': ['1'], + 'bar': ['hello'], + 'world': ['false'], + 'class': ['this.is.a.test.package.TestClass'], + 'test': ['testMethod'], + }) + ] + self.assertEqual(expected, statuses) + + def testParseAmInstrumentRawOutput_multiStatus(self): + raw_output = [ + 'INSTRUMENTATION_STATUS: class=foo', + 'INSTRUMENTATION_STATUS: test=bar', + 'INSTRUMENTATION_STATUS_CODE: 1', + 'INSTRUMENTATION_STATUS: test_skipped=true', + 'INSTRUMENTATION_STATUS_CODE: 0', + 'INSTRUMENTATION_STATUS: class=hello', + 'INSTRUMENTATION_STATUS: test=world', + 'INSTRUMENTATION_STATUS: stack=', + 'foo/bar.py (27)', + 'hello/world.py (42)', + 'test/file.py (1)', + 'INSTRUMENTATION_STATUS_CODE: -1', + ] + + _, _, statuses = ( + test_runner.TestRunner._ParseAmInstrumentRawOutput(raw_output)) + + expected = [ + (1, {'class': ['foo'], 'test': ['bar'],}), + (0, {'test_skipped': ['true']}), + (-1, { + 'class': ['hello'], + 'test': ['world'], + 'stack': ['', 'foo/bar.py (27)', 'hello/world.py (42)', + 'test/file.py (1)'], + }), + ] + self.assertEqual(expected, statuses) + + def testParseAmInstrumentRawOutput_statusResultAndCode(self): + raw_output = [ + 'INSTRUMENTATION_STATUS: class=foo', + 'INSTRUMENTATION_STATUS: test=bar', + 'INSTRUMENTATION_STATUS_CODE: 1', + 'INSTRUMENTATION_RESULT: hello', + 'world', + '', + '', + 'INSTRUMENTATION_CODE: 0', + ] + + code, result, statuses = ( + test_runner.TestRunner._ParseAmInstrumentRawOutput(raw_output)) + + self.assertEqual(0, code) + self.assertEqual(['hello', 'world', '', ''], result) + self.assertEqual([(1, {'class': ['foo'], 'test': ['bar']})], statuses) + + def testGenerateTestResult_noStatus(self): + result = self.instance._GenerateTestResult( + 'test.package.TestClass#testMethod', [], 0, 1000) + self.assertEqual('test.package.TestClass#testMethod', result.GetName()) + self.assertEqual(base_test_result.ResultType.UNKNOWN, result.GetType()) + self.assertEqual('', result.GetLog()) + self.assertEqual(1000, result.GetDur()) + + def testGenerateTestResult_testPassed(self): + statuses = [ + (1, { + 'class': ['test.package.TestClass'], + 'test': ['testMethod'], + }), + (0, { + 'class': ['test.package.TestClass'], + 'test': ['testMethod'], + }), + ] + result = self.instance._GenerateTestResult( + 'test.package.TestClass#testMethod', statuses, 0, 1000) + self.assertEqual(base_test_result.ResultType.PASS, result.GetType()) + + def testGenerateTestResult_testSkipped_first(self): + statuses = [ + (0, { + 'test_skipped': ['true'], + }), + (1, { + 'class': ['test.package.TestClass'], + 'test': ['testMethod'], + }), + (0, { + 'class': ['test.package.TestClass'], + 'test': ['testMethod'], + }), + ] + result = self.instance._GenerateTestResult( + 'test.package.TestClass#testMethod', statuses, 0, 1000) + self.assertEqual(base_test_result.ResultType.SKIP, result.GetType()) + + def testGenerateTestResult_testSkipped_last(self): + statuses = [ + (1, { + 'class': ['test.package.TestClass'], + 'test': ['testMethod'], + }), + (0, { + 'class': ['test.package.TestClass'], + 'test': ['testMethod'], + }), + (0, { + 'test_skipped': ['true'], + }), + ] + result = self.instance._GenerateTestResult( + 'test.package.TestClass#testMethod', statuses, 0, 1000) + self.assertEqual(base_test_result.ResultType.SKIP, result.GetType()) + + def testGenerateTestResult_testSkipped_false(self): + statuses = [ + (0, { + 'test_skipped': ['false'], + }), + (1, { + 'class': ['test.package.TestClass'], + 'test': ['testMethod'], + }), + (0, { + 'class': ['test.package.TestClass'], + 'test': ['testMethod'], + }), + ] + result = self.instance._GenerateTestResult( + 'test.package.TestClass#testMethod', statuses, 0, 1000) + self.assertEqual(base_test_result.ResultType.PASS, result.GetType()) + + def testGenerateTestResult_testFailed(self): + statuses = [ + (1, { + 'class': ['test.package.TestClass'], + 'test': ['testMethod'], + }), + (-2, { + 'class': ['test.package.TestClass'], + 'test': ['testMethod'], + }), + ] + result = self.instance._GenerateTestResult( + 'test.package.TestClass#testMethod', statuses, 0, 1000) + self.assertEqual(base_test_result.ResultType.FAIL, result.GetType()) + + def testGenerateTestResult_testCrashed(self): + self.instance.test_pkg.GetPackageName = mock.Mock( + return_value='generate.test.result.test.package') + self.instance.device.old_interface.DismissCrashDialogIfNeeded = mock.Mock( + return_value='generate.test.result.test.package') + statuses = [ + (1, { + 'class': ['test.package.TestClass'], + 'test': ['testMethod'], + }), + (-1, { + 'class': ['test.package.TestClass'], + 'test': ['testMethod'], + 'stack': ['', 'foo/bar.py (27)', 'hello/world.py (42)'], + }), + ] + result = self.instance._GenerateTestResult( + 'test.package.TestClass#testMethod', statuses, 0, 1000) + self.assertEqual(base_test_result.ResultType.CRASH, result.GetType()) + self.assertEqual('\nfoo/bar.py (27)\nhello/world.py (42)', result.GetLog()) + + def test_RunTest_verifyAdbShellCommand(self): + self.instance.options.test_runner = 'MyTestRunner' + self.instance.device.RunShellCommand = mock.Mock() + self.instance.test_pkg.GetPackageName = mock.Mock( + return_value='test.package') + self.instance._GetInstrumentationArgs = mock.Mock( + return_value={'test_arg_key': 'test_arg_value'}) + self.instance._RunTest('test.package.TestClass#testMethod', 100) + self.instance.device.RunShellCommand.assert_called_with( + ['am', 'instrument', '-r', + '-e', 'test_arg_key', "'test_arg_value'", + '-e', 'class', "'test.package.TestClass#testMethod'", + '-w', 'test.package/MyTestRunner'], + timeout=100, retries=0) + +if __name__ == '__main__': + unittest.main(verbosity=2) + diff --git a/build/android/pylib/junit/__init__.py b/build/android/pylib/junit/__init__.py new file mode 100644 index 0000000000..5cac026153 --- /dev/null +++ b/build/android/pylib/junit/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + diff --git a/build/android/pylib/junit/setup.py b/build/android/pylib/junit/setup.py new file mode 100644 index 0000000000..6ae000606c --- /dev/null +++ b/build/android/pylib/junit/setup.py @@ -0,0 +1,18 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +from pylib.junit import test_runner + +def Setup(options): + """Creates a test runner factory for junit tests. + + Return: + A (runner_factory, tests) tuple. + """ + + def TestRunnerFactory(_unused_device, _unused_shard_index): + return test_runner.JavaTestRunner(options) + + return (TestRunnerFactory, ['JUnit tests']) + diff --git a/build/android/pylib/junit/test_dispatcher.py b/build/android/pylib/junit/test_dispatcher.py new file mode 100644 index 0000000000..b821b75e73 --- /dev/null +++ b/build/android/pylib/junit/test_dispatcher.py @@ -0,0 +1,19 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +def RunTests(tests, runner_factory): + """Runs a set of java tests on the host. + + Return: + A tuple containing the results & the exit code. + """ + def run(t): + runner = runner_factory(None, None) + runner.SetUp() + result = runner.RunTest(t) + runner.TearDown() + return result == 0 + + return (None, 0 if all(run(t) for t in tests) else 1) + diff --git a/build/android/pylib/junit/test_runner.py b/build/android/pylib/junit/test_runner.py new file mode 100644 index 0000000000..d0803ea43e --- /dev/null +++ b/build/android/pylib/junit/test_runner.py @@ -0,0 +1,40 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import os + +from pylib import cmd_helper +from pylib import constants + +class JavaTestRunner(object): + """Runs java tests on the host.""" + + def __init__(self, options): + self._package_filter = options.package_filter + self._runner_filter = options.runner_filter + self._sdk_version = options.sdk_version + self._test_filter = options.test_filter + self._test_suite = options.test_suite + + def SetUp(self): + pass + + def RunTest(self, _test): + """Runs junit tests from |self._test_suite|.""" + command = ['java', + '-jar', os.path.join(constants.GetOutDirectory(), 'lib.java', + '%s.jar' % self._test_suite)] + if self._test_filter: + command.extend(['-gtest-filter', self._test_filter]) + if self._package_filter: + command.extend(['-package-filter', self._package_filter]) + if self._runner_filter: + command.extend(['-runner-filter', self._runner_filter]) + if self._sdk_version: + command.extend(['-sdk-version', self._sdk_version]) + return cmd_helper.RunCmd(command) + + def TearDown(self): + pass + diff --git a/build/android/pylib/perf/perf_control.py b/build/android/pylib/perf/perf_control.py index 70389071a6..d90edf45fc 100644 --- a/build/android/pylib/perf/perf_control.py +++ b/build/android/pylib/perf/perf_control.py @@ -68,15 +68,16 @@ class PerfControl(object): self._ForceAllCpusOnline(False) def _SetScalingGovernorInternal(self, value): - for cpu in range(self._num_cpu_cores): - scaling_governor_file = PerfControl._SCALING_GOVERNOR_FMT % cpu - if self._device.FileExists(scaling_governor_file): - logging.info('Writing scaling governor mode \'%s\' -> %s', - value, scaling_governor_file) - self._device.WriteFile(scaling_governor_file, value, as_root=True) + cpu_cores = ' '.join([str(x) for x in range(self._num_cpu_cores)]) + script = ('for CPU in %s; do\n' + ' FILE="/sys/devices/system/cpu/cpu$CPU/cpufreq/scaling_governor"\n' + ' test -e $FILE && echo %s > $FILE\n' + 'done\n') % (cpu_cores, value) + logging.info('Setting scaling governor mode: %s', value) + self._device.RunShellCommand(script, as_root=True) def _AllCpusAreOnline(self): - for cpu in range(self._num_cpu_cores): + for cpu in range(1, self._num_cpu_cores): online_path = PerfControl._CPU_ONLINE_FMT % cpu # TODO(epenner): Investigate why file may be missing # (http://crbug.com/397118) diff --git a/build/android/pylib/symbols/elf_symbolizer.py b/build/android/pylib/symbols/elf_symbolizer.py index 08c02d5a8a..374063a57f 100644 --- a/build/android/pylib/symbols/elf_symbolizer.py +++ b/build/android/pylib/symbols/elf_symbolizer.py @@ -13,6 +13,7 @@ import re import subprocess import sys import threading +import time # addr2line builds a possibly infinite memory cache that can exhaust @@ -184,12 +185,17 @@ class ELFSymbolizer(object): def _CreateDisambiguationTable(self): """ Non-unique file names will result in None entries""" + start_time = time.time() + logging.info('Collecting information about available source files...') self.disambiguation_table = {} for root, _, filenames in os.walk(self.source_root_path): for f in filenames: self.disambiguation_table[f] = os.path.join(root, f) if (f not in self.disambiguation_table) else None + logging.info('Finished collecting information about ' + 'possible files (took %.1f s).', + (time.time() - start_time)) class Addr2Line(object): diff --git a/build/android/pylib/uiautomator/test_runner.py b/build/android/pylib/uiautomator/test_runner.py index 794c313d43..fa0725d34a 100644 --- a/build/android/pylib/uiautomator/test_runner.py +++ b/build/android/pylib/uiautomator/test_runner.py @@ -74,5 +74,13 @@ class TestRunner(instr_test_runner.TestRunner): package=self._package), blocking=True, force_stop=True) - return self.device.old_interface.RunUIAutomatorTest( - test, self.test_pkg.GetPackageName(), timeout) + cmd = ['uiautomator', 'runtest', self.test_pkg.GetPackageName(), + '-e', 'class', test] + return self.device.RunShellCommand(cmd, timeout=timeout, retries=0) + + #override + def _GenerateTestResult(self, test, instr_statuses, start_ms, duration_ms): + # uiautomator emits its summary status with INSTRUMENTATION_STATUS_CODE, + # not INSTRUMENTATION_CODE, so we have to drop if off the list of statuses. + return super(TestRunner, self)._GenerateTestResult( + test, instr_statuses[:-1], start_ms, duration_ms) diff --git a/build/android/pylib/utils/findbugs.py b/build/android/pylib/utils/findbugs.py index 208b0cf45d..2f0fff91bb 100644 --- a/build/android/pylib/utils/findbugs.py +++ b/build/android/pylib/utils/findbugs.py @@ -70,7 +70,10 @@ def _GetChromeJars(release_version): version = 'Debug' if release_version: version = 'Release' - path = os.path.join(constants.DIR_SOURCE_ROOT, 'out', version, 'lib.java') + path = os.path.join(constants.DIR_SOURCE_ROOT, + os.environ.get('CHROMIUM_OUT_DIR', 'out'), + version, + 'lib.java') cmd = 'find %s -name "*.jar"' % path out = cmd_helper.GetCmdOutput(shlex.split(cmd)) out = [p for p in out.splitlines() if not p.endswith('.dex.jar')] diff --git a/build/android/test_runner.py b/build/android/test_runner.py index 8a4b9fa4c8..5303463874 100755 --- a/build/android/test_runner.py +++ b/build/android/test_runner.py @@ -28,6 +28,8 @@ from pylib.linker import setup as linker_setup from pylib.host_driven import setup as host_driven_setup from pylib.instrumentation import setup as instrumentation_setup from pylib.instrumentation import test_options as instrumentation_test_options +from pylib.junit import setup as junit_setup +from pylib.junit import test_dispatcher as junit_dispatcher from pylib.monkey import setup as monkey_setup from pylib.monkey import test_options as monkey_test_options from pylib.perf import setup as perf_setup @@ -175,21 +177,21 @@ def AddJavaTestOptions(option_parser): '-E', '--exclude-annotation', dest='exclude_annotation_str', help=('Comma-separated list of annotations. Exclude tests with these ' 'annotations.')) - option_parser.add_option('--screenshot', dest='screenshot_failures', - action='store_true', - help='Capture screenshots of test failures') - option_parser.add_option('--save-perf-json', action='store_true', - help='Saves the JSON file for each UI Perf test.') - option_parser.add_option('--official-build', action='store_true', - help='Run official build tests.') - option_parser.add_option('--test_data', action='append', default=[], - help=('Each instance defines a directory of test ' - 'data that should be copied to the target(s) ' - 'before running the tests. The argument ' - 'should be of the form <target>:<source>, ' - '<target> is relative to the device data' - 'directory, and <source> is relative to the ' - 'chromium build directory.')) + option_parser.add_option( + '--screenshot', dest='screenshot_failures', action='store_true', + help='Capture screenshots of test failures') + option_parser.add_option( + '--save-perf-json', action='store_true', + help='Saves the JSON file for each UI Perf test.') + option_parser.add_option( + '--official-build', action='store_true', help='Run official build tests.') + option_parser.add_option( + '--test_data', '--test-data', action='append', default=[], + help=('Each instance defines a directory of test data that should be ' + 'copied to the target(s) before running the tests. The argument ' + 'should be of the form <target>:<source>, <target> is relative to ' + 'the device data directory, and <source> is relative to the ' + 'chromium build directory.')) def ProcessJavaTestOptions(options): @@ -379,6 +381,36 @@ def ProcessUIAutomatorOptions(options, error_func): options.package) +def AddJUnitTestOptions(option_parser): + """Adds junit test options to |option_parser|.""" + option_parser.usage = '%prog junit -s [test suite name]' + option_parser.commands_dict = {} + + option_parser.add_option( + '-s', '--test-suite', dest='test_suite', + help=('JUnit test suite to run.')) + option_parser.add_option( + '-f', '--test-filter', dest='test_filter', + help='Filters tests googletest-style.') + option_parser.add_option( + '--package-filter', dest='package_filter', + help='Filters tests by package.') + option_parser.add_option( + '--runner-filter', dest='runner_filter', + help='Filters tests by runner class. Must be fully qualified.') + option_parser.add_option( + '--sdk-version', dest='sdk_version', type="int", + help='The Android SDK version.') + AddCommonOptions(option_parser) + + +def ProcessJUnitTestOptions(options, error_func): + """Processes all JUnit test options.""" + if not options.test_suite: + error_func('No test suite specified.') + return options + + def AddMonkeyTestOptions(option_parser): """Adds monkey test options to |option_parser|.""" @@ -635,6 +667,15 @@ def _RunUIAutomatorTests(options, error_func, devices): return exit_code +def _RunJUnitTests(options, error_func): + """Subcommand of RunTestsCommand which runs junit tests.""" + junit_options = ProcessJUnitTestOptions(options, error_func) + runner_factory, tests = junit_setup.Setup(junit_options) + _, exit_code = junit_dispatcher.RunTests(tests, runner_factory) + + return exit_code + + def _RunMonkeyTests(options, error_func, devices): """Subcommand of RunTestsCommands which runs monkey tests.""" monkey_options = ProcessMonkeyTestOptions(options, error_func) @@ -758,6 +799,8 @@ def RunTestsCommand(command, options, args, option_parser): return _RunInstrumentationTests(options, option_parser.error, devices) elif command == 'uiautomator': return _RunUIAutomatorTests(options, option_parser.error, devices) + elif command == 'junit': + return _RunJUnitTests(options, option_parser.error) elif command == 'monkey': return _RunMonkeyTests(options, option_parser.error, devices) elif command == 'perf': @@ -818,6 +861,8 @@ VALID_COMMANDS = { AddInstrumentationTestOptions, RunTestsCommand), 'uiautomator': CommandFunctionTuple( AddUIAutomatorTestOptions, RunTestsCommand), + 'junit': CommandFunctionTuple( + AddJUnitTestOptions, RunTestsCommand), 'monkey': CommandFunctionTuple( AddMonkeyTestOptions, RunTestsCommand), 'perf': CommandFunctionTuple( diff --git a/build/android/tests/multiple_proguards/multiple_proguards.gyp b/build/android/tests/multiple_proguards/multiple_proguards.gyp index 6e9c34cbc6..48a5d7ba8b 100644 --- a/build/android/tests/multiple_proguards/multiple_proguards.gyp +++ b/build/android/tests/multiple_proguards/multiple_proguards.gyp @@ -4,7 +4,6 @@ { 'variables': { 'chromium_code': 1, - 'package_name': 'multiple_proguard', }, 'targets': [ { @@ -15,6 +14,9 @@ 'java_in_dir': '.', 'proguard_enabled': 'true', 'proguard_flags_paths': [ + # Both these proguard?.flags files need to be part of the build to + # remove both warnings from the src/dummy/DummyActivity.java file, else the + # build will fail. 'proguard1.flags', 'proguard2.flags', ], @@ -23,12 +25,9 @@ 'apk_name': 'MultipleProguards', # This is a build-only test. There's nothing to install. 'gyp_managed_install': 0, + # The Java code produces warnings, so force the build to not show them. + 'chromium_code': 0, }, - 'dependencies': [ - # guava has references to objects using reflection which - # should be ignored in proguard step. - '../../../../third_party/guava/guava.gyp:guava_javalib', - ], 'includes': [ '../../../../build/java_apk.gypi' ], }, ], diff --git a/build/android/tests/multiple_proguards/proguard1.flags b/build/android/tests/multiple_proguards/proguard1.flags index 4539a7afcd..95a814cda6 100644 --- a/build/android/tests/multiple_proguards/proguard1.flags +++ b/build/android/tests/multiple_proguards/proguard1.flags @@ -1,2 +1 @@ -# src/third_party/guava/guava.gyp:guava_javalib -dontwarn sun.misc.Unsafe diff --git a/build/android/tests/multiple_proguards/proguard2.flags b/build/android/tests/multiple_proguards/proguard2.flags index 7da78c3654..ceac62b1c6 100644 --- a/build/android/tests/multiple_proguards/proguard2.flags +++ b/build/android/tests/multiple_proguards/proguard2.flags @@ -1,3 +1 @@ -# Striped64 uses reflection to access some local fields. --dontnote com.google.common.cache.Striped64 --dontnote com.google.common.cache.Striped64$Cell +-dontwarn sun.reflect.Reflection diff --git a/build/android/tests/multiple_proguards/src/dummy/DummyActivity.java b/build/android/tests/multiple_proguards/src/dummy/DummyActivity.java index 291a8100f3..72f20f4eba 100644 --- a/build/android/tests/multiple_proguards/src/dummy/DummyActivity.java +++ b/build/android/tests/multiple_proguards/src/dummy/DummyActivity.java @@ -1,14 +1,26 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package dummy; import android.app.Activity; -import android.os.Bundle; /** * Dummy activity to build apk. + * + * This class is created to ensure that proguard will produce two separate warnings. */ public class DummyActivity extends Activity { + private static void doBadThings1() { + try { + sun.misc.Unsafe.getUnsafe(); + } catch (Exception e) { + throw new Error(e); + } + } + + private static void doBadThings2() { + sun.reflect.Reflection.getCallerClass(2); + } } diff --git a/build/build_config.h b/build/build_config.h index b48db72743..553484605a 100644 --- a/build/build_config.h +++ b/build/build_config.h @@ -14,10 +14,6 @@ #ifndef BUILD_BUILD_CONFIG_H_ #define BUILD_BUILD_CONFIG_H_ -#if defined(__APPLE__) -#include <TargetConditionals.h> -#endif - // A set of macros to use for platform detection. #if defined(__native_client__) // __native_client__ must be first, so that other OS_ defines are not set. @@ -25,6 +21,10 @@ #elif defined(ANDROID) #define OS_ANDROID 1 #elif defined(__APPLE__) +// only include TargetConditions after testing ANDROID as some android builds +// on mac don't have this header available and it's not needed unless the target +// is really mac/ios. +#include <TargetConditionals.h> #define OS_MACOSX 1 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE #define OS_IOS 1 diff --git a/build/common.gypi b/build/common.gypi index a82d24dd22..dc0f525141 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -96,7 +96,7 @@ 'use_aura%': 1, }], - ['chromecast==1', { + ['chromecast==1 and OS!="android"', { 'embedded%': 1, 'use_ozone%': 1, }], @@ -176,6 +176,10 @@ # The system libdir used for this ABI. 'system_libdir%': 'lib', + # Default MIPS arch variant. This is set in the conditions block + # below for MIPS targets. + 'mips_arch_variant%': '', + 'conditions': [ # Ash needs Aura. ['use_aura==0', { @@ -201,6 +205,11 @@ 'enable_hidpi%': 1, }], + # Enable the OpenSSL backend on Mac OS. + ['OS=="mac"', { + 'use_openssl%': 1, + }], + # Enable App Launcher everywhere but mobile. ['OS!="ios" and OS!="android"', { 'enable_app_list%': 1, @@ -238,6 +247,21 @@ ['OS=="ios"', { 'target_subarch%': 'arm32', }], + + # Set arch variants for MIPS platforms. + ['target_arch=="mips64el"', { + 'conditions': [ + ['OS=="android"', { + 'mips_arch_variant%': 'r6', + }, { + 'mips_arch_variant%': 'r2', + }], + ], + }], + + ['target_arch=="mipsel"', { + 'mips_arch_variant%': 'r1', + }], ], }, @@ -247,6 +271,7 @@ 'host_arch%': '<(host_arch)', 'target_arch%': '<(target_arch)', 'target_subarch%': '<(target_subarch)', + 'mips_arch_variant%': '<(mips_arch_variant)', 'toolkit_views%': '<(toolkit_views)', 'desktop_linux%': '<(desktop_linux)', 'use_aura%': '<(use_aura)', @@ -317,7 +342,7 @@ 'component%': 'static_library', # Set to select the Title Case versions of strings in GRD files. - 'use_titlecase_in_grd_files%': 0, + 'use_titlecase_in_grd%': 0, # Use translations provided by volunteers at launchpad.net. This # currently only works on Linux. @@ -364,7 +389,7 @@ # Enable Chromium overrides of the default configurations for various # dynamic tools (like ASan). - 'use_sanitizer_options%': 1, + 'use_sanitizer_options%': 0, # Enable building with SyzyAsan. # See https://code.google.com/p/sawbuck/wiki/SyzyASanHowTo @@ -453,9 +478,6 @@ # print, UI, etc. 'enable_printing%': 1, - # Windows prints using a PDF as the metafile from the renderer. - 'win_pdf_metafile_for_printing%': 1, - # Set the version of CLD. # 0: Don't specify the version. This option is for the Finch testing. # 1: Use only CLD1. @@ -569,7 +591,7 @@ 'test_isolation_outdir%': '', # True if isolate should fail if the isolate files refer to files # that are missing. - 'test_isolation_fail_on_missing': 0, + 'test_isolation_fail_on_missing': 1, 'wix_path%': '<(DEPTH)/third_party/wix', @@ -584,6 +606,7 @@ 'data_reduction_fallback_host%' : '', 'data_reduction_dev_host%' : '', + 'data_reduction_dev_fallback_host%' : '', 'spdy_proxy_auth_origin%' : '', 'spdy_proxy_auth_property%' : '', 'spdy_proxy_auth_value%' : '', @@ -603,19 +626,22 @@ # Enable hole punching for the protected video. 'video_hole%': 0, + # Temporary hack to allow us to unify blink's definitions of load + # completion. blink uses a crazy set of constraints to determine load + # completion, but only actually requires them for layout tests. However, + # we need to maintain all the old behaviors while the plumbing is put in + # place on both sides of the repo boundary. + 'enable_load_completion_hacks%': 1, + # Automatically select platforms under ozone. Turn this off to # build only explicitly selected platforms. 'ozone_auto_platforms%': 1, + # If this is set clang is used as host compiler, but not as target + # compiler. Always do this by default. + 'host_clang%': 1, + 'conditions': [ - ['android_webview_build==0', { - # If this is set clang is used as host compiler, but not as target - # compiler. Always do this by default, except when building for AOSP. - 'host_clang%': 1, - }, { - # See http://crbug.com/377684 - 'host_clang%': 0, - }], # A flag for POSIX platforms ['OS=="win"', { 'os_posix%': 0, @@ -701,7 +727,7 @@ ['OS=="mac" or OS=="ios"', { # Mac and iOS want Title Case strings - 'use_titlecase_in_grd_files%': 1, + 'use_titlecase_in_grd%': 1, }], # Enable loader extensions on Chrome OS. @@ -778,6 +804,7 @@ 'safe_browsing%': 0, 'enable_managed_users%': 0, 'enable_task_manager%': 0, + 'use_system_libcxx%': 1, }], # Use GPU accelerated cross process image transport by default @@ -867,12 +894,6 @@ 'use_libjpeg_turbo%': 0, }], - ['OS=="android"', { - # When building as part of the Android system, use system libraries - # where possible to reduce ROM size. - 'use_system_libjpeg%': '<(android_webview_build)', - }], - # Do not enable the Settings App on ChromeOS. ['enable_app_list==1 and chromeos==0', { 'enable_settings_app%': 1, @@ -960,13 +981,15 @@ 'data_reduction_proxy_probe_url%': '', 'data_reduction_proxy_warmup_url%': '', 'data_reduction_dev_host%': '', + 'data_reduction_dev_fallback_host%': '', 'data_reduction_fallback_host%': '', }, { 'icu_use_data_file_flag%' : 0, 'spdy_proxy_auth_origin%': 'https://proxy.googlezip.net:443/', 'data_reduction_proxy_probe_url%': 'http://check.googlezip.net/connect', 'data_reduction_proxy_warmup_url%': 'http://www.gstatic.com/generate_204', - 'data_reduction_dev_host%': 'http://proxy-dev.googlezip.net:80/', + 'data_reduction_dev_host%': 'https://proxy-dev.googlezip.net:443/', + 'data_reduction_dev_fallback_host%': 'http://proxy-dev.googlezip.net:80/', 'data_reduction_fallback_host%': 'http://compress.googlezip.net:80/', }], ['OS=="win" or OS=="mac"', { @@ -980,6 +1003,13 @@ }, { 'sas_dll_path%': '<(DEPTH)/third_party/platformsdk_win7/files/redist/x86', }], + + # Turn on JNI generation optimizations on non-WebView builds. + ['OS=="android" and android_webview_build==0', { + 'optimize_jni_generation%': 1, + }, { + 'optimize_jni_generation%': 0, + }], ], # Set this to 1 to enable use of concatenated impulse responses @@ -1039,6 +1069,7 @@ 'buildtype%': '<(buildtype)', 'target_arch%': '<(target_arch)', 'target_subarch%': '<(target_subarch)', + 'mips_arch_variant%': '<(mips_arch_variant)', 'host_arch%': '<(host_arch)', 'toolkit_views%': '<(toolkit_views)', 'ui_compositor_image_transport%': '<(ui_compositor_image_transport)', @@ -1081,7 +1112,7 @@ 'system_libdir%': '<(system_libdir)', 'component%': '<(component)', 'enable_resource_whitelist_generation%': '<(enable_resource_whitelist_generation)', - 'use_titlecase_in_grd_files%': '<(use_titlecase_in_grd_files)', + 'use_titlecase_in_grd%': '<(use_titlecase_in_grd)', 'use_third_party_translations%': '<(use_third_party_translations)', 'remoting%': '<(remoting)', 'enable_one_click_signin%': '<(enable_one_click_signin)', @@ -1131,7 +1162,6 @@ 'test_isolation_outdir%': '<(test_isolation_outdir)', 'test_isolation_fail_on_missing': '<(test_isolation_fail_on_missing)', 'enable_printing%': '<(enable_printing)', - 'win_pdf_metafile_for_printing%': '<(win_pdf_metafile_for_printing)', 'enable_spellcheck%': '<(enable_spellcheck)', 'enable_google_now%': '<(enable_google_now)', 'cld_version%': '<(cld_version)', @@ -1162,6 +1192,7 @@ 'native_memory_pressure_signals%': '<(native_memory_pressure_signals)', 'data_reduction_fallback_host%': '<(data_reduction_fallback_host)', 'data_reduction_dev_host%': '<(data_reduction_dev_host)', + 'data_reduction_dev_fallback_host%': '<(data_reduction_dev_fallback_host)', 'spdy_proxy_auth_origin%': '<(spdy_proxy_auth_origin)', 'spdy_proxy_auth_property%': '<(spdy_proxy_auth_property)', 'spdy_proxy_auth_value%': '<(spdy_proxy_auth_value)', @@ -1179,6 +1210,10 @@ 'use_goma%': '<(use_goma)', 'gomadir%': '<(gomadir)', 'video_hole%': '<(video_hole)', + 'enable_load_completion_hacks%': '<(enable_load_completion_hacks)', + + # Whether or not we are building the Athena shell. + 'use_athena%': '0', # Use system protobuf instead of bundled one. 'use_system_protobuf%': 0, @@ -1319,9 +1354,6 @@ # Set to 1 to link against gsettings APIs instead of using dlopen(). 'linux_link_gsettings%': 0, - # Default arch variant for MIPS. - 'mips_arch_variant%': 'mips32r1', - # Enable use of OpenMAX DL FFT routines. 'use_openmax_dl_fft%': '<(use_openmax_dl_fft)', @@ -1469,17 +1501,7 @@ # chrome/third_party/chromevox. This is still experimental. 'use_migrated_chromevox%': 1, - # Chrome OS: whether to also build the upcoming version of - # ChromeVox, which can then be enabled via a command-line switch. - 'use_chromevox_next%': 0, - 'conditions': [ - # The version of clang shipped upstream does not find C++ headers when - # using -stdlib=libc++ so we instead need to use the version of clang - # coming with Xcode. - ['OS=="ios" and use_system_libcxx==1', { - 'clang_xcode%': 1, - }], # Enable the Syzygy optimization step for the official builds. ['OS=="win" and buildtype=="Official" and syzyasan!=1', { 'syzygy_optimize%': 1, @@ -1522,24 +1544,20 @@ # it takes effect here. ['os_posix==1 and OS!="mac" and OS!="ios" and clang==0 and asan==0 and lsan==0 and tsan==0 and msan==0 and ubsan_vptr==0', { 'conditions': [ - ['OS=="android"', { - # We directly set the gcc versions since we know what we use. + ['OS=="android" and android_webview_build==0', { + 'host_gcc_version%': '<!pymod_do_main(compiler_version host compiler)', + # We directly set the gcc version since we know what we use. + 'gcc_version%': 49, + }], + ['OS=="android" and android_webview_build==1', { + # Android WebView uses a hermetic clang toolchain for host builds. + 'host_gcc_version%': 0, + # Android WebView uses the GCC toolchain from the Android build. 'gcc_version%': 48, - }, { - 'gcc_version%': '<!pymod_do_main(compiler_version target compiler)', }], - ['android_webview_build==1', { - # Android WebView uses a hermetic toolchain even for host, so set it - # manually here. - 'conditions': [ - ['host_os=="mac"', { - 'host_gcc_version%': 42, - }, { # linux - 'host_gcc_version%': 46, - }], - ], - }, { # android_webview_build!=1 + ['OS!="android"', { 'host_gcc_version%': '<!pymod_do_main(compiler_version host compiler)', + 'gcc_version%': '<!pymod_do_main(compiler_version target compiler)', }], ], }, { @@ -1561,7 +1579,7 @@ }], ['os_posix==1 and OS!="mac" and OS!="ios"', { 'conditions': [ - ['target_arch=="mipsel"', { + ['target_arch=="mipsel" or target_arch=="mips64el"', { 'werror%': '', 'disable_nacl%': 1, 'nacl_untrusted_build%': 0, @@ -1670,7 +1688,7 @@ 'android_gdbserver%': '<(android_ndk_root)/prebuilt/android-x86/gdbserver/gdbserver', 'android_ndk_sysroot%': '<(android_ndk_root)/platforms/android-14/arch-x86', 'android_ndk_lib_dir%': 'usr/lib', - 'android_toolchain%': '<(android_ndk_root)/toolchains/x86-4.8/prebuilt/<(host_os)-<(android_host_arch)/bin', + 'android_toolchain%': '<(android_ndk_root)/toolchains/x86-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin', }], ['target_arch == "x64"', { 'android_app_abi%': 'x86_64', @@ -1690,7 +1708,7 @@ 'android_gdbserver%': '<(android_ndk_root)/prebuilt/android-arm/gdbserver/gdbserver', 'android_ndk_sysroot%': '<(android_ndk_root)/platforms/android-14/arch-arm', 'android_ndk_lib_dir%': 'usr/lib', - 'android_toolchain%': '<(android_ndk_root)/toolchains/arm-linux-androideabi-4.8/prebuilt/<(host_os)-<(android_host_arch)/bin', + 'android_toolchain%': '<(android_ndk_root)/toolchains/arm-linux-androideabi-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin', }], ['target_arch == "arm64"', { 'android_app_abi%': 'arm64-v8a', @@ -1704,7 +1722,15 @@ 'android_gdbserver%': '<(android_ndk_root)/prebuilt/android-mips/gdbserver/gdbserver', 'android_ndk_sysroot%': '<(android_ndk_root)/platforms/android-14/arch-mips', 'android_ndk_lib_dir%': 'usr/lib', - 'android_toolchain%': '<(android_ndk_root)/toolchains/mipsel-linux-android-4.8/prebuilt/<(host_os)-<(android_host_arch)/bin', + 'android_toolchain%': '<(android_ndk_root)/toolchains/mipsel-linux-android-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin', + }], + ['target_arch == "mips64el"', { + 'android_app_abi%': 'mips64', + 'android_gdbserver%': '<(android_ndk_root)/prebuilt/android-mips64/gdbserver/gdbserver', + 'android_ndk_sysroot%': '<(android_ndk_root)/platforms/android-L/arch-mips64', + 'android_ndk_lib_dir%': 'usr/lib64', + 'android_toolchain%': '<(android_ndk_root)/toolchains/mips64el-linux-android-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin', + 'gcc_version%': 49, }], ], }, @@ -1741,7 +1767,7 @@ # breaking assumptions in the build system that when inputs have changed # the outputs should always change as well. This is meant purely for # developer builds, to avoid spurious re-linking of native files. - 'optimize_jni_generation%': 0, + 'optimize_jni_generation%': '<(optimize_jni_generation)', # Always uses openssl. 'use_openssl%': 1, @@ -1772,9 +1798,6 @@ # When building as part of the Android system, use system libraries # where possible to reduce ROM size. - # TODO(steveblock): Investigate using the system version of sqlite. - 'use_system_sqlite%': 0, # '<(android_webview_build)', - 'use_system_expat%': '<(android_webview_build)', 'use_system_icu%': '<(android_webview_build)', 'use_system_stlport%': '<(android_webview_build)', @@ -1793,6 +1816,7 @@ 'enable_mpeg2ts_stream_parser%': 1, 'ffmpeg_branding%': 'Chrome', 'ozone_platform_ozonex%': 1, + 'use_playready%': 0, 'conditions': [ ['target_arch=="arm"', { 'arm_arch%': '', @@ -1802,7 +1826,7 @@ }], ], }], - ['android_webview_build==1 or android_webview_telemetry_build==1', { + ['android_webview_build==1', { # When building the WebView in the Android tree, jarjar will remap all # the class names, so the JNI generator needs to know this. 'jni_generator_jarjar_file': '../android_webview/build/jarjar-rules.txt', @@ -1952,8 +1976,8 @@ }], # Native Client glibc toolchain is enabled - # by default except on arm and mips. - ['target_arch=="arm" or target_arch=="mipsel"', { + # by default except on arm, mips and mips64. + ['target_arch=="arm" or target_arch=="mipsel" or target_arch=="mips64el"', { 'disable_glibc%': 1, }, { 'disable_glibc%': 0, @@ -2015,7 +2039,7 @@ ['remoting==1', { 'grit_defines': ['-D', 'remoting'], }], - ['use_titlecase_in_grd_files==1', { + ['use_titlecase_in_grd==1', { 'grit_defines': ['-D', 'use_titlecase'], }], ['use_third_party_translations==1', { @@ -2112,6 +2136,7 @@ ['asan==1 or msan==1 or lsan==1 or tsan==1', { 'clang%': 1, 'use_allocator%': 'none', + 'use_sanitizer_options%': 1, }], ['asan==1 and OS=="linux" and chromeos==0', { 'use_custom_libcxx%': 1, @@ -2279,7 +2304,7 @@ 'chromium_win_pch': 0, # goma doesn't support PDB yet, so win_z7=1 or fastbuild=1. 'conditions': [ - ['win_z7==0', { + ['win_z7==0 and fastbuild==0', { 'fastbuild': 1, }], ], @@ -2297,13 +2322,14 @@ 'host_cxx': '<!(which g++)', }], - # The seccomp-bpf sandbox is only supported on four architectures + # The seccomp-bpf sandbox is only supported on five architectures # currently. # Do not disable seccomp_bpf anywhere without talking to # security@chromium.org! ['((OS=="linux" or OS=="android") and ' '(target_arch=="ia32" or target_arch=="x64" or ' - 'target_arch=="arm" or target_arch=="mipsel"))', { + 'target_arch=="arm" or target_arch=="mipsel" or ' + 'target_arch=="arm64"))', { 'use_seccomp_bpf%': 1, }, { 'use_seccomp_bpf%': 0, @@ -2313,6 +2339,12 @@ # The path to the ANGLE library. 'angle_path': '<(DEPTH)/third_party/angle', + # TODO(jmadill): remove angle_gyp. http://crbug.com/415983 + # This temporary variable lets us change the name of the gyp file + # in blink and in chromium simultaneously. It should go away after + # we're done changing the path. + 'angle_gyp': 'build_angle.gyp', + # List of default apps to install in new profiles. The first list contains # the source files as found in svn. The second list, used only for linux, # contains the destination location for each of the files. When a crx @@ -2337,6 +2369,9 @@ # Whether to allow building of the GPU-related isolates. 'archive_gpu_tests%': 0, + + # Whether to allow building of chromoting related isolates. + 'archive_chromoting_tests%': 0, }, 'target_defaults': { 'variables': { @@ -2469,6 +2504,9 @@ # code generated by flex (used in angle) contains that keyword. # http://crbug.com/255186 '-Wno-deprecated-register', + + # TODO(hans): Clean this up. Or disable with finer granularity. + '-Wno-unused-local-typedef', ], }, 'includes': [ 'set_clang_warning_flags.gypi', ], @@ -2485,6 +2523,11 @@ '<(DEPTH)/build/mac/asan.gyp:asan_dynamic_runtime', ], }], + ['OS=="win" and asan==1 and component=="shared_library"', { + 'dependencies': [ + '<(DEPTH)/build/win/asan.gyp:asan_dynamic_runtime', + ], + }], ['OS=="linux" and use_allocator!="none" and clang_type_profiler==1', { 'cflags_cc!': ['-fno-rtti'], 'cflags_cc+': [ @@ -2589,6 +2632,11 @@ }], ['proprietary_codecs==1', { 'defines': ['USE_PROPRIETARY_CODECS'], + 'conditions': [ + ['enable_mpeg2ts_stream_parser==1', { + 'defines': ['ENABLE_MPEG2TS_STREAM_PARSER'], + }], + ], }], ['enable_viewport==1', { 'defines': ['ENABLE_VIEWPORT'], @@ -2778,6 +2826,11 @@ '__SOFTFP', ], }], + ['use_playready==1', { + 'defines': [ + 'PLAYREADY_CDM_AVAILABLE', + ], + }], ], }], ['enable_task_manager==1', { @@ -2834,9 +2887,6 @@ ['enable_printing==2', { 'defines': ['ENABLE_PRINTING=1'], }], - ['OS=="win" and win_pdf_metafile_for_printing==1', { - 'defines': ['WIN_PDF_METAFILE_FOR_PRINTING=1'], - }], ['enable_spellcheck==1', { 'defines': ['ENABLE_SPELLCHECK=1'], }], @@ -2869,6 +2919,10 @@ 'defines': [ 'DATA_REDUCTION_DEV_HOST="<(data_reduction_dev_host)"'], }], + ['data_reduction_dev_fallback_host != ""', { + 'defines': [ + 'DATA_REDUCTION_DEV_FALLBACK_HOST="<(data_reduction_dev_fallback_host)"'], + }], ['spdy_proxy_auth_origin != ""', { 'defines': ['SPDY_PROXY_AUTH_ORIGIN="<(spdy_proxy_auth_origin)"'], }], @@ -2916,6 +2970,9 @@ ['video_hole==1', { 'defines': ['VIDEO_HOLE=1'], }], + ['enable_load_completion_hacks==1', { + 'defines': ['ENABLE_LOAD_COMPLETION_HACKS=1'], + }], ], # conditions for 'target_defaults' 'target_conditions': [ ['<(use_openssl)==1', { @@ -3004,14 +3061,15 @@ 'VCCLCompilerTool': { 'WarnAsError': 'false' }, } }], + [ 'component=="shared_library"', { + # TODO(darin): Unfortunately, some third_party code depends on base. + 'msvs_disabled_warnings': [ + 4251, # class 'std::xx' needs to have dll-interface. + ], + }], ], }], - # TODO(darin): Unfortunately, some third_party code depends on base. - [ 'OS=="win" and component=="shared_library"', { - 'msvs_disabled_warnings': [ - 4251, # class 'std::xx' needs to have dll-interface. - ], - }], + [ 'OS=="mac" or OS=="ios"', { 'xcode_settings': { 'WARNING_CFLAGS!': ['-Wall', '-Wextra'], @@ -3304,6 +3362,7 @@ ], 'AdditionalOptions': [ '/d2Zi+', # Improve debugging of Release builds. + '/Zc:inline', # Remove unreferenced COMDAT (faster links). '<@(win_release_extra_cflags)', ], }, @@ -3427,6 +3486,14 @@ '-Wl,-z,now', '-Wl,-z,relro', ], + # TODO(glider): enable the default options on other systems. + 'conditions': [ + ['use_sanitizer_options==1 and ((OS=="linux" and (chromeos==0 or target_arch!="ia32")) or OS=="mac")', { + 'dependencies': [ + '<(DEPTH)/build/sanitizers/sanitizers.gyp:sanitizer_options', + ], + }], + ], }, }], # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580 @@ -3464,7 +3531,6 @@ 'cflags': [ '<(werror)', # See note above about the werror variable. '-pthread', - '-fno-exceptions', '-fno-strict-aliasing', # See http://crbug.com/32204 '-Wall', # TODO(evan): turn this back on once all the builds work. @@ -3479,6 +3545,7 @@ '-pipe', ], 'cflags_cc': [ + '-fno-exceptions', '-fno-rtti', '-fno-threadsafe-statics', # Make inline functions have hidden visiblity by default. @@ -3505,6 +3572,7 @@ 'cflags': [ '-O>(debug_optimize)', '-g', + '-gdwarf-4', ], 'conditions' : [ ['OS=="android"', { @@ -3608,14 +3676,6 @@ '-Wl,--warn-shared-textrel', ], }], - ['clang==1', { - 'cflags!': [ - '-fno-ident', - ], - # TODO(thakis): Remove once http://llvm.org/PR20354 is fixed - # and the fix is in chromium. - 'cflags': [ '-fno-slp-vectorize', ], - }], ['profiling==1', { 'cflags': [ '-fno-omit-frame-pointer', @@ -3779,14 +3839,14 @@ }], ['arm_thumb==1', { 'cflags': [ - '-mthumb', - ] + '-mthumb', + ], }], ['OS=="android"', { # Most of the following flags are derived from what Android # uses by default when building for arm, reference for which # can be found in the following file in the Android NDK: - # toolchains/arm-linux-androideabi-4.8/setup.mk + # toolchains/arm-linux-androideabi-4.9/setup.mk 'cflags': [ # The tree-sra optimization (scalar replacement for # aggregates enabling subsequent optimizations) leads to @@ -3794,14 +3854,8 @@ # compiler (r5-r7). This can be verified using # webkit_unit_tests' WTF.Checked_int8_t test. '-fno-tree-sra', - # The following 6 options are disabled to save on - # binary size in gcc 4.8. - # TODO(fdegans) Reevaluate when we upgrade GCC. - '-fno-partial-inlining', - '-fno-early-inlining', - '-fno-tree-copy-prop', - '-fno-tree-loop-optimize', - '-fno-move-loop-invariants', + # The following option is disabled to improve binary + # size and performance in gcc 4.9. '-fno-caller-saves', '-Wno-psabi', ], @@ -3815,6 +3869,17 @@ '-fuse-ld=gold', ], 'conditions': [ + ['gcc_version==48 and clang==0', { + 'cflags': [ + # The following 5 options are disabled to save on + # binary size in GCC 4.8. + '-fno-partial-inlining', + '-fno-early-inlining', + '-fno-tree-copy-prop', + '-fno-tree-loop-optimize', + '-fno-move-loop-invariants', + ], + }], ['arm_thumb==1', { 'cflags': [ '-mthumb-interwork' ], }], @@ -3838,11 +3903,6 @@ '-mthumb-interwork', '-finline-limit=64', '-fno-tree-sra', - '-fno-partial-inlining', - '-fno-early-inlining', - '-fno-tree-copy-prop', - '-fno-tree-loop-optimize', - '-fno-move-loop-invariants', '-fno-caller-saves', '-Wno-psabi', ], @@ -3911,19 +3971,22 @@ 'target_conditions': [ ['_toolset=="target"', { 'conditions': [ - ['android_webview_build==0 and mips_arch_variant=="mips32r2"', { + ['android_webview_build==0 and mips_arch_variant=="r6"', { + 'cflags': ['-mips32r6', '-Wa,-mips32r6'], + 'conditions': [ + ['OS=="android"', { + 'ldflags': ['-mips32r6', '-Wl,-melf32ltsmip',], + }], + ], + }], + ['android_webview_build==0 and mips_arch_variant=="r2"', { 'cflags': ['-mips32r2', '-Wa,-mips32r2'], }], - ['android_webview_build==0 and mips_arch_variant!="mips32r2"', { + ['android_webview_build==0 and mips_arch_variant=="r1"', { 'cflags': ['-mips32', '-Wa,-mips32'], }], ], - 'cflags': [ - '-EL', - '-mhard-float', - ], 'ldflags': [ - '-EL', '-Wl,--no-keep-memory' ], 'cflags_cc': [ @@ -3932,6 +3995,25 @@ }], ], }], + ['target_arch=="mips64el"', { + 'target_conditions': [ + ['_toolset=="target"', { + 'conditions': [ + ['android_webview_build==0 and mips_arch_variant=="r6"', { + 'cflags': ['-mips64r6', '-Wa,-mips64r6'], + 'ldflags': [ '-mips64r6' ], + }], + ['android_webview_build==0 and mips_arch_variant=="r2"', { + 'cflags': ['-mips64r2', '-Wa,-mips64r2'], + 'ldflags': [ '-mips64r2' ], + }], + ], + 'cflags_cc': [ + '-Wno-uninitialized', + ], + }], + ], + }], ['linux_fpic==1', { 'cflags': [ '-fPIC', @@ -4028,14 +4110,6 @@ ], }], ], - # TODO(glider): enable the default options on other systems. - 'conditions': [ - ['use_sanitizer_options==1 and OS=="linux" and (chromeos==0 or target_arch!="ia32")', { - 'dependencies': [ - '<(DEPTH)/build/sanitizers/sanitizers.gyp:sanitizer_options', - ], - }], - ], }], ['asan==1', { 'target_conditions': [ @@ -4247,12 +4321,7 @@ 'target_conditions': [ ['_toolset=="target"', { 'ldflags': [ - # There seems to be a conflict of --icf and -pie - # in gold which can generate crashy binaries. As - # a security measure, -pie takes precedence for - # now. - #'-Wl,--icf=safe', - '-Wl,--icf=none', + '-Wl,--icf=safe', ], }], ], @@ -4727,12 +4796,6 @@ # cfe-dev discussion. '-Wno-selector-type-mismatch', ], - 'OTHER_CFLAGS': [ - # TODO(thakis): Remove once http://llvm.org/PR20354 is fixed - # and the fix is in chromium. - '-fno-slp-vectorize', - ], - 'conditions': [ ['clang_xcode==0', { 'CC': '$(SOURCE_ROOT)/<(clang_dir)/clang', @@ -5242,6 +5305,11 @@ 4702 ], 'msvs_settings': { + 'VCCLCompilerTool': { + 'AdditionalOptions!': [ + '/Zc:inline', # Not supported on non-updated Express. + ], + }, 'VCLinkerTool': { # Explicitly required when using the ATL with express 'AdditionalDependencies': ['atlthunk.lib'], @@ -5448,7 +5516,7 @@ '-Wno-unused-private-field', '-Wno-unused-value', '-Wno-unused-variable', - '-ferror-limit=1', + '-Wno-unused-local-typedef', # http://crbug.com/411648 ], }, }], @@ -5474,14 +5542,22 @@ ], }, 'target_conditions': [ - ['_type=="executable"', { + ['component=="shared_library"', { + 'VCLinkerTool': { + 'AdditionalDependencies': [ + 'clang_rt.asan_dynamic-i386.lib', + 'clang_rt.asan_dynamic_runtime_thunk-i386.lib', + ], + }, + }], + ['_type=="executable" and component=="static_library"', { 'VCLinkerTool': { 'AdditionalDependencies': [ 'clang_rt.asan-i386.lib', ], }, }], - ['_type=="shared_library" or _type=="loadable_module"', { + ['(_type=="shared_library" or _type=="loadable_module") and component=="static_library"', { 'VCLinkerTool': { 'AdditionalDependencies': [ 'clang_rt.asan_dll_thunk-i386.lib', @@ -5556,7 +5632,7 @@ }, }], # Don't warn about the "typedef 'foo' locally defined but not used" - # for gcc 4.8. + # for gcc 4.8 and higher. # TODO: remove this flag once all builds work. See crbug.com/227506 ['gcc_version>=48 and clang==0', { 'target_defaults': { diff --git a/build/common_untrusted.gypi b/build/common_untrusted.gypi index 086264e032..bcc368646b 100644 --- a/build/common_untrusted.gypi +++ b/build/common_untrusted.gypi @@ -10,6 +10,17 @@ ], 'target_defaults': { 'conditions': [ + # TODO(bradnelson): Drop this once the nacl side does the same. + ['target_arch=="x64"', { + 'variables': { + 'enable_x86_32': 0, + }, + }], + ['target_arch=="ia32" and OS!="win"', { + 'variables': { + 'enable_x86_64': 0, + }, + }], ['target_arch=="arm"', { 'variables': { 'clang': 1, @@ -26,4 +37,4 @@ }], ], }, -}
\ No newline at end of file +} diff --git a/build/compiled_action.gni b/build/compiled_action.gni index 937069113f..b750af0320 100644 --- a/build/compiled_action.gni +++ b/build/compiled_action.gni @@ -23,8 +23,12 @@ # args (required) # [list of strings] Same meaning as action/action_foreach. # +# inputs (optional) +# Files the binary takes as input. The step will be re-run whenever any +# of these change. If inputs is empty, the step will run only when the +# binary itself changes. +# # visibility -# inputs # deps # args (all optional) # Same meaning as action/action_foreach. @@ -62,11 +66,20 @@ # saves unnecessarily compiling your tool for the target platform. But if you # need a target build of your tool as well, just leave off the if statement. +if (build_os == "win") { + _host_executable_suffix = ".exe" +} else { + _host_executable_suffix = "" +} + template("compiled_action") { assert(defined(invoker.tool), "tool must be defined for $target_name") assert(defined(invoker.outputs), "outputs must be defined for $target_name") assert(defined(invoker.args), "args must be defined for $target_name") + assert(!defined(invoker.sources), + "compiled_action doesn't take a sources arg. Use inputs instead.") + action(target_name) { if (defined(invoker.visibility)) { visibility = invoker.visibility @@ -76,6 +89,8 @@ template("compiled_action") { if (defined(invoker.inputs)) { inputs = invoker.inputs + } else { + inputs = [] } outputs = invoker.outputs @@ -88,7 +103,10 @@ template("compiled_action") { # specify this, since we can't know what the output name is (it might be in # another file not processed yet). host_executable = get_label_info(host_tool, "root_out_dir") + "/" + - get_label_info(host_tool, "name") + get_label_info(host_tool, "name") + _host_executable_suffix + + # Add the executable itself as an input. + inputs += [ host_executable ] deps = [ host_tool ] if (defined(invoker.deps)) { @@ -120,6 +138,8 @@ template("compiled_action_foreach") { if (defined(invoker.inputs)) { inputs = invoker.inputs + } else { + inputs = [] } outputs = invoker.outputs @@ -132,7 +152,10 @@ template("compiled_action_foreach") { # specify this, since we can't know what the output name is (it might be in # another file not processed yet). host_executable = get_label_info(host_tool, "root_out_dir") + "/" + - get_label_info(host_tool, "name") + get_label_info(host_tool, "name") + _host_executable_suffix + + # Add the executable itself as an input. + inputs += [ host_executable ] deps = [ host_tool ] if (defined(invoker.deps)) { diff --git a/build/config/BUILD.gn b/build/config/BUILD.gn index b0daaf1dd3..45b61cf024 100644 --- a/build/config/BUILD.gn +++ b/build/config/BUILD.gn @@ -31,7 +31,6 @@ config("feature_flags") { # TODO(brettw) most of these need to be parameterized. defines = [ "CHROMIUM_BUILD", - "ENABLE_NOTIFICATIONS", "ENABLE_EGLIMAGE=1", "ENABLE_BACKGROUND=1", "V8_DEPRECATION_WARNINGS", # Don't use deprecated V8 APIs anywhere. @@ -43,10 +42,17 @@ config("feature_flags") { if (enable_mdns) { defines += [ "ENABLE_MDNS=1" ] } + if (enable_notifications) { + defines += [ "ENABLE_NOTIFICATIONS" ] + } if (enable_pepper_cdms) { # TODO(brettw) should probably be "=1" defines += [ "ENABLE_PEPPER_CDMS" ] } + if (enable_browser_cdms) { + # TODO(brettw) should probably be "=1" + defines += [ "ENABLE_BROWSER_CDMS" ] + } if (enable_plugins) { defines += [ "ENABLE_PLUGINS=1" ] } @@ -135,9 +141,6 @@ config("feature_flags") { if (enable_themes) { defines += [ "ENABLE_THEMES=1" ] } - if (is_win && win_pdf_metafile_for_printing) { - defines += [ "WIN_PDF_METAFILE_FOR_PRINTING=1" ] - } if (enable_captive_portal_detection) { defines += [ "ENABLE_CAPTIVE_PORTAL_DETECTION=1" ] } @@ -180,6 +183,12 @@ config("feature_flags") { if (enable_one_click_signin) { defines += [ "ENABLE_ONE_CLICK_SIGNIN" ] } + if (use_athena) { + defines += [ "USE_ATHENA=1" ] + } + if (enable_hidpi) { + defines += [ "ENABLE_HIDPI=1" ] + } } # Debug/release ---------------------------------------------------------------- @@ -207,6 +216,9 @@ config("debug") { } config("release") { + defines = [ + "NDEBUG", + ] } # Default libraries ------------------------------------------------------------ diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index dfa9c3bbb1..7994dd77f7 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -22,7 +22,8 @@ declare_args() { # 2 means regular build with symbols. # 1 means minimal symbols, usually enough for backtraces only. # 0 means no symbols. - symbol_level = 2 + # -1 means auto-set (off in release, regular in debug). + symbol_level = -1 # Component build. is_component_build = false @@ -63,6 +64,13 @@ declare_args() { # Compile for Thread Sanitizer to find threading bugs. is_tsan = false + + if (os == "chromeos") { + # Allows the target toolchain to be injected as arguments. This is needed + # to support the CrOS build system which supports per-build-configuration + # toolchains. + cros_use_custom_toolchain = false + } } # ============================================================================= @@ -283,12 +291,6 @@ set_sources_assignment_filter(sources_assignment_filter) # BUILD OPTIONS # ============================================================================= -if (is_component_build) { - component_mode = "shared_library" -} else { - component_mode = "source_set" -} - # These Sanitizers all imply using the Clang compiler. On Windows they either # don't work or work differently. if (!is_clang && (is_asan || is_lsan || is_tsan || is_msan)) { @@ -323,6 +325,7 @@ if (is_win) { "//build/config/win:nominmax", "//build/config/win:sdk", "//build/config/win:unicode", + "//build/config/win:winver", ] } if (is_posix) { @@ -359,14 +362,19 @@ if (is_debug) { } _native_compiler_configs += [ _default_optimization_config ] +# If it wasn't manually set, set to an appropriate default. +if (symbol_level == -1) { + # Linux is slowed by having symbols as part of the target binary, whereas + # Mac and Windows have them separate, so in Release Linux, default them off. + if (is_debug || !is_linux) { + symbol_level = 2 + } else { + symbol_level = 0 + } +} + # Symbol setup. -if (is_clang && (is_linux || is_android)) { - # Clang creates chubby debug information, which makes linking very slow. - # For now, don't create debug information with clang. - # See http://crbug.com/70000 - # TODO(brettw) This just copies GYP. Why not do this on Mac as well? - _default_symbols_config = "//build/config/compiler:no_symbols" -} else if (symbol_level == 2) { +if (symbol_level == 2) { _default_symbols_config = "//build/config/compiler:symbols" } else if (symbol_level == 1) { _default_symbols_config = "//build/config/compiler:minimal_symbols" @@ -396,39 +404,65 @@ if (is_win) { ] } +# Executable defaults. +_executable_configs = _native_compiler_configs + [ + "//build/config:default_libs", +] +if (is_win) { + _executable_configs += _windows_linker_configs +} else if (is_mac) { + _executable_configs += [ + "//build/config/mac:mac_dynamic_flags", + "//build/config/mac:mac_executable_flags" ] +} else if (is_linux || is_android) { + _executable_configs += [ "//build/config/gcc:executable_ldconfig" ] +} set_defaults("executable") { - configs = _native_compiler_configs + [ - "//build/config:default_libs", - ] - if (is_win) { - configs += _windows_linker_configs - } else if (is_mac) { - configs += [ - "//build/config/mac:mac_dynamic_flags", - "//build/config/mac:mac_executable_flags" ] - } else if (is_linux || is_android) { - configs += [ "//build/config/gcc:executable_ldconfig" ] - } + configs = _executable_configs } +# Static library defaults. set_defaults("static_library") { configs = _native_compiler_configs } +# Shared library defaults (also for components in component mode). +_shared_library_configs = _native_compiler_configs + [ + "//build/config:default_libs", +] +if (is_win) { + _shared_library_configs += _windows_linker_configs +} else if (is_mac) { + _shared_library_configs += [ "//build/config/mac:mac_dynamic_flags" ] +} set_defaults("shared_library") { - configs = _native_compiler_configs + [ - "//build/config:default_libs", - ] - if (is_win) { - configs += _windows_linker_configs - } else if (is_mac) { - configs += [ "//build/config/mac:mac_dynamic_flags" ] + configs = _shared_library_configs +} +if (is_component_build) { + set_defaults("component") { + configs = _shared_library_configs } } +# Source set defaults (also for components in non-component mode). set_defaults("source_set") { configs = _native_compiler_configs } +if (!is_component_build) { + set_defaults("component") { + configs = _native_compiler_configs + } +} + +# Test defaults. +set_defaults("test") { + if (is_android) { + configs = _shared_library_configs + } else { + configs = _executable_configs + } +} + # ============================================================================== # TOOLCHAIN SETUP @@ -469,6 +503,9 @@ if (is_win) { host_toolchain = "//build/toolchain/linux:$build_cpu_arch" set_default_toolchain("//build/toolchain/linux:$cpu_arch") } + if (is_chromeos && cros_use_custom_toolchain) { + set_default_toolchain("//build/toolchain/cros:target") + } } else if (is_mac) { host_toolchain = "//build/toolchain/mac:clang" set_default_toolchain(host_toolchain) @@ -476,3 +513,180 @@ if (is_win) { host_toolchain = "//build/toolchain/mac:host_clang" set_default_toolchain("//build/toolchain/mac:clang") } + +# ============================================================================== +# COMPONENT SETUP +# ============================================================================== + +# TODO(brettw) erase this once the built-in "component" function is removed. +if (is_component_build) { + component_mode = "shared_library" +} else { + component_mode = "source_set" +} + +template("component") { + if (is_component_build) { + shared_library(target_name) { + # Configs will always be defined since we set_defaults for a component + # above. We want to use those rather than whatever came with the nested + # shared/static library inside the component. + configs = [] # Prevent list overwriting warning. + configs = invoker.configs + + # The sources assignment filter will have already been applied when the + # code was originally executed. We don't want to apply it again, since + # the original target may have override it for some assignments. + set_sources_assignment_filter([]) + + if (defined(invoker.all_dependent_configs)) { all_dependent_configs = invoker.all_dependent_configs } + if (defined(invoker.allow_circular_includes_from)) { allow_circular_includes_from = invoker.allow_circular_includes_from } + if (defined(invoker.cflags)) { cflags = invoker.cflags } + if (defined(invoker.cflags_c)) { cflags_c = invoker.cflags_c } + if (defined(invoker.cflags_cc)) { cflags_cc = invoker.cflags_cc } + if (defined(invoker.cflags_objc)) { cflags_objc = invoker.cflags_objc } + if (defined(invoker.cflags_objcc)) { cflags_objcc = invoker.cflags_objcc } + if (defined(invoker.check_includes)) { check_includes = invoker.check_includes } + if (defined(invoker.data)) { data = invoker.data } + if (defined(invoker.datadeps)) { datadeps = invoker.datadeps } + if (defined(invoker.defines)) { defines = invoker.defines } + if (defined(invoker.deps)) { deps = invoker.deps } + if (defined(invoker.direct_dependent_configs)) { direct_dependent_configs = invoker.direct_dependent_configs } + if (defined(invoker.forward_dependent_configs_from)) { forward_dependent_configs_from = invoker.forward_dependent_configs_from } + if (defined(invoker.include_dirs)) { include_dirs = invoker.include_dirs } + if (defined(invoker.ldflags)) { ldflags = invoker.ldflags } + if (defined(invoker.lib_dirs)) { lib_dirs = invoker.lib_dirs } + if (defined(invoker.libs)) { libs = invoker.libs } + if (defined(invoker.output_extension)) { output_extension = invoker.output_extension } + if (defined(invoker.output_name)) { output_name = invoker.output_name } + if (defined(invoker.public)) { public = invoker.public } + if (defined(invoker.public_configs)) { public_configs = invoker.public_configs } + if (defined(invoker.public_deps)) { public_deps = invoker.public_deps } + if (defined(invoker.sources)) { sources = invoker.sources } + if (defined(invoker.testonly)) { testonly = invoker.testonly } + if (defined(invoker.visibility)) { visibility = invoker.visibility } + } + } else { + source_set(target_name) { + # See above. + configs = [] # Prevent list overwriting warning. + configs = invoker.configs + + # See above call. + set_sources_assignment_filter([]) + + if (defined(invoker.all_dependent_configs)) { all_dependent_configs = invoker.all_dependent_configs } + if (defined(invoker.allow_circular_includes_from)) { allow_circular_includes_from = invoker.allow_circular_includes_from } + if (defined(invoker.cflags)) { cflags = invoker.cflags } + if (defined(invoker.cflags_c)) { cflags_c = invoker.cflags_c } + if (defined(invoker.cflags_cc)) { cflags_cc = invoker.cflags_cc } + if (defined(invoker.cflags_objc)) { cflags_objc = invoker.cflags_objc } + if (defined(invoker.cflags_objcc)) { cflags_objcc = invoker.cflags_objcc } + if (defined(invoker.check_includes)) { check_includes = invoker.check_includes } + if (defined(invoker.data)) { data = invoker.data } + if (defined(invoker.datadeps)) { datadeps = invoker.datadeps } + if (defined(invoker.defines)) { defines = invoker.defines } + if (defined(invoker.deps)) { deps = invoker.deps } + if (defined(invoker.direct_dependent_configs)) { direct_dependent_configs = invoker.direct_dependent_configs } + if (defined(invoker.forward_dependent_configs_from)) { forward_dependent_configs_from = invoker.forward_dependent_configs_from } + if (defined(invoker.include_dirs)) { include_dirs = invoker.include_dirs } + if (defined(invoker.ldflags)) { ldflags = invoker.ldflags } + if (defined(invoker.lib_dirs)) { lib_dirs = invoker.lib_dirs } + if (defined(invoker.libs)) { libs = invoker.libs } + if (defined(invoker.output_extension)) { output_extension = invoker.output_extension } + if (defined(invoker.output_name)) { output_name = invoker.output_name } + if (defined(invoker.public)) { public = invoker.public } + if (defined(invoker.public_configs)) { public_configs = invoker.public_configs } + if (defined(invoker.public_deps)) { public_deps = invoker.public_deps } + if (defined(invoker.sources)) { sources = invoker.sources } + if (defined(invoker.testonly)) { testonly = invoker.testonly } + if (defined(invoker.visibility)) { visibility = invoker.visibility } + } + } +} + +# ============================================================================== +# TEST SETUP +# ============================================================================== + +# Define a test as an executable (or shared_library on Android) with the +# "testonly" flag set. +template("test") { + if (is_android) { + shared_library(target_name) { + # Configs will always be defined since we set_defaults for a component + # above. We want to use those rather than whatever came with the nested + # shared/static library inside the component. + configs = [] # Prevent list overwriting warning. + configs = invoker.configs + + # See above call. + set_sources_assignment_filter([]) + + testonly = true + + if (defined(invoker.all_dependent_configs)) { all_dependent_configs = invoker.all_dependent_configs } + if (defined(invoker.allow_circular_includes_from)) { allow_circular_includes_from = invoker.allow_circular_includes_from } + if (defined(invoker.cflags)) { cflags = invoker.cflags } + if (defined(invoker.cflags_c)) { cflags_c = invoker.cflags_c } + if (defined(invoker.cflags_cc)) { cflags_cc = invoker.cflags_cc } + if (defined(invoker.cflags_objc)) { cflags_objc = invoker.cflags_objc } + if (defined(invoker.cflags_objcc)) { cflags_objcc = invoker.cflags_objcc } + if (defined(invoker.check_includes)) { check_includes = invoker.check_includes } + if (defined(invoker.data)) { data = invoker.data } + if (defined(invoker.datadeps)) { datadeps = invoker.datadeps } + if (defined(invoker.defines)) { defines = invoker.defines } + if (defined(invoker.deps)) { deps = invoker.deps } + if (defined(invoker.direct_dependent_configs)) { direct_dependent_configs = invoker.direct_dependent_configs } + if (defined(invoker.forward_dependent_configs_from)) { forward_dependent_configs_from = invoker.forward_dependent_configs_from } + if (defined(invoker.include_dirs)) { include_dirs = invoker.include_dirs } + if (defined(invoker.ldflags)) { ldflags = invoker.ldflags } + if (defined(invoker.lib_dirs)) { lib_dirs = invoker.lib_dirs } + if (defined(invoker.libs)) { libs = invoker.libs } + if (defined(invoker.output_extension)) { output_extension = invoker.output_extension } + if (defined(invoker.output_name)) { output_name = invoker.output_name } + if (defined(invoker.public)) { public = invoker.public } + if (defined(invoker.public_configs)) { public_configs = invoker.public_configs } + if (defined(invoker.public_deps)) { public_deps = invoker.public_deps } + if (defined(invoker.sources)) { sources = invoker.sources } + if (defined(invoker.visibility)) { visibility = invoker.visibility } + } + } else { + executable(target_name) { + # See above. + configs = [] # Prevent list overwriting warning. + configs = invoker.configs + + # See above call. + set_sources_assignment_filter([]) + + testonly = true + + if (defined(invoker.all_dependent_configs)) { all_dependent_configs = invoker.all_dependent_configs } + if (defined(invoker.allow_circular_includes_from)) { allow_circular_includes_from = invoker.allow_circular_includes_from } + if (defined(invoker.cflags)) { cflags = invoker.cflags } + if (defined(invoker.cflags_c)) { cflags_c = invoker.cflags_c } + if (defined(invoker.cflags_cc)) { cflags_cc = invoker.cflags_cc } + if (defined(invoker.cflags_objc)) { cflags_objc = invoker.cflags_objc } + if (defined(invoker.cflags_objcc)) { cflags_objcc = invoker.cflags_objcc } + if (defined(invoker.check_includes)) { check_includes = invoker.check_includes } + if (defined(invoker.data)) { data = invoker.data } + if (defined(invoker.datadeps)) { datadeps = invoker.datadeps } + if (defined(invoker.defines)) { defines = invoker.defines } + if (defined(invoker.deps)) { deps = invoker.deps } + if (defined(invoker.direct_dependent_configs)) { direct_dependent_configs = invoker.direct_dependent_configs } + if (defined(invoker.forward_dependent_configs_from)) { forward_dependent_configs_from = invoker.forward_dependent_configs_from } + if (defined(invoker.include_dirs)) { include_dirs = invoker.include_dirs } + if (defined(invoker.ldflags)) { ldflags = invoker.ldflags } + if (defined(invoker.lib_dirs)) { lib_dirs = invoker.lib_dirs } + if (defined(invoker.libs)) { libs = invoker.libs } + if (defined(invoker.output_extension)) { output_extension = invoker.output_extension } + if (defined(invoker.output_name)) { output_name = invoker.output_name } + if (defined(invoker.public)) { public = invoker.public } + if (defined(invoker.public_configs)) { public_configs = invoker.public_configs } + if (defined(invoker.public_deps)) { public_deps = invoker.public_deps } + if (defined(invoker.sources)) { sources = invoker.sources } + if (defined(invoker.visibility)) { visibility = invoker.visibility } + } + } +} diff --git a/build/config/android/config.gni b/build/config/android/config.gni index 29d739a438..760328095f 100644 --- a/build/config/android/config.gni +++ b/build/config/android/config.gni @@ -20,6 +20,11 @@ if (is_android) { android_default_keystore_path = "//build/android/ant/chromium-debug.keystore" android_default_keystore_name = "chromiumdebugkey" android_default_keystore_password = "chromium" + + # This is a unique identifier for a given build. It's used for + # identifying various build artifacts corresponding to a particular build of + # chrome (e.g. where to find archived symbols). + android_chrome_build_id = "\"\"" } if (is_android_webview_build) { @@ -78,7 +83,7 @@ if (is_android) { # Toolchain root directory for each build. The actual binaries are inside # a "bin" directory inside of these. - _android_toolchain_version = "4.8" + _android_toolchain_version = "4.9" x86_android_toolchain_root = "$android_ndk_root/toolchains/x86-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}" arm_android_toolchain_root = "$android_ndk_root/toolchains/arm-linux-androideabi-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}" mips_android_toolchain_root = "$android_ndk_root/toolchains/mipsel-linux-android-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}" diff --git a/build/config/android/internal_rules.gni b/build/config/android/internal_rules.gni index 376b4fa040..42d3b3aa7b 100644 --- a/build/config/android/internal_rules.gni +++ b/build/config/android/internal_rules.gni @@ -15,6 +15,8 @@ android_sdk_jar = "$android_sdk/android.jar" rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir) template("android_lint") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + jar_path = invoker.jar_path android_manifest = invoker.android_manifest java_files = invoker.java_files @@ -63,6 +65,8 @@ template("android_lint") { # See build/android/gyp/write_build_config.py and # build/android/gyp/util/build_utils.py:ExpandFileArgs template("write_build_config") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + assert(defined(invoker.type)) assert(defined(invoker.build_config)) @@ -74,6 +78,7 @@ template("write_build_config") { action(target_name) { script = "//build/android/gyp/write_build_config.py" depfile = "$target_gen_dir/$target_name.d" + inputs = [] deps = [] if (defined(invoker.deps)) { @@ -112,6 +117,19 @@ template("write_build_config") { args += [ "--resources-zip", rebase_path(invoker.resources_zip, root_build_dir), ] + if (defined(invoker.android_manifest)) { + inputs += [ + invoker.android_manifest + ] + args += [ + "--android-manifest", rebase_path(invoker.android_manifest, root_build_dir), + ] + } + if (defined(invoker.custom_package)) { + args += [ + "--package-name", invoker.custom_package + ] + } } if (type == "android_apk") { @@ -137,6 +155,8 @@ template("write_build_config") { # Creates a zip archive of the inputs. # If base_dir is provided, the archive paths will be relative to it. template("zip") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + assert(defined(invoker.inputs)) assert(defined(invoker.output)) @@ -164,6 +184,8 @@ template("zip") { } template("dex") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + assert(defined(invoker.sources)) assert(defined(invoker.output)) action(target_name) { @@ -175,6 +197,10 @@ template("dex") { inputs = invoker.inputs } + if (defined(invoker.deps)) { + deps = invoker.deps + } + rebased_output = rebase_path(invoker.output, root_build_dir) args = [ @@ -200,6 +226,8 @@ template("dex") { # Packages resources, assets, dex, and native libraries into an apk. Signs and # zipaligns the apk. template("create_apk") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + _android_manifest = invoker.android_manifest _base_path = invoker.base_path _final_apk_path = invoker.apk_path @@ -336,6 +364,8 @@ template("create_apk") { } template("java_prebuilt") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + _input_jar_path = invoker.input_jar_path _output_jar_path = invoker.output_jar_path _jar_toc_path = _output_jar_path + ".TOC" @@ -417,6 +447,8 @@ template("java_prebuilt") { # jar_path: Use this to explicitly set the output jar path. Defaults to # "${target_gen_dir}/${target_name}.jar. template("java_library") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + assert(defined(invoker.java_files)) assert(defined(invoker.build_config)) assert(defined(invoker.jar_path)) @@ -508,11 +540,35 @@ template("java_library") { # Runs Android lint against the compiled java files. # Dexes the output jar for inclusion in an APK. template("android_java_library") { - assert(defined(invoker.java_files)) + if (defined(invoker.testonly)) { testonly = invoker.testonly } + + assert(defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir)) assert(defined(invoker.build_config)) assert(defined(invoker.jar_path)) assert(defined(invoker.dex_path)) + _srcjar_deps = [] + if (defined(invoker.srcjar_deps)) { + _srcjar_deps = invoker.srcjar_deps + } + + _java_files = [] + if (defined(invoker.java_files)) { + _java_files = invoker.java_files + } else { + _java_files_build_rel = exec_script( + "//build/android/gyp/find.py", + [ + "--pattern", + "*.java", + rebase_path(invoker.DEPRECATED_java_in_dir, root_build_dir) + ], + "list lines" + ) + _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir) + } + assert(_java_files != [] || _srcjar_deps != []) + _jar_path = invoker.jar_path _dex_path = invoker.dex_path @@ -523,6 +579,7 @@ template("android_java_library") { assert(_android_manifest != "") _final_deps = [] + _final_datadeps = [] java_library("${target_name}__java_library") { jar_path = _jar_path @@ -530,23 +587,25 @@ template("android_java_library") { jar_excluded_patterns = invoker.jar_excluded_patterns } build_config = invoker.build_config - java_files = invoker.java_files + java_files = _java_files + srcjar_deps = _srcjar_deps - if (defined(invoker.srcjar_deps)) { - srcjar_deps = invoker.srcjar_deps - } if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { proguard_preprocess = invoker.proguard_preprocess proguard_config = invoker.proguard_config } + + if (defined(invoker.dist_jar_path)) { + dist_jar_path = invoker.dist_jar_path + } } if (defined(invoker.chromium_code) && invoker.chromium_code) { - _final_deps += [ ":${target_name}__lint" ] + _final_datadeps += [ ":${target_name}__lint" ] android_lint("${target_name}__lint") { android_manifest = _android_manifest jar_path = _jar_path - java_files = invoker.java_files + java_files = _java_files } } @@ -559,12 +618,14 @@ template("android_java_library") { deps = [ ":${target_name}__java_library", ":${target_name}__dex", - ] + _final_deps + ] + _final_deps + _final_datadeps } } # Runs process_resources.py template("process_resources") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + zip_path = invoker.zip_path srcjar_path = invoker.srcjar_path build_config = invoker.build_config @@ -611,6 +672,7 @@ template("process_resources") { "--resource-zip-out", rebase_path(zip_path, root_build_dir), "--dependencies-res-zips=@FileArg($rebase_build_config:resources:dependency_zips)", + "--extra-res-packages=@FileArg($rebase_build_config:resources:extra_package_names)", ] if (non_constant_id) { @@ -642,12 +704,18 @@ template("process_resources") { } template("copy_ex") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + action(target_name) { script = "//build/android/gyp/copy_ex.py" depfile = "$target_gen_dir/$target_name.d" outputs = [ depfile, ] + sources = [] + if (defined(invoker.sources)) { + sources += invoker.sources + } inputs = [] if (defined(invoker.inputs)) { @@ -661,6 +729,9 @@ template("copy_ex") { if (defined(invoker.args)) { args += invoker.args } + rebased_sources = rebase_path(sources, root_build_dir) + args += [ "--files=$rebased_sources" ] + if (defined(invoker.clear_dir) && invoker.clear_dir) { args += ["--clear"] } diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni index 43d79d0153..4e9f3a8100 100644 --- a/build/config/android/rules.gni +++ b/build/config/android/rules.gni @@ -29,6 +29,8 @@ assert(is_android) # jni_package = "foo" # } template("generate_jni") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + assert(defined(invoker.sources)) assert(defined(invoker.jni_package)) jni_package = invoker.jni_package @@ -69,13 +71,13 @@ template("generate_jni") { group(target_name) { deps = [ ":$foreach_target_name" ] - direct_dependent_configs = [ ":jni_includes_${target_name}" ] + public_configs = [ ":jni_includes_${target_name}" ] if (defined(invoker.deps)) { deps += invoker.deps } - if (defined(invoker.forward_dependent_configs_from)) { - forward_dependent_configs_from = invoker.forward_dependent_configs_from + if (defined(invoker.public_deps)) { + public_deps = invoker.public_deps } } } @@ -95,7 +97,7 @@ template("generate_jni") { # jar_file: the path to the .jar. If not provided, will default to the sdk's # android.jar # -# deps, forward_dependent_configs_from: As normal +# deps, public_deps: As normal # # Example # generate_jar_jni("foo_jni") { @@ -105,6 +107,8 @@ template("generate_jni") { # jni_package = "foo" # } template("generate_jar_jni") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + assert(defined(invoker.classes)) assert(defined(invoker.jni_package)) @@ -118,17 +122,16 @@ template("generate_jar_jni") { base_output_dir = "${root_gen_dir}/${target_name}/${jni_package}" jni_output_dir = "${base_output_dir}/jni" - jni_generator_include = - rebase_path("//base/android/jni_generator/jni_generator_helper.h", - root_build_dir) + jni_generator_include = "//base/android/jni_generator/jni_generator_helper.h" # TODO(cjhopman): make jni_generator.py support generating jni for multiple # .class files from a .jar. jni_actions = [] foreach(class, invoker.classes) { - classname_list = process_file_template( + _classname_list = [] + _classname_list = process_file_template( [class], "{{source_name_part}}") - classname = classname_list[0] + classname = _classname_list[0] jni_target_name = "${target_name}__jni_${classname}" jni_actions += [ ":$jni_target_name" ] action(jni_target_name) { @@ -150,7 +153,7 @@ template("generate_jar_jni") { "--optimize_generation=1", "--ptr_type=long", "--output_dir", rebase_path(jni_output_dir, root_build_dir), - "--includes", rebase_path(jni_generator_include, "//"), + "--includes", rebase_path(jni_generator_include, root_build_dir), ] } } @@ -164,10 +167,10 @@ template("generate_jar_jni") { if (defined(invoker.deps)) { deps += invoker.deps } - if (defined(invoker.forward_dependent_configs_from)) { - forward_dependent_configs_from = invoker.forward_dependent_configs_from + if (defined(invoker.public_deps)) { + public_deps = invoker.public_deps } - direct_dependent_configs = [ ":jni_includes_${target_name}" ] + public_configs = [ ":jni_includes_${target_name}" ] } } @@ -205,6 +208,8 @@ template("generate_jar_jni") { # include_path = "android/java/templates" # } template("java_cpp_template") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + assert(defined(invoker.sources)) package_name = invoker.package_name + "" @@ -219,7 +224,7 @@ template("java_cpp_template") { if (defined(invoker.inputs)) { inputs = invoker.inputs + [] } - depfile = "${target_gen_dir}/${target_name}.d" + depfile = "${target_gen_dir}/${target_name}_{{source_name_part}}.d" sources = invoker.sources @@ -262,6 +267,73 @@ template("java_cpp_template") { } } +# Declare a target for generating Java classes from C++ enums. +# +# This target generates Java files from C++ enums using a script. +# +# This target will create a single .srcjar. Adding this target to an +# android_library target's srcjar_deps will make the generated java files be +# included in that library's final outputs. +# +# Variables +# sources: list of files to be processed by the script. For each annotated +# enum contained in the sources files the script will generate a .java +# file with the same name as the name of the enum. +# +# outputs: list of outputs, relative to the output_dir. These paths are +# verified at build time by the script. To get the list programatically run: +# python build/android/gyp/java_cpp_enum.py --output_dir=. \ +# --print_output_only path/to/header/file.h +# +# Example +# java_cpp_enum("foo_generated_enum") { +# sources = [ +# "src/native_foo_header.h", +# ] +# outputs = [ +# "org/chromium/FooEnum.java", +# ] +# } +template("java_cpp_enum") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + + assert(defined(invoker.sources)) + assert(defined(invoker.outputs)) + + action("${target_name}__generate_enum") { + sources = rebase_path(invoker.sources, root_build_dir) + script = "//build/android/gyp/java_cpp_enum.py" + gen_dir = "${target_gen_dir}/${target_name}/enums" + outputs = get_path_info( + rebase_path(invoker.outputs, ".", gen_dir), "abspath") + + args = [ + "--output_dir", rebase_path(gen_dir, root_build_dir), + ] + foreach(output, rebase_path(outputs, root_build_dir)) { + args += ["--assert_file", output] + } + args += sources + } + + generate_enum_outputs = get_target_outputs(":${target_name}__generate_enum") + base_gen_dir = get_label_info(":${target_name}__generate_enum", + "target_gen_dir") + + srcjar_path = "${target_gen_dir}/${target_name}.srcjar" + zip("${target_name}__zip_srcjar") { + inputs = generate_enum_outputs + output = srcjar_path + base_dir = base_gen_dir + } + + group(target_name) { + deps = [ + ":${target_name}__zip_srcjar" + ] + } +} + # Declare an Android resources target # @@ -292,7 +364,10 @@ template("java_cpp_template") { # custom_package = "org.chromium.foo" # } template("android_resources") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + assert(defined(invoker.resource_dirs)) + assert(defined(invoker.android_manifest) || defined(invoker.custom_package)) base_path = "$target_gen_dir/$target_name" zip_path = base_path + ".resources.zip" @@ -303,9 +378,9 @@ template("android_resources") { type = "android_resources" resources_zip = zip_path srcjar = srcjar_path - if (defined(invoker.deps)) { - deps = invoker.deps - } + if (defined(invoker.deps)) { deps = invoker.deps } + if (defined(invoker.android_manifest)) { android_manifest = invoker.android_manifest } + if (defined(invoker.custom_package)) { custom_package = invoker.custom_package } } android_manifest = "//build/android/AndroidManifest.xml" @@ -348,6 +423,8 @@ template("android_resources") { # grd_file = "foo_strings.grd" # } template("java_strings_grd") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + base_path = "$target_gen_dir/$target_name" resources_zip = base_path + ".resources.zip" build_config = base_path + ".build_config" @@ -405,13 +482,17 @@ template("java_strings_grd") { # java_files: List of .java files included in this library. # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars # will be added to java_files and be included in this library. -# chromium_code: If true, extra static analysis warning/errors will be enabled. +# chromium_code: If true, extra analysis warning/errors will be enabled. # jar_excluded_patterns: List of patterns of .class files to exclude from the # final jar. # proguard_preprocess: If true, proguard preprocessing will be run. This can # be used to remove unwanted parts of the library. # proguard_config: Path to the proguard config for preprocessing. # +# DEPRECATED_java_in_dir: Directory containing java files. All .java files in +# this directory will be included in the library. This is only supported to +# ease the gyp->gn conversion and will be removed in the future. +# # Example # android_library("foo_java") { # java_files = [ @@ -430,11 +511,13 @@ template("java_strings_grd") { # ] # } template("android_library") { - assert(defined(invoker.java_files)) - base_path = "$target_gen_dir/$target_name" - build_config = base_path + ".build_config" - jar_path = base_path + ".jar" - dex_path = base_path + ".dex.jar" + if (defined(invoker.testonly)) { testonly = invoker.testonly } + + assert(defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir)) + _base_path = "$target_gen_dir/$target_name" + _build_config = _base_path + ".build_config" + _jar_path = _base_path + ".jar" + _dex_path = _base_path + ".dex.jar" write_build_config("${target_name}__build_config") { type = "android_library" @@ -444,7 +527,9 @@ template("android_library") { deps += invoker.deps } - # base_path + build_config = _build_config + jar_path = _jar_path + dex_path = _dex_path } _chromium_code = true @@ -454,16 +539,26 @@ template("android_library") { android_java_library(target_name) { chromium_code = _chromium_code - java_files = invoker.java_files - build_config = build_config + if (defined(invoker.java_files)) { + java_files = invoker.java_files + } else { + DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir + } + build_config = _build_config + jar_path = _jar_path + dex_path = _dex_path if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { proguard_preprocess = true proguard_config = invoker.proguard_config } + jar_excluded_patterns = [ + "*/R.class", "*/R##*.class", + "*/Manifest.class", "*/Manifest##*.class", + ] if (defined(invoker.jar_excluded_patterns)) { - jar_excluded_patterns = invoker.jar_excluded_patterns + jar_excluded_patterns += invoker.jar_excluded_patterns } if (defined(invoker.srcjar_deps)) { @@ -496,6 +591,8 @@ template("android_library") { # ] # } template("android_java_prebuilt") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + assert(defined(invoker.jar_path)) _base_path = "${target_gen_dir}/$target_name" _jar_path = _base_path + ".jar" @@ -546,6 +643,9 @@ template("android_java_prebuilt") { # # Variables # android_manifest: Path to AndroidManifest.xml. +# datadeps: List of dependencies needed at runtime. These will be built but +# won't change the generated .apk in any way (in fact they may be built +# after the .apk is). # deps: List of dependencies. All Android java resources and libraries in the # "transitive closure" of these dependencies will be included in the apk. # Note: this "transitive closure" actually only includes such targets if @@ -560,6 +660,11 @@ template("android_java_prebuilt") { # native_libs: List paths of native libraries to include in this apk. If these # libraries depend on other shared_library targets, those dependencies will # also be included in the apk. +# testonly: Marks this target as "test-only". +# +# DEPRECATED_java_in_dir: Directory containing java files. All .java files in +# this directory will be included in the library. This is only supported to +# ease the gyp->gn conversion and will be removed in the future. # # Example # android_apk("foo_apk") { @@ -580,26 +685,33 @@ template("android_java_prebuilt") { # ] # } template("android_apk") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + + assert(defined(invoker.final_apk_path) || defined(invoker.apk_name)) gen_dir = "$target_gen_dir/$target_name" base_path = "$gen_dir/$target_name" build_config = "$base_path.build_config" resources_zip_path = "$base_path.resources.zip" all_resources_zip_path = "$base_path.resources.all.zip" - resource_srcjar_path = "$base_path.resources.srcjar" jar_path = "$base_path.jar" final_dex_path = "$gen_dir/classes.dex" _template_name = target_name + _final_apk_path = "" + if (defined(invoker.final_apk_path)) { + _final_apk_path = invoker.final_apk_path + } else if (defined(invoker.apk_name)) { + _final_apk_path = "$root_build_dir/apks/" + invoker.apk_name + ".apk" + } + _dist_jar_path_list = process_file_template( + [ _final_apk_path ], + "$root_build_dir/test.lib.java/{{source_name_part}}.jar" + ) + _dist_jar_path = _dist_jar_path_list[0] - _native_lib_version_name = "" - - _use_chromium_linker = false - _enable_chromium_linker_tests = false - _load_library_from_apk = false - - _native_libs_dir = base_path + "/libs" _native_libs = [] if (defined(invoker.native_libs)) { _native_libs = invoker.native_libs + _native_libs_dir = base_path + "/libs" } _keystore_path = android_default_keystore_path @@ -619,9 +731,8 @@ template("android_apk") { _rebased_build_config = rebase_path(build_config, root_build_dir) - write_build_config("${target_name}__build_config") { + write_build_config("${_template_name}__build_config") { type = "android_apk" - srcjar = resource_srcjar_path dex_path = final_dex_path resources_zip = resources_zip_path @@ -634,69 +745,108 @@ template("android_apk") { final_deps = [] - final_deps += [":${target_name}__process_resources"] - process_resources("${target_name}__process_resources") { + final_deps += [":${_template_name}__process_resources"] + process_resources("${_template_name}__process_resources") { + srcjar_path = "${target_gen_dir}/${target_name}.srcjar" android_manifest = invoker.android_manifest - resource_dirs = ["//build/android/ant/empty/res"] zip_path = resources_zip_path - srcjar_path = resource_srcjar_path - generate_constant_ids = true } + _srcjar_deps += [":${_template_name}__process_resources"] - java_cpp_template("${target_name}__native_libraries_java") { - package_name = "org/chromium/base/library_loader" - sources = [ - "//base/android/java/templates/NativeLibraries.template", - ] - inputs = [ - build_config, - ] + if (_native_libs != []) { + _use_chromium_linker = false + _enable_chromium_linker_tests = false + _load_library_from_apk = false + _native_lib_version_name = "" - defines = [ - "NATIVE_LIBRARIES_LIST=" + - "@FileArg($_rebased_build_config:native:java_libraries_list)", - "NATIVE_LIBRARIES_VERSION_NUMBER=\"$_native_lib_version_name\"", - ] - if (_use_chromium_linker) { - defines += ["ENABLED_CHROMIUM_LINKER"] - } - if (_load_library_from_apk) { - defines += ["ENABLE_CHROMIUM_LINKER_LIBRARY_IN_ZIP_FILE"] - } - if (_enable_chromium_linker_tests) { - defines += ["ENABLE_CHROMIUM_LINKER_TESTS"] + + java_cpp_template("${_template_name}__native_libraries_java") { + package_name = "org/chromium/base/library_loader" + sources = [ + "//base/android/java/templates/NativeLibraries.template", + ] + inputs = [ + build_config, + ] + + defines = [ + "NATIVE_LIBRARIES_LIST=" + + "@FileArg($_rebased_build_config:native:java_libraries_list)", + "NATIVE_LIBRARIES_VERSION_NUMBER=\"$_native_lib_version_name\"", + ] + if (_use_chromium_linker) { + defines += ["ENABLED_CHROMIUM_LINKER"] + } + if (_load_library_from_apk) { + defines += ["ENABLE_CHROMIUM_LINKER_LIBRARY_IN_ZIP_FILE"] + } + if (_enable_chromium_linker_tests) { + defines += ["ENABLE_CHROMIUM_LINKER_TESTS"] + } } + _srcjar_deps += [ ":${_template_name}__native_libraries_java" ] } - _srcjar_deps += [ ":${target_name}__native_libraries_java" ] - rebased_build_config = rebase_path(build_config, root_build_dir) - - final_deps += [":${target_name}__java"] - android_java_library("${target_name}__java") { + final_deps += [ ":${_template_name}__java" ] + android_java_library("${_template_name}__java") { android_manifest = invoker.android_manifest - java_files = invoker.java_files + if (defined(invoker.java_files)) { + java_files = invoker.java_files + } else if (defined(invoker.DEPRECATED_java_in_dir)) { + DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir + } else { + java_files = [] + } srcjar_deps = _srcjar_deps dex_path = base_path + ".dex.jar" } - final_deps += [":${target_name}__final_dex"] - dex("${target_name}__final_dex") { - sources = [jar_path] - inputs = [build_config] + if (_dist_jar_path != "") { + # TODO(cjhopman): This is only ever needed to calculate the list of tests to + # run. See build/android/pylib/instrumentation/test_jar.py. We should be + # able to just do that calculation at build time instead. + action("${_template_name}__create_dist_jar") { + script = "//build/android/gyp/create_dist_jar.py" + depfile = "$target_gen_dir/$target_name.d" + inputs = [ build_config ] + outputs = [ + depfile, + _dist_jar_path, + ] + args = [ + "--depfile", rebase_path(depfile, root_build_dir), + "--output", rebase_path(_dist_jar_path, root_build_dir), + "--inputs=@FileArg($_rebased_build_config:dist_jar:dependency_jars)", + ] + inputs += [ jar_path ] + _rebased_jar_path = rebase_path([ jar_path ], root_build_dir) + args += [ + "--inputs=$_rebased_jar_path", + ] + } + } + + final_deps += [":${_template_name}__final_dex"] + dex("${_template_name}__final_dex") { + deps = [ ":${_template_name}__java" ] + sources = [ jar_path ] + inputs = [ build_config ] output = final_dex_path - dex_arg_key = "${rebased_build_config}:apk_dex:dependency_dex_files" - args = ["--inputs=@FileArg($dex_arg_key)"] + dex_arg_key = "${_rebased_build_config}:apk_dex:dependency_dex_files" + args = [ "--inputs=@FileArg($dex_arg_key)" ] } if (_native_libs != []) { - copy_ex("${target_name}__prepare_native") { + copy_ex("${_template_name}__prepare_native") { clear_dir = true - inputs = [build_config] + inputs = [ + build_config + ] dest = "$_native_libs_dir/$android_app_abi" args = [ - "--files=@FileArg(${rebased_build_config}:native:libraries)", + "--files=@FileArg(${_rebased_build_config}:native:libraries)", ] if (is_debug) { rebased_gdbserver = rebase_path(android_gdbserver, root_build_dir) @@ -707,13 +857,17 @@ template("android_apk") { } } - final_deps += [":${target_name}__create"] - create_apk("${target_name}__create") { - apk_path = invoker.final_apk_path + final_deps += [":${_template_name}__create"] + create_apk("${_template_name}__create") { + apk_path = _final_apk_path android_manifest = invoker.android_manifest resources_zip = all_resources_zip_path dex_path = final_dex_path + if (defined(invoker.asset_location)) { + asset_location = invoker.asset_location + } + keystore_name = _keystore_name keystore_path = _keystore_path keystore_password = _keystore_password @@ -726,6 +880,10 @@ template("android_apk") { group(target_name) { deps = final_deps + if (defined(invoker.datadeps)) { + # TODO(cjhopman): Fix this when group datadeps works. + deps += invoker.datadeps + } } } @@ -753,6 +911,8 @@ template("android_apk") { # unittests_dep = ":foo_unittests" # } template("unittest_apk") { + testonly = true + assert(defined(invoker.unittests_dep), "Need unittests_dep for $target_name") test_suite_name = get_label_info(invoker.unittests_dep, "name") @@ -760,12 +920,12 @@ template("unittest_apk") { if (defined(invoker.unittests_binary)) { unittests_binary = root_out_dir + "/" + invoker.unittests_binary } else { - unittests_binary = root_out_dir + "/" + test_suite_name + unittests_binary = root_out_dir + "/lib.stripped/lib" + test_suite_name + ".so" } android_apk(target_name) { - apk_name = test_suite_name - final_apk_path = "$root_build_dir/${apk_name}_apk/${apk_name}-debug.apk" + _apk_name = test_suite_name + final_apk_path = "$root_build_dir/${_apk_name}_apk/${_apk_name}-debug.apk" java_files = [ "//testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java" ] @@ -775,5 +935,159 @@ template("unittest_apk") { if (defined(invoker.deps)) { deps = invoker.deps } + datadeps = [ + "//tools/android/md5sum", + ] + } +} + +# Generate .java files from .aidl files. +# +# This target will store the .java files in a srcjar and should be included in +# an android_library or android_apk's srcjar_deps. +# +# Variables +# sources: Paths to .aidl files to compile. +# import_include: Path to directory containing .java files imported by the +# .aidl files. +# interface_file: Preprocessed aidl file to import. +# +# Example +# android_aidl("foo_aidl") { +# import_include = "java/src" +# sources = [ +# "java/src/com/foo/bar/FooBarService.aidl", +# "java/src/com/foo/bar/FooBarServiceCallback.aidl", +# ] +# } +template("android_aidl") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + + srcjar_path = "${target_gen_dir}/${target_name}.srcjar" + aidl_path = "${android_sdk_build_tools}/aidl" + framework_aidl = "$android_sdk/framework.aidl" + + action(target_name) { + script = "//build/android/gyp/aidl.py" + sources = invoker.sources + + imports = [ framework_aidl ] + if (defined(invoker.interface_file)) { + assert(invoker.interface_file != "") + imports += [ invoker.interface_file ] + } + + inputs = [ + aidl_path, + ] + imports + + depfile = "${target_gen_dir}/${target_name}.d" + outputs = [ + depfile, + srcjar_path + ] + rebased_imports = rebase_path(imports, root_build_dir) + args = [ + "--depfile", rebase_path(depfile, root_build_dir), + "--aidl-path", rebase_path(aidl_path, root_build_dir), + "--imports=$rebased_imports", + "--srcjar", rebase_path(srcjar_path, root_build_dir), + ] + if (defined(invoker.import_include) && invoker.import_include != "") { + # TODO(cjhopman): aidl supports creating a depfile. We should be able to + # switch to constructing a depfile for the overall action from that + # instead of having all the .java files in the include paths as inputs. + rebased_import_includes = rebase_path( + [invoker.import_include], root_build_dir) + args += [ "--includes=$rebased_import_includes" ] + + _java_files_build_rel = exec_script( + "//build/android/gyp/find.py", + rebase_path([invoker.import_include], root_build_dir), + "list lines" + ) + _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir) + inputs += _java_files + } + args += rebase_path(sources, root_build_dir) + } +} + +# Creates a dist directory for a native executable. +# +# Running a native executable on a device requires all the shared library +# dependencies of that executable. To make it easier to install and run such an +# executable, this will create a directory containing the native exe and all +# it's library dependencies. +# +# Note: It's usually better to package things as an APK than as a native +# executable. +# +# Variables +# dist_dir: Directory for the exe and libraries. Everything in this directory +# will be deleted before copying in the exe and libraries. +# binary: Path to (stripped) executable. +# +# Example +# create_native_executable_dist("foo_dist") { +# dist_dir = "$root_build_dir/foo_dist" +# binary = "$root_build_dir/exe.stripped/foo" +# } +template("create_native_executable_dist") { + if (defined(invoker.testonly)) { testonly = invoker.testonly } + + dist_dir = invoker.dist_dir + binary = invoker.binary + final_deps = [] + template_name = target_name + + libraries_list = "${target_gen_dir}/${template_name}_library_dependencies.list" + + # TODO(gyp) + #'dependencies': [ + #'<(DEPTH)/build/android/setup.gyp:copy_system_libraries', + #], + + stripped_libraries_dir = "$root_build_dir/lib.stripped" + final_deps += [ ":${template_name}__find_library_dependencies" ] + action("${template_name}__find_library_dependencies") { + script = "//build/android/gyp/write_ordered_libraries.py" + depfile = "$target_gen_dir/$target_name.d" + inputs = [ + binary, + android_readelf, + ] + outputs = [ + depfile, + libraries_list, + ] + rebased_binaries = rebase_path([ binary ], root_build_dir) + args = [ + "--depfile", rebase_path(depfile, root_build_dir), + "--input-libraries=$rebased_binaries", + "--libraries-dir", rebase_path(stripped_libraries_dir, root_build_dir), + "--output", rebase_path(libraries_list, root_build_dir), + "--readelf", rebase_path(android_readelf, root_build_dir), + ] + } + + final_deps += [ ":${template_name}__copy_libraries_and_exe" ] + copy_ex("${template_name}__copy_libraries_and_exe") { + clear_dir = true + inputs = [ + binary, + libraries_list + ] + dest = dist_dir + rebased_binaries_list = rebase_path([ binary ], root_build_dir) + rebased_libraries_list = rebase_path(libraries_list, root_build_dir) + args = [ + "--files=$rebased_binaries_list", + "--files=@FileArg($rebased_libraries_list:libraries)", + ] + } + + group(target_name) { + deps = final_deps } } diff --git a/build/config/arm.gni b/build/config/arm.gni index 65cb160a53..59de6687e7 100644 --- a/build/config/arm.gni +++ b/build/config/arm.gni @@ -12,6 +12,14 @@ if (cpu_arch == "arm") { # "softfp". An empty string means to use the default one for the # arm_version. arm_float_abi = "" + + # The ARM variant-specific tuning mode. This will be a string like "armv6" + # or "cortex-a15". An empty string means to use the default for the + # arm_version. + arm_tune = "" + + # Whether to use the neon FPU instruction set or not. + arm_use_neon = true } assert(arm_float_abi == "" || @@ -21,15 +29,14 @@ if (cpu_arch == "arm") { if (is_android) { arm_use_neon = false - arm_optionally_use_neon = true - } else { - arm_use_neon = true - arm_optionally_use_neon = true } + arm_optionally_use_neon = true if (arm_version == 6) { arm_arch = "armv6" - arm_tune = "" + if (arm_tune != "") { + arm_tune = "" + } if (arm_float_abi == "") { arm_float_abi = "softfp" } @@ -40,10 +47,14 @@ if (cpu_arch == "arm") { } else if (arm_version == 7) { arm_arch = "armv7-a" - arm_tune = "generic-armv7-a" + if (arm_tune == "") { + arm_tune = "generic-armv7-a" + } + if (arm_float_abi == "") { arm_float_abi = "softfp" } + arm_use_thumb = true if (arm_use_neon) { diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 613223539b..42c254c08c 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -14,6 +14,23 @@ declare_args() { # Normally, Android builds are lightly optimized, even for debug builds, to # keep binary size down. Setting this flag to true disables such optimization android_full_debug = false + + # Whether to use the binary binutils checked into third_party/binutils. + # These are not multi-arch so cannot be used except on x86 and x86-64 (the + # only two architectures that are currently checked in). Turn this off when + # you are using a custom toolchain and need to control -B in cflags. + linux_use_bundled_binutils = is_linux && cpu_arch == "x64" +} + +use_gold = is_linux && cpu_arch == "x64" + +if (!is_win) { + # linux_use_debug_fission: whether to use split DWARF debug info + # files. This can reduce link time significantly, but is incompatible + # with some utilities such as icecc and ccache. Requires gold and + # gcc >= 4.8 or clang. + # http://gcc.gnu.org/wiki/DebugFission + use_debug_fission = use_gold && linux_use_bundled_binutils } # default_include_dirs --------------------------------------------------------- @@ -88,6 +105,29 @@ config("compiler") { } } + if (is_clang && is_debug) { + # Allow comparing the address of references and 'this' against 0 + # in debug builds. Technically, these can never be null in + # well-defined C/C++ and Clang can optimize such checks away in + # release builds, but they may be used in asserts in debug builds. + cflags_cc += [ + "-Wno-undefined-bool-conversion", + "-Wno-tautological-undefined-compare", + ] + } + + if (is_clang && !is_win) { + # This is here so that all files get recompiled after a clang roll and + # when turning clang on or off. (defines are passed via the command line, + # and build system rebuild things when their commandline changes). Nothing + # should ever read this define. + defines += [ + "CR_CLANG_REVISION=" + + exec_script( + "//tools/clang/scripts/posix-print-revision.py", [], "value") + ] + } + # Mac-specific compiler flags setup. # ---------------------------------- if (is_mac || is_ios) { @@ -123,7 +163,7 @@ config("compiler") { # CPU architecture. We may or may not be doing a cross compile now, so for # simplicity we always explicitly set the architecture. if (cpu_arch == "x64") { - cflags += [ "-m64" ] + cflags += [ "-m64", "-march=x86-64", ] ldflags += [ "-m64" ] } else if (cpu_arch == "x86") { cflags += [ "-m32" ] @@ -145,6 +185,20 @@ config("compiler") { cflags += [ "-mthumb-interwork" ] } } + if (!is_clang) { + # Clang doesn't support these flags. + cflags += [ + # The tree-sra optimization (scalar replacement for + # aggregates enabling subsequent optimizations) leads to + # invalid code generation when using the Android NDK's + # compiler (r5-r7). This can be verified using + # webkit_unit_tests' WTF.Checked_int8_t test. + "-fno-tree-sra", + # The following option is disabled to improve binary + # size and performance in gcc 4.9. + "-fno-caller-saves", + ] + } } } @@ -182,38 +236,47 @@ config("compiler") { # ------------------------------------ if (is_linux) { cflags += [ "-pthread" ] - - if (cpu_arch == "x64") { - # Use gold for linking on 64-bit Linux only (on 32-bit it runs out of - # address space, and it doesn't support cross-compiling). - gold_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", - root_build_dir) - ldflags += [ - "-B$gold_path", - - # There seems to be a conflict of --icf and -pie in gold which can - # generate crashy binaries. As a security measure, -pie takes - # precedence for now. - # TODO(brettw) common.gypi has this only for target toolset. - #"-Wl,--icf=safe", - "-Wl,--icf=none", - - # Experimentation found that using four linking threads - # saved ~20% of link time. - # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36 - # Only apply this to the target linker, since the host - # linker might not be gold, but isn't used much anyway. - # TODO(raymes): Disable threading because gold is frequently - # crashing on the bots: crbug.com/161942. - #"-Wl,--threads", - #"-Wl,--thread-count=4", - ] - } - ldflags += [ "-pthread", ] } + if (use_gold) { + # Use gold for linking on 64-bit Linux only (on 32-bit it runs out of + # address space, and it doesn't support cross-compiling). + gold_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", + root_build_dir) + ldflags += [ + "-B$gold_path", + + # Newer gccs and clangs support -fuse-ld, use the flag to force gold + # selection. + # gcc -- http://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Optimize-Options.html + "-fuse-ld=gold", + + # There seems to be a conflict of --icf and -pie in gold which can + # generate crashy binaries. As a security measure, -pie takes + # precedence for now. + # TODO(brettw) common.gypi has this only for target toolset. + #"-Wl,--icf=safe", + "-Wl,--icf=none", + + # Experimentation found that using four linking threads + # saved ~20% of link time. + # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36 + # Only apply this to the target linker, since the host + # linker might not be gold, but isn't used much anyway. + # TODO(raymes): Disable threading because gold is frequently + # crashing on the bots: crbug.com/161942. + #"-Wl,--threads", + #"-Wl,--thread-count=4", + ] + } + + if (linux_use_bundled_binutils) { + binutils_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", + root_build_dir) + cflags += [ "-B$binutils_path" ] + } # Clang-specific compiler flags setup. # ------------------------------------ @@ -238,15 +301,6 @@ config("compiler") { # Clang doesn't support these flags. cflags += [ "-finline-limit=64", - # The following 6 options are disabled to save on - # binary size in gcc 4.8. - # TODO(fdegans) Reevaluate when we upgrade GCC. - "-fno-partial-inlining", - "-fno-early-inlining", - "-fno-tree-copy-prop", - "-fno-tree-loop-optimize", - "-fno-move-loop-invariants", - "-fno-caller-saves", ] } if (is_android_webview_build) { @@ -454,8 +508,6 @@ config("runtime_library") { # Toggles between higher and lower warnings for code that is (or isn't) # part of Chromium. -# TODO: -Werror should always be on, independent of chromium_code -# http://crbug.com/393046 config("chromium_code") { if (is_win) { cflags = [ @@ -464,6 +516,7 @@ config("chromium_code") { } else { cflags = [ "-Wall", + "-Wextra", # GCC turns on -Wsign-compare for C++ under -Wall, but clang doesn't, # so we specify it explicitly. @@ -471,11 +524,6 @@ config("chromium_code") { # http://code.google.com/p/chromium/issues/detail?id=90453 "-Wsign-compare", ] - if (!is_linux) { - # TODO: Add this unconditionally once linux builds without warnings with - # clang in the gn build. - cflags += [ "-Werror" ] - } # In Chromium code, we define __STDC_foo_MACROS in order to get the # C99 macros on Mac and Linux. @@ -483,12 +531,6 @@ config("chromium_code") { "__STDC_CONSTANT_MACROS", "__STDC_FORMAT_MACROS", ] - - # TODO(brettw) this should also be enabled on Linux but some files - # currently fail. - if (is_mac) { - cflags += [ "-Wextra" ] - } } } config("no_chromium_code") { @@ -641,6 +683,7 @@ config("default_warnings") { cflags = [ # Enables. "-Wendif-labels", # Weird old-style text after an #endif. + "-Werror", # Warnings as errors. # Disables. "-Wno-missing-field-initializers", # "struct foo f = {0};" @@ -676,15 +719,17 @@ config("default_warnings") { # http://crbug.com/255186 "-Wno-deprecated-register", - # Clang spots more unused functions. - "-Wno-unused-function", - ] + # TODO(thakis): This used to be implied by -Wno-unused-function, + # which we no longer use. Check if it makes sense to remove + # this as well. http://crbug.com/316352 + "-Wno-unneeded-internal-declaration", - if (!is_mac && !is_ios) { - cflags_cc += [ - "-Wno-reserved-user-defined-literal", - ] - } + # TODO(thakis): Remove, http://crbug.com/263960 + "-Wno-reserved-user-defined-literal", + + # TODO(hans): Clean this up. Or disable with finer granularity. + "-Wno-unused-local-typedef", + ] } if (gcc_version >= 48) { cflags_cc += [ @@ -876,6 +921,9 @@ config("symbols") { ldflags = [ "/DEBUG" ] } else { cflags = [ "-g2" ] + if (use_debug_fission) { + cflags += [ "-gsplit-dwarf" ] + } } } @@ -885,6 +933,9 @@ config("minimal_symbols") { ldflags = [ "/DEBUG" ] } else { cflags = [ "-g1" ] + if (use_debug_fission) { + cflags += [ "-gsplit-dwarf" ] + } } } diff --git a/build/config/crypto.gni b/build/config/crypto.gni index 1837754a0a..20004c3edd 100644 --- a/build/config/crypto.gni +++ b/build/config/crypto.gni @@ -8,9 +8,9 @@ # the global build dependency on it should be removed. declare_args() { - # Use OpenSSL instead of NSS. This is used for Android and NaCl untrusted + # Use OpenSSL instead of NSS. This is used for Android, Mac, and NaCl untrusted # code, and is experimental in other cases (see http://crbug.com/62803). - use_openssl = is_android || is_nacl + use_openssl = is_android || is_mac || is_nacl } # True when we're using OpenSSL for certificate verification and storage. We diff --git a/build/config/features.gni b/build/config/features.gni index dfa964ce58..54b6159cb0 100644 --- a/build/config/features.gni +++ b/build/config/features.gni @@ -19,10 +19,12 @@ declare_args() { # Multicast DNS. enable_mdns = is_win || is_linux - enable_plugins = !is_android || !is_ios + enable_plugins = !is_android && !is_ios # Enables Native Client support. - enable_nacl = (!is_ios && !is_android) + # TODO(GYP) enable this when nacl works in GN. + enable_nacl = false + #enable_nacl = (!is_ios && !is_android) # If debug_devtools is set to true, JavaScript files for DevTools are stored # as is and loaded from disk. Otherwise, a concatenated file is stored in @@ -56,6 +58,8 @@ enable_spellcheck = !is_android enable_pepper_cdms = enable_plugins && (is_linux || is_mac || is_win) +enable_browser_cdms = is_android + # Enable printing support and UI. This variable is used to configure which # parts of printing will be built. 0 disables printing completely, 1 enables it # fully, and 2 enables only the codepath to generate a Metafile (e.g. usually @@ -162,3 +166,8 @@ enable_chromevox_next = false # Use brlapi from brltty for braille display support. use_brlapi = is_chromeos + +# Option controlling the use of GConf (the classic GNOME configuration +# system). +# TODO(GYP) also require !embedded to enable. +use_gconf = is_linux && !is_chromeos diff --git a/build/config/gcc/gcc_version.gni b/build/config/gcc/gcc_version.gni index 86f5093cf5..9b27c90473 100644 --- a/build/config/gcc/gcc_version.gni +++ b/build/config/gcc/gcc_version.gni @@ -2,8 +2,15 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -if (is_android) { - gcc_version = 48 +if (is_clang) { + gcc_version = 0 +} else if (is_android) { + import("//build/config/android/config.gni") + if (is_android_webview_build) { + gcc_version = 48 + } else { + gcc_version = 49 + } } else { gcc_version = exec_script("../../compiler_version.py", [ "host", "compiler" ], "value") } diff --git a/build/config/linux/BUILD.gn b/build/config/linux/BUILD.gn index f26b5101da..3ca2b735f6 100644 --- a/build/config/linux/BUILD.gn +++ b/build/config/linux/BUILD.gn @@ -19,6 +19,12 @@ config("sdk") { sysroot ], "value") ] } + + # Set here because OS_CHROMEOS cannot be autodetected in build_config.h like + # OS_LINUX and the like. + if (is_chromeos) { + defines = [ "OS_CHROMEOS" ] + } } config("fontconfig") { @@ -33,12 +39,6 @@ pkg_config("glib") { packages = [ "glib-2.0", "gmodule-2.0", "gobject-2.0", "gthread-2.0" ] } -pkg_config("gtk") { - # Gtk requires gmodule, but it does not list it as a dependency in some - # misconfigured systems. - packages = [ "gmodule-2.0", "gtk+-2.0", "gthread-2.0" ] -} - pkg_config("pangocairo") { packages = [ "pangocairo" ] } @@ -57,10 +57,6 @@ pkg_config("dbus") { packages = [ "dbus-1" ] } -pkg_config("gnome_keyring") { - packages = [ "gnome-keyring-1" ] -} - if (use_evdev_gestures) { pkg_config("libevdev-cros") { packages = [ "libevdev-cros" ] @@ -120,9 +116,26 @@ config("libresolv") { libs = [ "resolv" ] } -pkg_config("gconf") { - packages = [ "gconf-2.0" ] - defines = [ "USE_GCONF" ] +# CrOS doesn't install GTK, gconf or any gnome packages. +if (!is_chromeos) { + pkg_config("gtk") { + # Gtk requires gmodule, but it does not list it as a dependency in some + # misconfigured systems. + packages = [ "gmodule-2.0", "gtk+-2.0", "gthread-2.0" ] + } + + pkg_config("gtkprint") { + packages = [ "gtk+-unix-print-2.0" ] + } + + pkg_config("gnome_keyring") { + packages = [ "gnome-keyring-1" ] + } + + pkg_config("gconf") { + packages = [ "gconf-2.0" ] + defines = [ "USE_GCONF" ] + } } # If brlapi isn't needed, don't require it to be installed. @@ -138,13 +151,40 @@ if (use_brlapi) { output_cc = "libbrlapi_loader.cc" header = "<brlapi.h>" config = ":brlapi_config" + + functions = [ + "brlapi_getHandleSize", + "brlapi_error_location", + "brlapi_strerror", + "brlapi__acceptKeys", + "brlapi__openConnection", + "brlapi__closeConnection", + "brlapi__getDisplaySize", + "brlapi__enterTtyModeWithPath", + "brlapi__leaveTtyMode", + "brlapi__writeDots", + "brlapi__readKey", + ] } } pkg_config("gio_config") { packages = [ "gio-2.0" ] - defines = [ "USE_GIO" ] - ignore_libs = true # Loader generated below. + # glib >=2.40 deprecate g_settings_list_schemas in favor of + # g_settings_schema_source_list_schemas. This function is not available on + # earlier versions that we still need to support (specifically, 2.32), so + # disable the warning with the GLIB_DISABLE_DEPRECATION_WARNINGS define. + # TODO(mgiuca): Remove this suppression when we drop support for Ubuntu 13.10 + # (saucy) and earlier. Update the code to use + # g_settings_schema_source_list_schemas instead. + defines = [ "USE_GIO", "GLIB_DISABLE_DEPRECATION_WARNINGS" ] + + # TODO(brettw) Theoretically I think ignore_libs should be set so that we + # don't link directly to GIO and use the loader generated below. But the gio + # target in GYP doesn't make any sense to me and appears to link directly to + # GIO in addition to making a loader. This this uncommented, the link in + # component build fails, so I think this is closer to the GYP build. + #ignore_libs = true # Loader generated below. } # This generates a target named "gio". diff --git a/build/config/linux/pkg-config.py b/build/config/linux/pkg-config.py index b107e74f27..60304d47f8 100644 --- a/build/config/linux/pkg-config.py +++ b/build/config/linux/pkg-config.py @@ -101,6 +101,8 @@ def RewritePath(path, strip_prefix, sysroot): parser = OptionParser() +parser.add_option('-p', action='store', dest='pkg_config', type='string', + default='pkg-config') parser.add_option('-v', action='append', dest='strip_out', type='string') parser.add_option('-s', action='store', dest='sysroot', type='string') parser.add_option('-a', action='store', dest='arch', type='string') @@ -120,7 +122,7 @@ else: try: flag_string = subprocess.check_output( - [ "pkg-config", "--cflags", "--libs-only-l", "--libs-only-L" ] + + [ options.pkg_config, "--cflags", "--libs-only-l", "--libs-only-L" ] + args, env=os.environ) # For now just split on spaces to get the args out. This will break if # pkgconfig returns quoted things with spaces in them, but that doesn't seem diff --git a/build/config/linux/pkg_config.gni b/build/config/linux/pkg_config.gni index 46f7d7590e..378863e955 100644 --- a/build/config/linux/pkg_config.gni +++ b/build/config/linux/pkg_config.gni @@ -24,6 +24,15 @@ import("//build/config/sysroot.gni") # when doing manual dynamic linking), set: # ignore_libs = true +declare_args() { + # A pkg-config wrapper to call instead of trying to find and call the right + # pkg-config directly. Wrappers like this are common in cross-compilation + # environments. + # Leaving it blank defaults to searching PATH for 'pkg-config' and relying on + # the sysroot mechanism to find the right .pc files. + pkg_config = "" +} + template("pkg_config") { assert(defined(invoker.packages), "Variable |packages| must be defined to be a list in pkg_config.") @@ -31,6 +40,8 @@ template("pkg_config") { if (sysroot != "") { # Pass the sysroot if we're using one (it requires the CPU arch also). args = ["-s", sysroot, "-a", cpu_arch] + invoker.packages + } else if (pkg_config != "") { + args = ["-p", pkg_config] + invoker.packages } else { args = invoker.packages } diff --git a/build/config/locales.gni b/build/config/locales.gni new file mode 100644 index 0000000000..a628007506 --- /dev/null +++ b/build/config/locales.gni @@ -0,0 +1,118 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Note: keep in sync with below. +locales = [ + "am", + "ar", + "bg", + "bn", + "ca", + "cs", + "da", + "de", + "el", + "en-GB", + "en-US", + "es-419", + "es", + "et", + "fa", + "fi", + "fil", + "fr", + "gu", + "he", + "hi", + "hr", + "hu", + "id", + "it", + "ja", + "kn", + "ko", + "lt", + "lv", + "ml", + "mr", + "ms", + "nb", + "nl", + "pl", + "pt-BR", + "pt-PT", + "ro", + "ru", + "sk", + "sl", + "sr", + "sv", + "sw", + "ta", + "te", + "th", + "tr", + "uk", + "vi", + "zh-CN", + "zh-TW", +] + +# Same as the locales list but in the format Mac expects for output files: +# it uses underscores instead of hyphens, and "en" instead of "en-US". +locales_as_mac_outputs = [ + "am", + "ar", + "bg", + "bn", + "ca", + "cs", + "da", + "de", + "el", + "en_GB", + "en", + "es_419", + "es", + "et", + "fa", + "fi", + "fil", + "fr", + "gu", + "he", + "hi", + "hr", + "hu", + "id", + "it", + "ja", + "kn", + "ko", + "lt", + "lv", + "ml", + "mr", + "ms", + "nb", + "nl", + "pl", + "pt_BR", + "pt_PT", + "ro", + "ru", + "sk", + "sl", + "sr", + "sv", + "sw", + "ta", + "te", + "th", + "tr", + "uk", + "vi", + "zh_CN", + "zh_TW", +] diff --git a/build/config/ui.gni b/build/config/ui.gni index b58d7ed8db..9c159a2e70 100644 --- a/build/config/ui.gni +++ b/build/config/ui.gni @@ -61,3 +61,7 @@ use_ozone_evdev = use_ozone use_glib = is_linux use_clipboard_aurax11 = is_linux && use_aura && use_x11 + +use_athena = false + +enable_hidpi = is_mac || is_chromeos || is_win diff --git a/build/config/win/BUILD.gn b/build/config/win/BUILD.gn index d94dec389d..0f00a1ee5b 100644 --- a/build/config/win/BUILD.gn +++ b/build/config/win/BUILD.gn @@ -11,13 +11,11 @@ config("sdk") { defines = [ "_ATL_NO_OPENGL", - "_WIN32_WINNT=0x0602", "_WINDOWS", "CERT_CHAIN_PARA_HAS_EXTRA_FIELDS", "NTDDI_VERSION=0x06020000", "PSAPI_VERSION=1", "WIN32", - "WINVER=0x0602", ] include_dirs = system_include_dirs @@ -33,6 +31,15 @@ config("sdk") { } } +# Sets the default Windows build version. This is separated because some +# targets need to manually override it for their compiles. +config("winver") { + defines = [ + "_WIN32_WINNT=0x0602", + "WINVER=0x0602", + ] +} + # Linker flags for Windows SDK setup, this is applied only to EXEs and DLLs. config("sdk_link") { if (cpu_arch == "x64") { diff --git a/build/get_landmines.py b/build/get_landmines.py index 3aac6e760b..69564581a7 100755 --- a/build/get_landmines.py +++ b/build/get_landmines.py @@ -28,7 +28,7 @@ def print_landmines(): builder() == 'ninja'): print 'Need to clobber winja goma due to backend cwd cache fix.' if platform() == 'android': - print 'Clobber: To delete generated class files (we just use jars now).' + print 'Clobber: To delete generated mojo class files.' if platform() == 'win' and builder() == 'ninja': print 'Compile on cc_unittests fails due to symbols removed in r185063.' if platform() == 'linux' and builder() == 'ninja': @@ -55,6 +55,7 @@ def print_landmines(): print 'Need to clobber everything due to build_nexe change in nacl r13424' print '[chromium-dev] PSA: clobber build needed for IDR_INSPECTOR_* compil...' print 'blink_resources.grd changed: crbug.com/400860' + print 'ninja dependency cycle: crbug.com/408192' def main(): diff --git a/build/get_syzygy_binaries.py b/build/get_syzygy_binaries.py index 05e8072d3d..79a186d688 100755 --- a/build/get_syzygy_binaries.py +++ b/build/get_syzygy_binaries.py @@ -358,17 +358,53 @@ def _ParseCommandLine(): return options -def main(): - # We only care about Windows platforms, as the Syzygy binaries aren't used - # elsewhere. - if sys.platform not in ('win32', 'cygwin'): +def _RemoveOrphanedFiles(options): + """This is run on non-Windows systems to remove orphaned files that may have + been downloaded by a previous version of this script. + """ + # Reconfigure logging to output info messages. This will allow inspection of + # cleanup status on non-Windows buildbots. + _LOGGER.setLevel(logging.INFO) + + output_dir = os.path.abspath(options.output_dir) + + # We only want to clean up the folder in 'src/third_party/syzygy', and we + # expect to be called with that as an output directory. This is an attempt to + # not start deleting random things if the script is run from an alternate + # location, or not called from the gclient hooks. + expected_syzygy_dir = os.path.abspath(os.path.join( + os.path.dirname(__file__), '..', 'third_party', 'syzygy')) + expected_output_dir = os.path.join(expected_syzygy_dir, 'binaries') + if expected_output_dir != output_dir: + _LOGGER.info('Unexpected output directory, skipping cleanup.') return + if not os.path.isdir(expected_syzygy_dir): + _LOGGER.info('Output directory does not exist, skipping cleanup.') + return + + def OnError(function, path, excinfo): + """Logs error encountered by shutil.rmtree.""" + _LOGGER.error('Error when running %s(%s)', function, path, exc_info=excinfo) + + _LOGGER.info('Removing orphaned files from %s', expected_syzygy_dir) + if not options.dry_run: + shutil.rmtree(expected_syzygy_dir, True, OnError) + + +def main(): options = _ParseCommandLine() if options.dry_run: _LOGGER.debug('Performing a dry-run.') + # We only care about Windows platforms, as the Syzygy binaries aren't used + # elsewhere. However, there was a short period of time where this script + # wasn't gated on OS types, and those OSes downloaded and installed binaries. + # This will cleanup orphaned files on those operating systems. + if sys.platform not in ('win32', 'cygwin'): + return _RemoveOrphanedFiles(options) + # Load the current installation state, and validate it against the # requested installation. state, is_consistent = _GetCurrentState(options.revision, options.output_dir) diff --git a/build/go/go.py b/build/go/go.py new file mode 100755 index 0000000000..2e4f99bc37 --- /dev/null +++ b/build/go/go.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# Copyright (c) 2012 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +This script invokes the go build tool. +Must be called as follows: +python go.py <go-binary> <build directory> <output file> <src directory> +<CGO_CFLAGS> <CGO_LDFLAGS> <go-binary options> +eg. +python go.py /usr/lib/google-golang/bin/go out/build out/a.out .. "-I." +"-L. -ltest" test -c test/test.go +""" + +import argparse +import os +import shutil +import sys + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('go_binary') + parser.add_argument('build_directory') + parser.add_argument('output_file') + parser.add_argument('src_root') + parser.add_argument('cgo_cflags') + parser.add_argument('cgo_ldflags') + parser.add_argument('go_option', nargs='*') + args = parser.parse_args() + go_binary = args.go_binary + build_dir = args.build_directory + out_file = os.path.abspath(args.output_file) + # The src directory specified is relative. We need this as an absolute path. + src_root = os.path.abspath(args.src_root) + # GOPATH must be absolute, and point to one directory up from |src_Root| + go_path = os.path.abspath(os.path.join(src_root, "..")) + go_options = args.go_option + try: + shutil.rmtree(build_dir, True) + os.mkdir(build_dir) + except: + pass + old_directory = os.getcwd() + os.chdir(build_dir) + os.environ["GOPATH"] = go_path + os.environ["CGO_CFLAGS"] = args.cgo_cflags + os.environ["CGO_LDFLAGS"] = args.cgo_ldflags + os.system("%s %s" % (go_binary, " ".join(go_options))) + out_files = [ f for f in os.listdir(".") if os.path.isfile(f)] + if (len(out_files) > 0): + shutil.move(out_files[0], out_file) + os.chdir(old_directory) + try: + shutil.rmtree(build_dir, True) + except: + pass + +if __name__ == '__main__': + sys.exit(main()) diff --git a/build/go/rules.gni b/build/go/rules.gni new file mode 100644 index 0000000000..ab703d6c96 --- /dev/null +++ b/build/go/rules.gni @@ -0,0 +1,62 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +declare_args() { + # By default, there is no go build tool, because go builds are not supported. + go_build_tool = "" +} + +# Declare a go test binary target. +# +# The target generates a go test executable, linking against other C code, +# which is compiled into a static library and linked against Go. +# +# Only works on linux. |go_build_tool| must be set to the absolute path +# of the go build tool. +# +# Variables (all required) +# sources: list of .go files to compile +# static_library_sources: list of C sources needed for the static library +# deps: dependencies for the static library + +template("go_test_binary") { + # Only available on linux for now. + assert(is_linux) + assert(defined(invoker.sources)) + assert(go_build_tool != "") + + static_library_name = target_name + "_static_library" + + static_library(static_library_name) { + sources = invoker.static_library_sources + deps = invoker.deps + complete_static_lib = true + } + + action(target_name) { + deps = [ + ":$static_library_name", + ] + script = "//build/go/go.py" + outputs = [ "${target_out_dir}/${target_name}" ] + # Since go test does not permit specifying an output directory or output + # binary name, we create a temporary build directory, and the python + # script will later identify the output, copy it to the target location, + # and clean up the temporary build directory. + build_dir = "${target_out_dir}/${target_name}_build" + args = [ + "--", + "${go_build_tool}", + rebase_path(build_dir, root_build_dir), + rebase_path(target_out_dir, root_build_dir) + "/${target_name}", + rebase_path("//", root_build_dir), + "-I" + rebase_path("//"), + " -L" + rebase_path(target_out_dir) + + " -L" + rebase_path(root_build_dir + "/obj/third_party/libevent") + + " -l" + static_library_name + + " -lstdc++ -lpthread -lm -lglib-2.0 -levent", + "test", "-c", + ] + rebase_path(invoker.sources, build_dir) + } +} diff --git a/build/gyp_chromium b/build/gyp_chromium index b8fe82dc5c..326919c08c 100755 --- a/build/gyp_chromium +++ b/build/gyp_chromium @@ -27,6 +27,7 @@ import gyp SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Add paths so that pymod_do_main(...) can import files. +sys.path.insert(1, os.path.join(chrome_src, 'build', 'android', 'gyp')) sys.path.insert(1, os.path.join(chrome_src, 'tools')) sys.path.insert(1, os.path.join(chrome_src, 'tools', 'generate_shim_headers')) sys.path.insert(1, os.path.join(chrome_src, 'tools', 'grit')) diff --git a/build/host_jar.gypi b/build/host_jar.gypi new file mode 100644 index 0000000000..6ccc1bdbad --- /dev/null +++ b/build/host_jar.gypi @@ -0,0 +1,102 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This file is meant to be included into a target to provide a rule to build +# a JAR file for use on a host in a consistent manner. +# +# To use this, create a gyp target with the following form: +# { +# 'target_name': 'my_jar', +# 'type': 'none', +# 'variables': { +# 'src_paths': [ +# 'path/to/directory', +# 'path/to/other/directory', +# 'path/to/individual_file.java', +# ... +# ], +# }, +# 'includes': [ 'path/to/this/gypi/file' ], +# } +# +# Required variables: +# src_paths - A list of all paths containing java files that should be +# included in the jar. Paths can be either directories or files. +# Optional/automatic variables: +# excluded_src_paths - A list of all paths that should be excluded from +# the jar. +# generated_src_dirs - Directories containing additional .java files +# generated at build time. +# input_jars_paths - A list of paths to the jars that should be included +# in the classpath. +# main_class - The class containing the main() function that should be called +# when running the jar file. +# jar_excluded_classes - A list of .class files that should be excluded +# from the jar. + +{ + 'dependencies': [ + '<(DEPTH)/build/android/setup.gyp:build_output_dirs', + ], + 'variables': { + 'classes_dir': '<(intermediate_dir)/classes', + 'excluded_src_paths': [], + 'generated_src_dirs': [], + 'input_jars_paths': [], + 'intermediate_dir': '<(SHARED_INTERMEDIATE_DIR)/<(_target_name)', + 'jar_dir': '<(PRODUCT_DIR)/lib.java', + 'jar_excluded_classes': [], + 'jar_name': '<(_target_name).jar', + 'jar_path': '<(jar_dir)/<(jar_name)', + 'main_class%': '', + 'stamp': '<(intermediate_dir)/jar.stamp', + }, + 'all_dependent_settings': { + 'variables': { + 'input_jars_paths': ['<(jar_path)'] + }, + }, + 'actions': [ + { + 'action_name': 'javac_<(_target_name)', + 'message': 'Compiling <(_target_name) java sources', + 'variables': { + 'extra_options': [], + 'java_sources': [ '<!@(find <@(src_paths) -name "*.java")' ], + 'conditions': [ + ['"<(excluded_src_paths)" != ""', { + 'java_sources!': ['<!@(find <@(excluded_src_paths) -name "*.java")'] + }], + ['"<(jar_excluded_classes)" != ""', { + 'extra_options': ['--excluded-classes=<(jar_excluded_classes)'] + }], + ['">(main_class)" != ""', { + 'extra_options': ['--main-class=>(main_class)'] + }] + ], + }, + 'inputs': [ + '<(DEPTH)/build/android/gyp/util/build_utils.py', + '<(DEPTH)/build/android/gyp/javac.py', + '^@(java_sources)', + '>@(input_jars_paths)', + ], + 'outputs': [ + '<(jar_path)', + '<(stamp)', + ], + 'action': [ + 'python', '<(DEPTH)/build/android/gyp/javac.py', + '--classpath=>(input_jars_paths)', + '--src-gendirs=>(generated_src_dirs)', + '--chromium-code=<(chromium_code)', + '--stamp=<(stamp)', + '--jar-path=<(jar_path)', + '<@(extra_options)', + '^@(java_sources)', + ], + }, + ] +} + diff --git a/build/host_prebuilt_jar.gypi b/build/host_prebuilt_jar.gypi new file mode 100644 index 0000000000..feed5caebb --- /dev/null +++ b/build/host_prebuilt_jar.gypi @@ -0,0 +1,50 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This file is meant to be included into a target to provide a rule to +# copy a prebuilt JAR for use on a host to the output directory. +# +# To use this, create a gyp target with the following form: +# { +# 'target_name': 'my_prebuilt_jar', +# 'type': 'none', +# 'variables': { +# 'jar_path': 'path/to/prebuilt.jar', +# }, +# 'includes': [ 'path/to/this/gypi/file' ], +# } +# +# Required variables: +# jar_path - The path to the prebuilt jar. + +{ + 'dependencies': [ + ], + 'variables': { + 'dest_path': '<(PRODUCT_DIR)/lib.java/<(_target_name).jar', + 'src_path': '<(jar_path)', + }, + 'all_dependent_settings': { + 'variables': { + 'input_jars_paths': [ + '<(dest_path)', + ] + }, + }, + 'actions': [ + { + 'action_name': 'copy_prebuilt_jar', + 'message': 'Copy <(src_path) to <(dest_path)', + 'inputs': [ + '<(src_path)', + ], + 'outputs': [ + '<(dest_path)', + ], + 'action': [ + 'python', '<(DEPTH)/build/cp.py', '<(src_path)', '<(dest_path)', + ], + } + ] +} diff --git a/build/install-build-deps-android.sh b/build/install-build-deps-android.sh index f5d288a726..e7409103de 100755 --- a/build/install-build-deps-android.sh +++ b/build/install-build-deps-android.sh @@ -19,7 +19,7 @@ fi # Install first the default Linux build deps. "$(dirname "${BASH_SOURCE[0]}")/install-build-deps.sh" \ - --no-syms --no-arm --no-chromeos-fonts --no-nacl --no-prompt + --no-syms --no-arm --no-chromeos-fonts --no-nacl --no-prompt "$@" # The temporary directory used to store output of update-java-alternatives TEMPDIR=$(mktemp -d) diff --git a/build/install-build-deps.sh b/build/install-build-deps.sh index a15edef94c..a0f11db7e1 100755 --- a/build/install-build-deps.sh +++ b/build/install-build-deps.sh @@ -94,8 +94,8 @@ fi chromeos_dev_list="libbluetooth-dev libxkbcommon-dev" # Packages needed for development -dev_list="apache2.2-bin bison curl dpkg-dev elfutils devscripts fakeroot flex - fonts-thai-tlwg g++ git-core git-svn gperf language-pack-da +dev_list="apache2.2-bin bison cdbs curl dpkg-dev elfutils devscripts fakeroot + flex fonts-thai-tlwg g++ git-core git-svn gperf language-pack-da language-pack-fr language-pack-he language-pack-zh-hant libapache2-mod-php5 libasound2-dev libbrlapi-dev libav-tools libbz2-dev libcairo2-dev libcap-dev libcups2-dev libcurl4-gnutls-dev @@ -105,9 +105,10 @@ dev_list="apache2.2-bin bison curl dpkg-dev elfutils devscripts fakeroot flex libpulse-dev libsctp-dev libspeechd-dev libsqlite3-dev libssl-dev libudev-dev libwww-perl libxslt1-dev libxss-dev libxt-dev libxtst-dev mesa-common-dev openbox patch perl php5-cgi pkg-config python - python-cherrypy3 python-dev python-psutil rpm ruby subversion - ttf-dejavu-core ttf-indic-fonts ttf-kochi-gothic ttf-kochi-mincho - wdiff xfonts-mathml zip $chromeos_dev_list" + python-cherrypy3 python-crypto python-dev python-openssl + python-psutil rpm ruby subversion ttf-dejavu-core ttf-indic-fonts + ttf-kochi-gothic ttf-kochi-mincho wdiff xfonts-mathml zip + $chromeos_dev_list" # 64-bit systems need a minimum set of 32-bit compat packages for the pre-built # NaCl binaries. @@ -139,23 +140,26 @@ dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg libfontconfig1-dbg # arm cross toolchain packages needed to build chrome on armhf arm_list="libc6-dev-armhf-cross linux-libc-dev-armhf-cross - g++-arm-linux-gnueabihf" + g++-arm-linux-gnueabihf + linux-libc-dev:i386" # Packages to build NaCl, its toolchains, and its ports. -nacl_list="autoconf bison cmake g++-mingw-w64-i686 gawk lib32z1-dev +naclports_list="ant autoconf bison cmake gawk intltool xutils-dev xsltproc" +nacl_list="g++-mingw-w64-i686 lib32z1-dev libasound2:i386 libcap2:i386 libelf-dev:i386 libexif12:i386 libfontconfig1:i386 libgconf-2-4:i386 libglib2.0-0:i386 libgpm2:i386 libgtk2.0-0:i386 libncurses5:i386 lib32ncurses5-dev - libnss3:i386 libpango1.0-0:i386 xsltproc ant + libnss3:i386 libpango1.0-0:i386 libssl0.9.8:i386 libtinfo-dev libtinfo-dev:i386 libtool libxcomposite1:i386 libxcursor1:i386 libxdamage1:i386 libxi6:i386 - libxrandr2:i386 libxss1:i386 libxtst6:i386 texinfo xvfb" + libxrandr2:i386 libxss1:i386 libxtst6:i386 texinfo xvfb + ${naclports_list}" # Find the proper version of libgbm-dev. We can't just install libgbm-dev as # it depends on mesa, and only one version of mesa can exists on the system. # Hence we must match the same version or this entire script will fail. mesa_variant="" -for variant in "-lts-quantal" "-lts-raring" "-lts-saucy"; do +for variant in "-lts-quantal" "-lts-raring" "-lts-saucy" "-lts-trusty"; do if $(dpkg-query -Wf'${Status}' libgl1-mesa-glx${variant} | \ grep -q " ok installed"); then mesa_variant="${variant}" diff --git a/build/ios/grit_whitelist.txt b/build/ios/grit_whitelist.txt index 32c8ca7773..63df8969d3 100644 --- a/build/ios/grit_whitelist.txt +++ b/build/ios/grit_whitelist.txt @@ -613,6 +613,7 @@ IDS_LIBADDRESSINPUT_MISSING_REQUIRED_POSTAL_CODE_EXAMPLE_AND_URL IDS_LIBADDRESSINPUT_MISSING_REQUIRED_ZIP_CODE_EXAMPLE IDS_LIBADDRESSINPUT_MISSING_REQUIRED_ZIP_CODE_EXAMPLE_AND_URL IDS_LIBADDRESSINPUT_OBLAST +IDS_LIBADDRESSINPUT_ORGANIZATION_LABEL IDS_LIBADDRESSINPUT_PARISH IDS_LIBADDRESSINPUT_POSTAL_CODE_LABEL IDS_LIBADDRESSINPUT_PO_BOX_FORBIDDEN_VALUE diff --git a/build/ios/mac_build.gypi b/build/ios/mac_build.gypi index cbdbc79d17..4da21eb253 100644 --- a/build/ios/mac_build.gypi +++ b/build/ios/mac_build.gypi @@ -67,8 +67,6 @@ '-Goutput_dir=xcodebuild/<(ninja_output_dir)', # nacl isn't in the iOS checkout, make sure it's turned off '-Ddisable_nacl=1', - # Add a variable to handle specific cases for mac_build. - '-Dios_mac_build=1', # Pass through the Mac SDK version. '-Dmac_sdk=<(mac_sdk)', '-Dparent_generator=<(parent_generator)' diff --git a/build/isolate.gypi b/build/isolate.gypi index b0b2ca0567..5217c311fc 100644 --- a/build/isolate.gypi +++ b/build/isolate.gypi @@ -63,14 +63,12 @@ # the switch-over to running tests on Swarm is completed. #'<@(isolate_dependency_tracked)', ], - 'outputs': [ - '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).isolated', - ], + 'outputs': [], 'action': [ 'python', '<(DEPTH)/tools/isolate_driver.py', '<(test_isolation_mode)', - '--isolated', '<@(_outputs)', + '--isolated', '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).isolated', '--isolate', '<(RULE_INPUT_PATH)', # Variables should use the -V FOO=<(FOO) form so frequent values, @@ -91,6 +89,7 @@ '--config-variable', 'OS=<(OS)', '--config-variable', 'CONFIGURATION_NAME=<(CONFIGURATION_NAME)', + '--config-variable', 'asan=<(asan)', '--config-variable', 'chromeos=<(chromeos)', '--config-variable', 'component=<(component)', '--config-variable', 'fastbuild=<(fastbuild)', @@ -102,6 +101,7 @@ '--config-variable', 'libpeer_target_type=<(libpeer_target_type)', '--config-variable', 'use_openssl=<(use_openssl)', '--config-variable', 'target_arch=<(target_arch)', + '--config-variable', 'use_ozone=<(use_ozone)', ], 'conditions': [ # Note: When gyp merges lists, it appends them to the old value. @@ -118,6 +118,15 @@ ['test_isolation_fail_on_missing == 0', { 'action': ['--ignore_broken_items'], }], + ["test_isolation_mode == 'prepare'", { + 'outputs': [ + '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).isolated.gen.json', + ], + }, { + 'outputs': [ + '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).isolated', + ], + }], ], }, ], diff --git a/build/java_aidl.gypi b/build/java_aidl.gypi index 3c6f8e435c..8f111fdc6d 100644 --- a/build/java_aidl.gypi +++ b/build/java_aidl.gypi @@ -49,7 +49,7 @@ ['aidl_import_include != ""', { 'variables': { 'additional_aidl_arguments': [ '-I<(aidl_import_include)' ], - 'additional_aidl_input_paths': [ '<!@(find <(aidl_import_include) -name "*.java")', ] + 'additional_aidl_input_paths': [ '<!@(find <(aidl_import_include) -name "*.java" | sort)' ], } }], ], diff --git a/build/java_apk.gypi b/build/java_apk.gypi index 08529fa367..2c9f4a595b 100644 --- a/build/java_apk.gypi +++ b/build/java_apk.gypi @@ -56,6 +56,9 @@ # code. This allows a test APK to inject a Linker.TestRunner instance at # runtime. Should only be used by the chromium_linker_test_apk target!! # never_lint - Set to 1 to not run lint on this target. +# java_in_dir_suffix - To override the /src suffix on java_in_dir. +# app_manifest_version_name - set the apps 'human readable' version number. +# app_manifest_version_code - set the apps version number. { 'variables': { 'tested_apk_obfuscated_jar_path%': '/', @@ -99,6 +102,7 @@ 'lint_result': '<(intermediate_dir)/lint_result.xml', 'lint_config': '<(intermediate_dir)/lint_config.xml', 'never_lint%': 0, + 'java_in_dir_suffix%': '/src', 'instr_stamp': '<(intermediate_dir)/instr.stamp', 'jar_stamp': '<(intermediate_dir)/jar.stamp', 'obfuscate_stamp': '<(intermediate_dir)/obfuscate.stamp', @@ -169,6 +173,8 @@ 'unsigned_standalone_apk_path': '<(unsigned_standalone_apk_path)', 'libchromium_android_linker': 'libchromium_android_linker.>(android_product_extension)', 'extra_native_libs': [], + 'native_lib_placeholder_stamp': '<(apk_package_native_libs_dir)/<(android_app_abi)/native_lib_placeholder.stamp', + 'native_lib_placeholders': [], }, # Pass the jar path to the apk's "fake" jar target. This would be better as # direct_dependent_settings, but a variable set by a direct_dependent_settings @@ -198,7 +204,7 @@ # We generate R.java in package R_package (in addition to the package # listed in the AndroidManifest.xml, which is unavoidable). 'additional_res_packages': ['<(R_package)'], - 'additional_R_text_files': ['<(PRODUCT_DIR)/<(package_name)/R.txt'], + 'additional_R_text_files': ['<(intermediate_dir)/R.txt'], }, }], ['native_lib_target != "" and component == "shared_library"', { @@ -380,15 +386,35 @@ }, 'includes': ['../build/android/strip_native_libraries.gypi'], }, + { + 'action_name': 'Create native lib placeholder files for previous releases', + 'variables': { + 'placeholders': ['<@(native_lib_placeholders)'], + 'conditions': [ + ['gyp_managed_install == 1', { + # This "library" just needs to be put in the .apk. It is not loaded + # at runtime. + 'placeholders': ['libfix.crbug.384638.so'], + }] + ], + }, + 'inputs': [ + '<(DEPTH)/build/android/gyp/create_placeholder_files.py', + ], + 'outputs': [ + '<(native_lib_placeholder_stamp)', + ], + 'action': [ + 'python', '<(DEPTH)/build/android/gyp/create_placeholder_files.py', + '--dest-lib-dir=<(apk_package_native_libs_dir)/<(android_app_abi)/', + '--stamp=<(native_lib_placeholder_stamp)', + '<@(placeholders)', + ], + }, ], 'conditions': [ ['gyp_managed_install == 1', { 'variables': { - # This "library" just needs to be put in the .apk. It is not loaded - # at runtime. - 'placeholder_native_library_path': - '<(apk_package_native_libs_dir)/<(android_app_abi)/libfix.crbug.384638.so', - 'package_input_paths': [ '<(placeholder_native_library_path)' ], 'libraries_top_dir': '<(intermediate_dir)/lib.stripped', 'libraries_source_dir': '<(libraries_top_dir)/lib/<(android_app_abi)', 'device_library_dir': '<(device_intermediate_dir)/lib.stripped', @@ -402,19 +428,6 @@ 'includes': ['../build/android/push_libraries.gypi'], }, { - 'action_name': 'create placeholder lib', - 'inputs': [ - '<(DEPTH)/build/android/gyp/touch.py', - ], - 'outputs': [ - '<(placeholder_native_library_path)', - ], - 'action' : [ - 'python', '<(DEPTH)/build/android/gyp/touch.py', - '<@(_outputs)', - ], - }, - { 'action_name': 'create device library symlinks', 'message': 'Creating links on device for <(_target_name)', 'inputs': [ @@ -605,7 +618,7 @@ # Java files instead of using find. (As is, this will be broken if two # targets use the same java_in_dir and both use java_apk.gypi or # both use java.gypi.) - 'java_sources': ['>!@(find >(java_in_dir)/src >(additional_src_dirs) -name "*.java" # apk)'], + 'java_sources': ['>!@(find >(java_in_dir)>(java_in_dir_suffix) >(additional_src_dirs) -name "*.java" # apk)'], }, 'inputs': [ @@ -657,7 +670,7 @@ { 'variables': { 'src_dirs': [ - '<(java_in_dir)/src', + '<(java_in_dir)<(java_in_dir_suffix)', '>@(additional_src_dirs)', ], 'lint_jar_path': '<(jar_path)', @@ -863,6 +876,11 @@ 'outputs': [ '<(unsigned_apk_path)', ], + 'conditions': [ + ['native_lib_target != ""', { + 'inputs': ['<(native_lib_placeholder_stamp)'], + }], + ], 'action': [ 'python', '<(DEPTH)/build/android/gyp/ant.py', '--', diff --git a/build/json_schema_bundle_compile.gypi b/build/json_schema_bundle_compile.gypi index 7e712d7df4..a3020136d3 100644 --- a/build/json_schema_bundle_compile.gypi +++ b/build/json_schema_bundle_compile.gypi @@ -7,6 +7,11 @@ # When including this gypi, the following variables must be set: # schema_files: # An array of json or idl files that comprise the api model. + # schema_include_rules (optional): + # An array of paths to include when searching for referenced objects, + # with the namespace separated by a :. + # Example: + # [ '/foo/bar:Foo::Bar::%(namespace)s' ] # cc_dir: # The directory to put the generated code in. # root_namespace: @@ -19,30 +24,30 @@ # chrome/browser/extensions/api and can be overridden by setting "impl_dir". 'api_gen_dir': '<(DEPTH)/tools/json_schema_compiler', 'api_gen': '<(api_gen_dir)/compiler.py', - 'impl_dir%': 'chrome/browser/extensions/api', + 'generator_files': [ + '<(api_gen_dir)/cc_generator.py', + '<(api_gen_dir)/code.py', + '<(api_gen_dir)/compiler.py', + '<(api_gen_dir)/cpp_bundle_generator.py', + '<(api_gen_dir)/cpp_type_generator.py', + '<(api_gen_dir)/cpp_util.py', + '<(api_gen_dir)/h_generator.py', + '<(api_gen_dir)/idl_schema.py', + '<(api_gen_dir)/json_schema.py', + '<(api_gen_dir)/model.py', + '<(api_gen_dir)/util_cc_helper.py', + ], + 'schema_include_rules': [], }, 'actions': [ { - # GN version: //extensions/generated_extensions_api.gni - 'action_name': 'genapi_bundle', + 'action_name': 'genapi_bundle_schema', 'inputs': [ - '<(api_gen_dir)/cc_generator.py', - '<(api_gen_dir)/code.py', - '<(api_gen_dir)/compiler.py', - '<(api_gen_dir)/cpp_bundle_generator.py', - '<(api_gen_dir)/cpp_type_generator.py', - '<(api_gen_dir)/cpp_util.py', - '<(api_gen_dir)/h_generator.py', - '<(api_gen_dir)/idl_schema.py', - '<(api_gen_dir)/json_schema.py', - '<(api_gen_dir)/model.py', - '<(api_gen_dir)/util_cc_helper.py', + '<@(generator_files)', '<@(schema_files)', '<@(non_compiled_schema_files)', ], 'outputs': [ - '<(SHARED_INTERMEDIATE_DIR)/<(cc_dir)/generated_api.h', - '<(SHARED_INTERMEDIATE_DIR)/<(cc_dir)/generated_api.cc', '<(SHARED_INTERMEDIATE_DIR)/<(cc_dir)/generated_schemas.h', '<(SHARED_INTERMEDIATE_DIR)/<(cc_dir)/generated_schemas.cc', ], @@ -52,14 +57,16 @@ '--root=<(DEPTH)', '--destdir=<(SHARED_INTERMEDIATE_DIR)', '--namespace=<(root_namespace)', - '--generator=cpp-bundle', - '--impl-dir=<(impl_dir)', + '--generator=cpp-bundle-schema', + '--include-rules=<(schema_include_rules)', '<@(schema_files)', '<@(non_compiled_schema_files)', ], - 'message': 'Generating C++ API bundle code', + 'message': 'Generating C++ API bundle code for schemas', 'process_outputs_as_sources': 1, - } + # Avoid running MIDL compiler on IDL input files. + 'explicit_idl_action': 1, + }, ], 'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)', diff --git a/build/json_schema_bundle_registration_compile.gypi b/build/json_schema_bundle_registration_compile.gypi new file mode 100644 index 0000000000..5a013bcf70 --- /dev/null +++ b/build/json_schema_bundle_registration_compile.gypi @@ -0,0 +1,78 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'variables': { + # When including this gypi, the following variables must be set: + # schema_files: + # An array of json or idl files that comprise the api model. + # impl_dir_: + # The root path of API implementations; also used for the + # output location. (N.B. Named as such to prevent gyp from + # expanding it as a relative path.) + # root_namespace: + # A Python string substituion pattern used to generate the C++ + # namespace for each API. Use %(namespace)s to replace with the API + # namespace, like "toplevel::%(namespace)s_api". + # + # Functions and namespaces can be excluded by setting "nocompile" to true. + 'api_gen_dir': '<(DEPTH)/tools/json_schema_compiler', + 'api_gen': '<(api_gen_dir)/compiler.py', + 'generator_files': [ + '<(api_gen_dir)/cc_generator.py', + '<(api_gen_dir)/code.py', + '<(api_gen_dir)/compiler.py', + '<(api_gen_dir)/cpp_bundle_generator.py', + '<(api_gen_dir)/cpp_type_generator.py', + '<(api_gen_dir)/cpp_util.py', + '<(api_gen_dir)/h_generator.py', + '<(api_gen_dir)/idl_schema.py', + '<(api_gen_dir)/json_schema.py', + '<(api_gen_dir)/model.py', + '<(api_gen_dir)/util_cc_helper.py', + ], + }, + 'actions': [ + { + # GN version: //extensions/generated_extensions_api.gni + 'action_name': 'genapi_bundle_registration', + 'inputs': [ + '<@(generator_files)', + '<@(schema_files)', + '<@(non_compiled_schema_files)', + ], + 'outputs': [ + '<(SHARED_INTERMEDIATE_DIR)/<(impl_dir_)/generated_api_registration.h', + '<(SHARED_INTERMEDIATE_DIR)/<(impl_dir_)/generated_api_registration.cc', + ], + 'action': [ + 'python', + '<(api_gen)', + '--root=<(DEPTH)', + '--destdir=<(SHARED_INTERMEDIATE_DIR)', + '--namespace=<(root_namespace)', + '--generator=cpp-bundle-registration', + '--impl-dir=<(impl_dir_)', + '<@(schema_files)', + '<@(non_compiled_schema_files)', + ], + 'message': 'Generating C++ API bundle code for function registration', + 'process_outputs_as_sources': 1, + # Avoid running MIDL compiler on IDL input files. + 'explicit_idl_action': 1, + }, + ], + 'include_dirs': [ + '<(SHARED_INTERMEDIATE_DIR)', + '<(DEPTH)', + ], + 'direct_dependent_settings': { + 'include_dirs': [ + '<(SHARED_INTERMEDIATE_DIR)', + ] + }, + # This target exports a hard dependency because it generates header + # files. + 'hard_dependency': 1, +} diff --git a/build/json_schema_compile.gypi b/build/json_schema_compile.gypi index d164748508..9952e205f8 100644 --- a/build/json_schema_compile.gypi +++ b/build/json_schema_compile.gypi @@ -7,6 +7,11 @@ # When including this gypi, the following variables must be set: # schema_files: # An array of json or idl files that comprise the api model. + # schema_include_rules (optional): + # An array of paths to include when searching for referenced objects, + # with the namespace separated by a :. + # Example: + # [ '/foo/bar:Foo::Bar::%(namespace)s' ] # cc_dir: # The directory to put the generated code in. # root_namespace: @@ -15,11 +20,9 @@ # namespace, like "toplevel::%(namespace)s_api". # # Functions and namespaces can be excluded by setting "nocompile" to true. - # The default root path of API implementation sources is - # chrome/browser/extensions/api and can be overridden by setting "impl_dir". 'api_gen_dir': '<(DEPTH)/tools/json_schema_compiler', 'api_gen': '<(api_gen_dir)/compiler.py', - 'impl_dir%': 'chrome/browser/extensions/api', + 'schema_include_rules': [], }, 'rules': [ { @@ -57,7 +60,7 @@ '--destdir=<(SHARED_INTERMEDIATE_DIR)', '--namespace=<(root_namespace)', '--generator=cpp', - '--impl-dir=<(impl_dir)' + '--include-rules=<(schema_include_rules)' ], 'message': 'Generating C++ code from <(RULE_INPUT_PATH) json files', 'process_outputs_as_sources': 1, @@ -96,7 +99,7 @@ '--destdir=<(SHARED_INTERMEDIATE_DIR)', '--namespace=<(root_namespace)', '--generator=cpp', - '--impl-dir=<(impl_dir)' + '--include-rules=<(schema_include_rules)' ], 'message': 'Generating C++ code from <(RULE_INPUT_PATH) IDL files', 'process_outputs_as_sources': 1, diff --git a/build/landmines.py b/build/landmines.py index b62e75851c..a03486499b 100755 --- a/build/landmines.py +++ b/build/landmines.py @@ -5,7 +5,8 @@ """ This script runs every build as the first hook (See DEPS). If it detects that -the build should be clobbered, it will remove the build directory. +the build should be clobbered, it will delete the contents of the build +directory. A landmine is tripped when a builder checks out a different revision, and the diff between the new landmines and the old ones is non-null. At this point, the @@ -44,8 +45,6 @@ def get_build_dir(build_tool, is_iphone=False): ret = os.path.join(SRC_DIR, 'xcodebuild') elif build_tool in ['make', 'ninja', 'ninja-ios']: # TODO: Remove ninja-ios. ret = os.path.join(SRC_DIR, os.environ.get('CHROMIUM_OUT_DIR', 'out')) - elif build_tool in ['msvs', 'vs', 'ib']: - ret = os.path.join(SRC_DIR, 'build') else: raise NotImplementedError('Unexpected GYP_GENERATORS (%s)' % build_tool) return os.path.abspath(ret) @@ -72,8 +71,14 @@ def clobber_if_necessary(new_landmines): sys.stdout.write('Clobbering due to:\n') sys.stdout.writelines(diff) - # Clobber. - shutil.rmtree(out_dir) + # Clobber contents of build directory but not directory itself: some + # checkouts have the build directory mounted. + for f in os.listdir(out_dir): + path = os.path.join(out_dir, f) + if os.path.isfile(path): + os.unlink(path) + elif os.path.isdir(path): + shutil.rmtree(path) # Save current set of landmines for next time. with open(landmines_path, 'w') as f: diff --git a/build/linux/system.gyp b/build/linux/system.gyp index d33bdf420f..8f9b2d8219 100644 --- a/build/linux/system.gyp +++ b/build/linux/system.gyp @@ -413,6 +413,9 @@ ], }, 'link_settings': { + 'ldflags': [ + '<!@(<(pkg-config) --libs-only-L --libs-only-other gbm)', + ], 'libraries': [ '<!@(<(pkg-config) --libs-only-l gbm)', ], @@ -567,12 +570,28 @@ 'cflags': [ '<!@(<(pkg-config) --cflags gio-2.0)', ], + 'variables': { + 'gio_warning_define': [ + # glib >=2.40 deprecate g_settings_list_schemas in favor of + # g_settings_schema_source_list_schemas. This function is not + # available on earlier versions that we still need to support + # (specifically, 2.32), so disable the warning. + # TODO(mgiuca): Remove this suppression (and variable) when we + # drop support for Ubuntu 13.10 (saucy) and earlier. Update the + # code to use g_settings_schema_source_list_schemas instead. + 'GLIB_DISABLE_DEPRECATION_WARNINGS', + ], + }, + 'defines': [ + '<(gio_warning_define)', + ], 'direct_dependent_settings': { 'cflags': [ '<!@(<(pkg-config) --cflags gio-2.0)', ], 'defines': [ 'USE_GIO', + '<(gio_warning_define)', ], 'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)', diff --git a/build/linux/unbundle/protobuf.gyp b/build/linux/unbundle/protobuf.gyp new file mode 100644 index 0000000000..7bcd9921a1 --- /dev/null +++ b/build/linux/unbundle/protobuf.gyp @@ -0,0 +1,149 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'targets': [ + { + 'target_name': 'protobuf_lite', + 'type': 'none', + 'direct_dependent_settings': { + 'cflags': [ + # Use full protobuf, because vanilla protobuf doesn't have + # our custom patch to retain unknown fields in lite mode. + '<!@(pkg-config --cflags protobuf)', + ], + 'defines': [ + 'USE_SYSTEM_PROTOBUF', + + # This macro must be defined to suppress the use + # of dynamic_cast<>, which requires RTTI. + 'GOOGLE_PROTOBUF_NO_RTTI', + 'GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER', + ], + }, + 'link_settings': { + # Use full protobuf, because vanilla protobuf doesn't have + # our custom patch to retain unknown fields in lite mode. + 'ldflags': [ + '<!@(pkg-config --libs-only-L --libs-only-other protobuf)', + ], + 'libraries': [ + '<!@(pkg-config --libs-only-l protobuf)', + ], + }, + 'variables': { + 'headers_root_path': 'src', + 'header_filenames': [ + # This list can easily be updated using the command below: + # find third_party/protobuf/src -iname '*.h' -printf "'%p',\n" | \ + # sed -e 's|third_party/protobuf/src/||' | sort -u + 'google/protobuf/compiler/code_generator.h', + 'google/protobuf/compiler/command_line_interface.h', + 'google/protobuf/compiler/cpp/cpp_enum_field.h', + 'google/protobuf/compiler/cpp/cpp_enum.h', + 'google/protobuf/compiler/cpp/cpp_extension.h', + 'google/protobuf/compiler/cpp/cpp_field.h', + 'google/protobuf/compiler/cpp/cpp_file.h', + 'google/protobuf/compiler/cpp/cpp_generator.h', + 'google/protobuf/compiler/cpp/cpp_helpers.h', + 'google/protobuf/compiler/cpp/cpp_message_field.h', + 'google/protobuf/compiler/cpp/cpp_message.h', + 'google/protobuf/compiler/cpp/cpp_options.h', + 'google/protobuf/compiler/cpp/cpp_primitive_field.h', + 'google/protobuf/compiler/cpp/cpp_service.h', + 'google/protobuf/compiler/cpp/cpp_string_field.h', + 'google/protobuf/compiler/cpp/cpp_unittest.h', + 'google/protobuf/compiler/importer.h', + 'google/protobuf/compiler/java/java_doc_comment.h', + 'google/protobuf/compiler/java/java_enum_field.h', + 'google/protobuf/compiler/java/java_enum.h', + 'google/protobuf/compiler/java/java_extension.h', + 'google/protobuf/compiler/java/java_field.h', + 'google/protobuf/compiler/java/java_file.h', + 'google/protobuf/compiler/java/java_generator.h', + 'google/protobuf/compiler/java/java_helpers.h', + 'google/protobuf/compiler/java/java_message_field.h', + 'google/protobuf/compiler/java/java_message.h', + 'google/protobuf/compiler/java/java_primitive_field.h', + 'google/protobuf/compiler/java/java_service.h', + 'google/protobuf/compiler/java/java_string_field.h', + 'google/protobuf/compiler/mock_code_generator.h', + 'google/protobuf/compiler/package_info.h', + 'google/protobuf/compiler/parser.h', + 'google/protobuf/compiler/plugin.h', + 'google/protobuf/compiler/plugin.pb.h', + 'google/protobuf/compiler/python/python_generator.h', + 'google/protobuf/compiler/subprocess.h', + 'google/protobuf/compiler/zip_writer.h', + 'google/protobuf/descriptor_database.h', + 'google/protobuf/descriptor.h', + 'google/protobuf/descriptor.pb.h', + 'google/protobuf/dynamic_message.h', + 'google/protobuf/extension_set.h', + 'google/protobuf/generated_enum_reflection.h', + 'google/protobuf/generated_message_reflection.h', + 'google/protobuf/generated_message_util.h', + 'google/protobuf/io/coded_stream.h', + 'google/protobuf/io/coded_stream_inl.h', + 'google/protobuf/io/gzip_stream.h', + 'google/protobuf/io/package_info.h', + 'google/protobuf/io/printer.h', + 'google/protobuf/io/tokenizer.h', + 'google/protobuf/io/zero_copy_stream.h', + 'google/protobuf/io/zero_copy_stream_impl.h', + 'google/protobuf/io/zero_copy_stream_impl_lite.h', + 'google/protobuf/message.h', + 'google/protobuf/message_lite.h', + 'google/protobuf/package_info.h', + 'google/protobuf/reflection_ops.h', + 'google/protobuf/repeated_field.h', + 'google/protobuf/service.h', + 'google/protobuf/stubs/atomicops.h', + 'google/protobuf/stubs/atomicops_internals_arm64_gcc.h', + 'google/protobuf/stubs/atomicops_internals_arm_gcc.h', + 'google/protobuf/stubs/atomicops_internals_arm_qnx.h', + 'google/protobuf/stubs/atomicops_internals_atomicword_compat.h', + 'google/protobuf/stubs/atomicops_internals_macosx.h', + 'google/protobuf/stubs/atomicops_internals_mips_gcc.h', + 'google/protobuf/stubs/atomicops_internals_pnacl.h', + 'google/protobuf/stubs/atomicops_internals_tsan.h', + 'google/protobuf/stubs/atomicops_internals_x86_gcc.h', + 'google/protobuf/stubs/atomicops_internals_x86_msvc.h', + 'google/protobuf/stubs/common.h', + 'google/protobuf/stubs/hash.h', + 'google/protobuf/stubs/map-util.h', + 'google/protobuf/stubs/once.h', + 'google/protobuf/stubs/platform_macros.h', + 'google/protobuf/stubs/stl_util.h', + 'google/protobuf/stubs/stringprintf.h', + 'google/protobuf/stubs/strutil.h', + 'google/protobuf/stubs/substitute.h', + 'google/protobuf/stubs/template_util.h', + 'google/protobuf/stubs/type_traits.h', + 'google/protobuf/testing/file.h', + 'google/protobuf/testing/googletest.h', + 'google/protobuf/test_util.h', + 'google/protobuf/test_util_lite.h', + 'google/protobuf/text_format.h', + 'google/protobuf/unknown_field_set.h', + 'google/protobuf/wire_format.h', + 'google/protobuf/wire_format_lite.h', + 'google/protobuf/wire_format_lite_inl.h', + ], + }, + 'includes': [ + '../../build/shim_headers.gypi', + ], + }, + { + 'target_name': 'protoc', + 'type': 'none', + 'toolsets': ['host', 'target'], + }, + { + 'target_name': 'py_proto', + 'type': 'none', + }, + ], +} diff --git a/build/linux/unbundle/replace_gyp_files.py b/build/linux/unbundle/replace_gyp_files.py index fc7646f4c0..a780fc5741 100755 --- a/build/linux/unbundle/replace_gyp_files.py +++ b/build/linux/unbundle/replace_gyp_files.py @@ -33,6 +33,7 @@ REPLACEMENTS = { 'use_system_libxslt': 'third_party/libxslt/libxslt.gyp', 'use_system_openssl': 'third_party/boringssl/boringssl.gyp', 'use_system_opus': 'third_party/opus/opus.gyp', + 'use_system_protobuf': 'third_party/protobuf/protobuf.gyp', 'use_system_re2': 'third_party/re2/re2.gyp', 'use_system_snappy': 'third_party/snappy/snappy.gyp', 'use_system_speex': 'third_party/speex/speex.gyp', diff --git a/build/mac/find_sdk.py b/build/mac/find_sdk.py index 1d7634391f..0534766e80 100755 --- a/build/mac/find_sdk.py +++ b/build/mac/find_sdk.py @@ -3,11 +3,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -import os -import re -import subprocess -import sys - """Prints the lowest locally available SDK version greater than or equal to a given minimum sdk version to standard output. @@ -15,6 +10,12 @@ Usage: python find_sdk.py 10.6 # Ignores SDKs < 10.6 """ +import os +import re +import subprocess +import sys + + from optparse import OptionParser @@ -42,8 +43,8 @@ def main(): stderr=subprocess.STDOUT) out, err = job.communicate() if job.returncode != 0: - print >>sys.stderr, out - print >>sys.stderr, err + print >> sys.stderr, out + print >> sys.stderr, err raise Exception(('Error %d running xcode-select, you might have to run ' '|sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer| ' 'if you are using Xcode 4.') % job.returncode) @@ -63,17 +64,17 @@ def main(): best_sdk = sorted(sdks, key=parse_version)[0] if options.verify and best_sdk != min_sdk_version and not options.sdk_path: - print >>sys.stderr, '' - print >>sys.stderr, ' vvvvvvv' - print >>sys.stderr, '' - print >>sys.stderr, \ + print >> sys.stderr, '' + print >> sys.stderr, ' vvvvvvv' + print >> sys.stderr, '' + print >> sys.stderr, \ 'This build requires the %s SDK, but it was not found on your system.' \ % min_sdk_version - print >>sys.stderr, \ + print >> sys.stderr, \ 'Either install it, or explicitly set mac_sdk in your GYP_DEFINES.' - print >>sys.stderr, '' - print >>sys.stderr, ' ^^^^^^^' - print >>sys.stderr, '' + print >> sys.stderr, '' + print >> sys.stderr, ' ^^^^^^^' + print >> sys.stderr, '' return min_sdk_version if options.print_sdk_path: diff --git a/build/precompile.h b/build/precompile.h index a3c5193c61..20ca73cd33 100644 --- a/build/precompile.h +++ b/build/precompile.h @@ -20,6 +20,8 @@ #define BUILD_PRECOMPILE_H_ +#define _USE_MATH_DEFINES + // The Windows header needs to come before almost all the other // Windows-specific headers. #include <Windows.h> diff --git a/build/protoc_java.gypi b/build/protoc_java.gypi index a99ec6a5df..e1525b00d7 100644 --- a/build/protoc_java.gypi +++ b/build/protoc_java.gypi @@ -38,7 +38,7 @@ { 'variables': { - 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)', + 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)android_protoc<(EXECUTABLE_SUFFIX)', 'java_out_dir': '<(PRODUCT_DIR)/java_proto/<(_target_name)/src', 'proto_in_dir%': '.', 'stamp_file': '<(java_out_dir).stamp', @@ -71,12 +71,12 @@ '<(stamp_file)', '<@(_sources)', ], - 'message': 'Generating Java code from <(proto_in_dir)', + 'message': 'Generating Java code from protobuf files in <(proto_in_dir)', }, ], 'dependencies': [ - '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', - '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite_javalib', + '<(DEPTH)/third_party/android_protobuf/android_protobuf.gyp:android_protoc#host', + '<(DEPTH)/third_party/android_protobuf/android_protobuf.gyp:protobuf_nano_javalib', ], 'includes': [ 'java.gypi' ], } diff --git a/build/protoc_java.py b/build/protoc_java.py index 42e204464a..940fd80acf 100755 --- a/build/protoc_java.py +++ b/build/protoc_java.py @@ -3,7 +3,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -"""Generate java source files from protobufs +"""Generate java source files from protobuf files. Usage: protoc_java.py {protoc} {proto_path} {java_out} {stamp_file} {proto_files} @@ -30,20 +30,24 @@ def main(argv): protoc_path, proto_path, java_out, stamp_file = argv[1:5] proto_files = argv[5:] - # Delete all old sources + # Delete all old sources. if os.path.exists(java_out): shutil.rmtree(java_out) - # Create source directory + # Create source directory. os.makedirs(java_out) - # Generate Java files using protoc + # Specify arguments to the generator. + generator_args = ['optional_field_style=reftypes', + 'store_unknown_fields=true'] + out_arg = '--javanano_out=' + ','.join(generator_args) + ':' + java_out + + # Generate Java files using protoc. ret = subprocess.call( - [protoc_path, '--proto_path', proto_path, '--java_out', java_out] - + proto_files) + [protoc_path, '--proto_path', proto_path, out_arg] + proto_files) if ret == 0: - # Create a new stamp file + # Create a new stamp file. with file(stamp_file, 'a'): os.utime(stamp_file, None) diff --git a/build/sanitizers/sanitizer_options.cc b/build/sanitizers/sanitizer_options.cc index ece14b9793..1e9262581f 100644 --- a/build/sanitizers/sanitizer_options.cc +++ b/build/sanitizers/sanitizer_options.cc @@ -7,6 +7,11 @@ #include "build/build_config.h" +#if defined(ADDRESS_SANITIZER) && defined(OS_MACOSX) +#include <crt_externs.h> // for _NSGetArgc, _NSGetArgv +#include <string.h> +#endif // ADDRESS_SANITIZER && OS_MACOSX + // Functions returning default options are declared weak in the tools' runtime // libraries. To make the linker pick the strong replacements for those // functions from this module, we explicitly force its inclusion by passing @@ -61,6 +66,8 @@ const char *kAsanDefaultOptions = const char *kAsanDefaultOptions = "strict_memcmp=0 replace_intrin=0 check_printf=1 use_sigaltstack=1 " "strip_path_prefix=Release/../../ "; +static const char kNaClDefaultOptions[] = "handle_segv=0"; +static const char kNaClFlag[] = "--type=nacl-loader"; #endif // OS_LINUX #if defined(OS_LINUX) || defined(OS_MACOSX) @@ -71,6 +78,18 @@ __attribute__((visibility("default"))) // stripped by the linker. __attribute__((used)) const char *__asan_default_options() { +#if defined(OS_MACOSX) + char*** argvp = _NSGetArgv(); + int* argcp = _NSGetArgc(); + if (!argvp || !argcp) return kAsanDefaultOptions; + char** argv = *argvp; + int argc = *argcp; + for (int i = 0; i < argc; ++i) { + if (strcmp(argv[i], kNaClFlag) == 0) { + return kNaClDefaultOptions; + } + } +#endif return kAsanDefaultOptions; } #endif // OS_LINUX || OS_MACOSX diff --git a/build/sanitizers/sanitizers.gyp b/build/sanitizers/sanitizers.gyp index cbe7ec015d..d971d6d1c3 100644 --- a/build/sanitizers/sanitizers.gyp +++ b/build/sanitizers/sanitizers.gyp @@ -45,6 +45,15 @@ 'ldflags': [ '-Wl,-u_sanitizer_options_link_helper', ], + 'target_conditions': [ + ['_type=="executable"', { + 'xcode_settings': { + 'OTHER_LDFLAGS': [ + '-Wl,-u,__sanitizer_options_link_helper', + ], + }, + }], + ], }, }, ], diff --git a/build/sanitizers/tsan_suppressions.cc b/build/sanitizers/tsan_suppressions.cc index 76d4cc18d3..aa4b7c7522 100644 --- a/build/sanitizers/tsan_suppressions.cc +++ b/build/sanitizers/tsan_suppressions.cc @@ -124,6 +124,8 @@ char kTSanDefaultSuppressions[] = "race:base::g_power_monitor\n" "race:base::PowerMonitor::PowerMonitor\n" "race:base::PowerMonitor::AddObserver\n" +"race:base::PowerMonitor::RemoveObserver\n" +"race:base::PowerMonitor::IsOnBatteryPower\n" // http://crbug.com/268941 "race:tracked_objects::ThreadData::tls_index_\n" @@ -184,9 +186,6 @@ char kTSanDefaultSuppressions[] = // http://crbug.com/329460 "race:extensions::InfoMap::AddExtension\n" -// http://crbug.com/330528 -"race:v8::internal::MarkCompactCollector::SweepInParallel\n" - // http://crbug.com/333244 "race:content::" "VideoCaptureImplTest::MockVideoCaptureImpl::~MockVideoCaptureImpl\n" @@ -302,6 +301,9 @@ char kTSanDefaultSuppressions[] = "deadlock:" "base::debug::TraceEventTestFixture_ThreadOnceBlocking_Test::TestBody\n" +// http://crbug.com/415472 +"deadlock:base::debug::TraceLog::GetCategoryGroupEnabled\n" + // End of suppressions. ; // Please keep this semicolon. diff --git a/build/secondary/testing/gmock/BUILD.gn b/build/secondary/testing/gmock/BUILD.gn index 018917f839..a0dbad7853 100644 --- a/build/secondary/testing/gmock/BUILD.gn +++ b/build/secondary/testing/gmock/BUILD.gn @@ -8,6 +8,8 @@ config("gmock_config") { } static_library("gmock") { + # TODO http://crbug.com/412064 enable this flag all the time. + testonly = !is_component_build sources = [ # Sources based on files in r173 of gmock. "include/gmock/gmock-actions.h", @@ -33,13 +35,15 @@ static_library("gmock") { # This project includes some stuff form gtest's guts. include_dirs = [ "../gtest/include" ] - direct_dependent_configs = [ + public_configs = [ ":gmock_config", "//testing/gtest:gtest_config", ] } static_library("gmock_main") { + # TODO http://crbug.com/412064 enable this flag all the time. + testonly = !is_component_build sources = [ "src/gmock_main.cc" ] deps = [ ":gmock" ] } diff --git a/build/secondary/testing/gtest/BUILD.gn b/build/secondary/testing/gtest/BUILD.gn index f7c1e0d720..f50afb6356 100644 --- a/build/secondary/testing/gtest/BUILD.gn +++ b/build/secondary/testing/gtest/BUILD.gn @@ -54,11 +54,13 @@ config("gtest_config") { } config("gtest_direct_config") { - visibility = ":*" + visibility = [ ":*" ] defines = [ "UNIT_TEST" ] } static_library("gtest") { + # TODO http://crbug.com/412064 enable this flag all the time. + testonly = !is_component_build sources = [ "include/gtest/gtest-death-test.h", "include/gtest/gtest-message.h", @@ -104,13 +106,15 @@ static_library("gtest") { include_dirs = [ "." ] all_dependent_configs = [ ":gtest_config" ] - direct_dependent_configs = [ ":gtest_direct_config" ] + public_configs = [ ":gtest_direct_config" ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] } source_set("gtest_main") { + # TODO http://crbug.com/412064 enable this flag all the time. + testonly = !is_component_build sources = [ "src/gtest_main.cc" ] deps = [ ":gtest" ] } diff --git a/build/secondary/third_party/android_tools/BUILD.gn b/build/secondary/third_party/android_tools/BUILD.gn index 1a54e15a7a..14e6c07874 100644 --- a/build/secondary/third_party/android_tools/BUILD.gn +++ b/build/secondary/third_party/android_tools/BUILD.gn @@ -12,7 +12,7 @@ config("cpu_features_include") { # //build/android/cpufeatures.gypi:cpufeatures source_set("cpu_features") { sources = [ "ndk/sources/android/cpufeatures/cpu-features.c" ] - direct_dependent_configs = [ ":cpu_features_include" ] + public_configs = [ ":cpu_features_include" ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] diff --git a/build/secondary/third_party/cacheinvalidation/BUILD.gn b/build/secondary/third_party/cacheinvalidation/BUILD.gn index 018e7c857b..15e2aa4371 100644 --- a/build/secondary/third_party/cacheinvalidation/BUILD.gn +++ b/build/secondary/third_party/cacheinvalidation/BUILD.gn @@ -75,7 +75,7 @@ static_library("cacheinvalidation") { "src/google/cacheinvalidation/include/types.h", ] - direct_dependent_configs = [ ":cacheinvalidation_config" ] + public_configs = [ ":cacheinvalidation_config" ] deps = [ "src/google/cacheinvalidation:cacheinvalidation_proto_cpp", diff --git a/build/secondary/third_party/cacheinvalidation/src/google/cacheinvalidation/BUILD.gn b/build/secondary/third_party/cacheinvalidation/src/google/cacheinvalidation/BUILD.gn index 9429139343..2dc1b99944 100644 --- a/build/secondary/third_party/cacheinvalidation/src/google/cacheinvalidation/BUILD.gn +++ b/build/secondary/third_party/cacheinvalidation/src/google/cacheinvalidation/BUILD.gn @@ -6,7 +6,7 @@ import("//third_party/protobuf/proto_library.gni") proto_library("cacheinvalidation_proto_cpp") { # Depend on cacheinvalidation instead. - visibility = "//third_party/cacheinvalidation/*" + visibility = [ "//third_party/cacheinvalidation/*" ] sources = [ "client.proto", diff --git a/build/secondary/third_party/flac/BUILD.gn b/build/secondary/third_party/flac/BUILD.gn index 53a2b05077..8a498bbe69 100644 --- a/build/secondary/third_party/flac/BUILD.gn +++ b/build/secondary/third_party/flac/BUILD.gn @@ -61,7 +61,7 @@ static_library("flac") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - direct_dependent_configs = [ ":flac_config" ] + public_configs = [ ":flac_config" ] include_dirs = [ "include", diff --git a/build/secondary/third_party/freetype/BUILD.gn b/build/secondary/third_party/freetype/BUILD.gn index ee70c4e89c..2b9623964f 100644 --- a/build/secondary/third_party/freetype/BUILD.gn +++ b/build/secondary/third_party/freetype/BUILD.gn @@ -43,7 +43,7 @@ source_set("freetype") { "build", ] - direct_dependent_configs = [ ":freetype_config" ] + public_configs = [ ":freetype_config" ] deps = [ "//third_party/libpng", diff --git a/build/secondary/third_party/google_toolbox_for_mac/BUILD.gn b/build/secondary/third_party/google_toolbox_for_mac/BUILD.gn index 66c2404d2a..1977a06aa4 100644 --- a/build/secondary/third_party/google_toolbox_for_mac/BUILD.gn +++ b/build/secondary/third_party/google_toolbox_for_mac/BUILD.gn @@ -37,7 +37,7 @@ component("google_toolbox_for_mac") { ":google_toolbox_for_mac_config", "//build/config/compiler:no_chromium_code", ] - direct_dependent_configs = [ ":google_toolbox_for_mac_config" ] + public_configs = [ ":google_toolbox_for_mac_config" ] if (!is_ios) { sources += [ @@ -172,11 +172,11 @@ component("google_toolbox_for_mac") { ] libs = [ - "AddressBook", - "AppKit", - "Carbon", - "Cocoa", - "QuartzCore", + "AddressBook.framework", + "AppKit.framework", + "Carbon.framework", + "Cocoa.framework", + "QuartzCore.framework", ] } else { # is_ios sources += [ @@ -198,6 +198,6 @@ component("google_toolbox_for_mac") { # build). Only do this in a component build, so that the shipping # chrome binary doesn't end up with unnecessarily exported # symbols. - config -= [ "//build/config/gcc:symbol_visibility_hidden" ] + configs -= [ "//build/config/gcc:symbol_visibility_hidden" ] } } diff --git a/build/secondary/third_party/icu/BUILD.gn b/build/secondary/third_party/icu/BUILD.gn index 14d59b5636..865a5e45a9 100644 --- a/build/secondary/third_party/icu/BUILD.gn +++ b/build/secondary/third_party/icu/BUILD.gn @@ -2,21 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -declare_args() { - # Tells icu to load an external data file rather than rely on the icudata - # being linked directly into the binary. - # - # This flag is a bit confusing. As of this writing, icu.gyp set the value to - # 0 but common.gypi sets the value to 1 for most platforms (and the 1 takes - # precedence). - # - # TODO(GYP) We'll probably need to enhance this logic to set the value to - # true or false in similar circumstances. Note that in the GYP build, some - # other projects access this variable. If we need to do a similar thing, - # we should probably make an icu config file (//third_party/icu/config.gni) - # with this flag in it rather than making it global. - icu_use_data_file = true -} +import("//third_party/icu/config.gni") # Meta target that includes both icuuc and icui18n. Most targets want both. # You can depend on the individually if you need to. @@ -46,23 +32,25 @@ config("icu_config") { # Config used only by ICU code. config("icu_code") { + cflags = [] if (is_win) { # Disable some compiler warnings. - cflags = [ + cflags += [ "/wd4005", # Macro redefinition. "/wd4068", # Unknown pragmas. "/wd4267", # Conversion from size_t on 64-bits. "/wd4996", # Deprecated functions. ] } else if (is_linux) { - cflags = [ + cflags += [ # Since ICU wants to internally use its own deprecated APIs, don't # complain about it. "-Wno-deprecated-declarations", "-Wno-unused-function", ] - } else if (is_clang) { - cflags = [ + } + if (is_clang) { + cflags += [ "-Wno-deprecated-declarations", "-Wno-logical-op-parentheses", "-Wno-tautological-compare", @@ -254,15 +242,22 @@ component("icui18n") { ] configs += [ ":icu_code" ] - direct_dependent_configs = [ ":icu_config" ] + public_configs = [ ":icu_config" ] + cflags = [] + if (is_android || is_linux) { + cflags += [ + # ICU uses its own deprecated functions. + "-Wno-deprecated-declarations", + ] + } if (is_clang) { # uspoof.h has a U_NAMESPACE_USE macro. That's a bug, # the header should use U_NAMESPACE_BEGIN instead. # http://bugs.icu-project.org/trac/ticket/9054 configs -= [ "//build/config/clang:extra_warnings" ] - cflags = [ + cflags += [ "-Wno-header-hygiene", # Looks like a real issue, see http://crbug.com/114660 "-Wno-return-type-c-linkage", @@ -461,7 +456,7 @@ component("icuuc") { "//build/config/compiler:no_chromium_code", ] - direct_dependent_configs = [ ":icu_config" ] + public_configs = [ ":icu_config" ] if (is_win || icu_use_data_file) { sources += [ "source/stubdata/stubdata.c" ] diff --git a/build/secondary/third_party/icu/config.gni b/build/secondary/third_party/icu/config.gni new file mode 100644 index 0000000000..9c389de92e --- /dev/null +++ b/build/secondary/third_party/icu/config.gni @@ -0,0 +1,16 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +declare_args() { + # Tells icu to load an external data file rather than rely on the icudata + # being linked directly into the binary. + # + # This flag is a bit confusing. As of this writing, icu.gyp set the value to + # 0 but common.gypi sets the value to 1 for most platforms (and the 1 takes + # precedence). + # + # TODO(GYP) We'll probably need to enhance this logic to set the value to + # true or false in similar circumstances. + icu_use_data_file = true +} diff --git a/build/secondary/third_party/leveldatabase/BUILD.gn b/build/secondary/third_party/leveldatabase/BUILD.gn index 60a600bf07..ffe9fa6f5d 100644 --- a/build/secondary/third_party/leveldatabase/BUILD.gn +++ b/build/secondary/third_party/leveldatabase/BUILD.gn @@ -114,7 +114,7 @@ static_library("leveldatabase") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - direct_dependent_configs = [ ":leveldatabase_config" ] + public_configs = [ ":leveldatabase_config" ] deps = [ "//base", @@ -150,12 +150,13 @@ if (!is_android) { "src/util/testutil.h", ] - forward_dependent_configs_from = [ ":leveldatabase" ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - deps = [ + public_deps = [ ":leveldatabase", + ] + deps = [ "//base", ] } diff --git a/build/secondary/third_party/libjpeg_turbo/BUILD.gn b/build/secondary/third_party/libjpeg_turbo/BUILD.gn index f594fbecb5..78b59aefa3 100644 --- a/build/secondary/third_party/libjpeg_turbo/BUILD.gn +++ b/build/secondary/third_party/libjpeg_turbo/BUILD.gn @@ -201,7 +201,7 @@ source_set("libjpeg") { configs += [ ":libjpeg_config" ] - direct_dependent_configs = [ ":libjpeg_config" ] + public_configs = [ ":libjpeg_config" ] # MemorySanitizer doesn't support assembly code, so keep it disabled in # MSan builds for now. diff --git a/build/secondary/third_party/libsrtp/BUILD.gn b/build/secondary/third_party/libsrtp/BUILD.gn index ba6dba09f7..b0e0a91e4d 100644 --- a/build/secondary/third_party/libsrtp/BUILD.gn +++ b/build/secondary/third_party/libsrtp/BUILD.gn @@ -67,14 +67,14 @@ config("system_libsrtp_config") { if (use_system_libsrtp) { group("libsrtp") { - direct_dependent_configs = [ ":libsrtp_config", ":system_libsrtp_config" ] + public_configs = [ ":libsrtp_config", ":system_libsrtp_config" ] libs = [ "-lsrtp" ] } } else { static_library("libsrtp") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - configs += [ ":libsrtp_config" ] + public_configs = [ ":libsrtp_config" ] sources = [ # includes @@ -142,6 +142,10 @@ if (use_system_libsrtp) { "srtp/crypto/rng/prng.c", "srtp/crypto/rng/rand_source.c", ] + + if (is_clang) { + cflags = [ "-Wno-implicit-function-declaration" ] + } } # TODO(GYP): A bunch of these tests don't compile (in gyp either). They're @@ -150,7 +154,6 @@ if (use_system_libsrtp) { executable("rdbx_driver") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - configs += [ ":libsrtp_config" ] deps = [ ":libsrtp" ] sources = [ "srtp/include/getopt_s.h", @@ -162,7 +165,6 @@ if (use_system_libsrtp) { executable("srtp_driver") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - configs += [ ":libsrtp_config" ] deps = [ ":libsrtp" ] sources = [ "srtp/include/getopt_s.h", @@ -175,7 +177,6 @@ if (use_system_libsrtp) { executable("roc_driver") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - configs += [ ":libsrtp_config" ] deps = [ ":libsrtp" ] sources = [ "srtp/crypto/include/rdbx.h", @@ -187,7 +188,6 @@ if (use_system_libsrtp) { executable("replay_driver") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - configs += [ ":libsrtp_config" ] deps = [ ":libsrtp" ] sources = [ "srtp/crypto/include/rdbx.h", @@ -199,7 +199,6 @@ if (use_system_libsrtp) { executable("rtpw") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - configs += [ ":libsrtp_config" ] deps = [ ":libsrtp" ] sources = [ "srtp/include/getopt_s.h", @@ -213,12 +212,14 @@ if (use_system_libsrtp) { if (is_android) { defines = [ "HAVE_SYS_SOCKET_H" ] } + if (is_clang) { + cflags = [ "-Wno-implicit-function-declaration" ] + } } executable("srtp_test_cipher_driver") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - configs += [ ":libsrtp_config" ] deps = [ ":libsrtp" ] sources = [ "srtp/crypto/test/cipher_driver.c", @@ -228,7 +229,6 @@ if (use_system_libsrtp) { executable("srtp_test_datatypes_driver") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - configs += [ ":libsrtp_config" ] deps = [ ":libsrtp" ] sources = [ "srtp/crypto/test/datatypes_driver.c", @@ -238,7 +238,6 @@ if (use_system_libsrtp) { executable("srtp_test_stat_driver") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - configs += [ ":libsrtp_config" ] deps = [ ":libsrtp" ] sources = [ "srtp/crypto/test/stat_driver.c", @@ -248,7 +247,6 @@ if (use_system_libsrtp) { executable("srtp_test_sha1_driver") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - configs += [ ":libsrtp_config" ] deps = [ ":libsrtp" ] sources = [ "srtp/crypto/test/sha1_driver.c", @@ -258,7 +256,6 @@ if (use_system_libsrtp) { executable("srtp_test_kernel_driver") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - configs += [ ":libsrtp_config" ] deps = [ ":libsrtp" ] sources = [ "srtp/crypto/test/kernel_driver.c", @@ -268,7 +265,6 @@ if (use_system_libsrtp) { executable("srtp_test_aes_calc") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - configs += [ ":libsrtp_config" ] deps = [ ":libsrtp" ] sources = [ "srtp/crypto/test/aes_calc.c", @@ -278,7 +274,6 @@ if (use_system_libsrtp) { executable("srtp_test_rand_gen") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - configs += [ ":libsrtp_config" ] deps = [ ":libsrtp" ] sources = [ "srtp/crypto/test/rand_gen.c", @@ -288,7 +283,6 @@ if (use_system_libsrtp) { executable("srtp_test_env") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - configs += [ ":libsrtp_config" ] deps = [ ":libsrtp" ] sources = [ "srtp/crypto/test/env.c", diff --git a/build/secondary/third_party/nss/BUILD.gn b/build/secondary/third_party/nss/BUILD.gn index 7c05da7860..31ed5a9567 100644 --- a/build/secondary/third_party/nss/BUILD.gn +++ b/build/secondary/third_party/nss/BUILD.gn @@ -205,7 +205,7 @@ if (is_linux) { "nspr/pr/src/threads/prtpd.c", ] - direct_dependent_configs = [ ":nspr_config" ] + public_configs = [ ":nspr_config" ] configs -= [ "//build/config/compiler:chromium_code", @@ -348,10 +348,10 @@ if (is_linux) { "nss/lib/nss/nssver.c", ] - deps = [ ":nss_static" ] + public_deps = [ ":nss_static" ] if (include_nss_root_certs) { - deps += [ ":nssckbi" ] + public_deps += [ ":nssckbi" ] } if (component_mode == "shared_library") { @@ -362,8 +362,6 @@ if (is_linux) { ldflags = [ rebase_path("nss/exports_win.def", root_build_dir) ] } } - - forward_dependent_configs_from = deps } config("nssckbi_config") { @@ -385,7 +383,7 @@ if (is_linux) { # TODO(rsleevi): http://crbug.com/128134 - Break the circular dependency # without requiring nssckbi to be built as a shared library. source_set("nssckbi") { - visibility = ":nss" # This target is internal implementation detail. + visibility = [ ":nss" ] # This target is internal implementation detail. sources = [ "nss/lib/ckfw/builtins/anchor.c", @@ -441,12 +439,11 @@ if (is_linux) { configs += [ "//build/config/compiler:no_chromium_code" ] include_dirs = [ "nss/lib/ckfw" ] - direct_dependent_configs = [ ":nssckbi_config" ] + public_configs = [ ":nssckbi_config" ] - deps = [ + public_deps = [ ":nss_static", ] - forward_dependent_configs_from = deps } config("nss_static_config") { @@ -561,7 +558,6 @@ if (is_linux) { "nss/lib/freebl/blapi.h", "nss/lib/freebl/blapii.h", "nss/lib/freebl/blapit.h", - "nss/lib/freebl/build_config_mac.h", "nss/lib/freebl/camellia.c", "nss/lib/freebl/camellia.h", "nss/lib/freebl/chacha20/chacha20.c", @@ -627,6 +623,7 @@ if (is_linux) { "nss/lib/freebl/mpi/mp_gf2m.c", "nss/lib/freebl/mpi/mp_gf2m.h", "nss/lib/freebl/mpi/primes.c", + "nss/lib/freebl/nss_build_config_mac.h", "nss/lib/freebl/poly1305/poly1305-donna-x64-sse2-incremental-source.c", "nss/lib/freebl/poly1305/poly1305.c", "nss/lib/freebl/poly1305/poly1305.h", @@ -841,7 +838,7 @@ if (is_linux) { ] } configs += [ "//build/config/compiler:no_chromium_code" ] - direct_dependent_configs = [ ":nss_static_config" ] + public_configs = [ ":nss_static_config" ] cflags = [] @@ -1070,7 +1067,7 @@ if (is_linux) { ] cflags += [ "-include", - rebase_path("//third_party/nss/nss/lib/freebl/build_config_mac.h", + rebase_path("//third_party/nss/nss/lib/freebl/nss_build_config_mac.h", root_build_dir), ] defines += [ @@ -1148,12 +1145,13 @@ if (is_linux) { ] } + public_deps = [ + ":nspr", + ] deps = [ ":nspr", "//third_party/sqlite", ] - - forward_dependent_configs_from = [ ":nspr" ] } } # Windows/Mac/iOS. diff --git a/build/secondary/third_party/openmax_dl/dl/BUILD.gn b/build/secondary/third_party/openmax_dl/dl/BUILD.gn new file mode 100644 index 0000000000..067be172ff --- /dev/null +++ b/build/secondary/third_party/openmax_dl/dl/BUILD.gn @@ -0,0 +1,232 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +declare_args() { + # Override this value to build with small float FFT tables + openmax_big_float_fft = true +} + +config("dl_config") { + include_dirs = [ ".." ] +} + +# GYP: third_party/openmax_dl/dl/dl.gyp:openmax_dl +source_set("dl") { + public_configs = [ ":dl_config" ] + sources = [ + "api/omxtypes.h", + "sp/api/omxSP.h", + "sp/src/armSP_FFT_F32TwiddleTable.c", + ] + + cflags = [] + deps = [] + defines = [] + + if (openmax_big_float_fft) { + defines += [ + "BIG_FFT_TABLE", + ] + } + + if (cpu_arch == "arm" || cpu_arch == "arm64") { + sources += [ + # Common files that are used by both arm and arm64 code. + "api/arm/armOMX.h", + "api/arm/omxtypes_s.h", + "sp/api/armSP.h", + "sp/src/arm/armSP_FFT_S32TwiddleTable.c", + "sp/src/arm/omxSP_FFTGetBufSize_C_FC32.c", + "sp/src/arm/omxSP_FFTGetBufSize_C_SC32.c", + "sp/src/arm/omxSP_FFTGetBufSize_R_F32.c", + "sp/src/arm/omxSP_FFTGetBufSize_R_S32.c", + "sp/src/arm/omxSP_FFTInit_C_FC32.c", + "sp/src/arm/omxSP_FFTInit_R_F32.c", + ] + } + + if (cpu_arch == "arm") { + configs -= [ "//build/config/compiler:compiler_arm_fpu" ] + cflags += [ + "-mfpu=neon" + ] + + deps += [ + ":openmax_dl_armv7" + ] + + sources += [ + # Common files that are used by both the NEON and non-NEON code. + "api/armCOMM_s.h", + "sp/src/arm/omxSP_FFTGetBufSize_C_SC16.c", + "sp/src/arm/omxSP_FFTGetBufSize_R_S16.c", + "sp/src/arm/omxSP_FFTGetBufSize_R_S16S32.c", + "sp/src/arm/omxSP_FFTInit_C_SC16.c", + "sp/src/arm/omxSP_FFTInit_C_SC32.c", + "sp/src/arm/omxSP_FFTInit_R_S16.c", + "sp/src/arm/omxSP_FFTInit_R_S16S32.c", + "sp/src/arm/omxSP_FFTInit_R_S32.c", + + # Complex 32-bit fixed-point FFT. + "sp/src/arm/neon/armSP_FFT_CToC_SC32_Radix2_fs_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_SC32_Radix2_ls_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_SC32_Radix2_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_SC32_Radix4_fs_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_SC32_Radix4_ls_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_SC32_Radix4_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_SC32_Radix8_fs_unsafe_s.S", + "sp/src/arm/neon/omxSP_FFTFwd_CToC_SC32_Sfs_s.S", + "sp/src/arm/neon/omxSP_FFTInv_CToC_SC32_Sfs_s.S", + # Real 32-bit fixed-point FFT + "sp/src/arm/neon/armSP_FFTInv_CCSToR_S32_preTwiddleRadix2_unsafe_s.S", + "sp/src/arm/neon/omxSP_FFTFwd_RToCCS_S32_Sfs_s.S", + "sp/src/arm/neon/omxSP_FFTInv_CCSToR_S32_Sfs_s.S", + # Complex 16-bit fixed-point FFT + "sp/src/arm/neon/armSP_FFTInv_CCSToR_S16_preTwiddleRadix2_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_SC16_Radix2_fs_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_SC16_Radix2_ls_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_SC16_Radix2_ps_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_SC16_Radix2_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_SC16_Radix4_fs_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_SC16_Radix4_ls_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_SC16_Radix4_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_SC16_Radix8_fs_unsafe_s.S", + "sp/src/arm/neon/omxSP_FFTFwd_CToC_SC16_Sfs_s.S", + "sp/src/arm/neon/omxSP_FFTInv_CToC_SC16_Sfs_s.S", + # Real 16-bit fixed-point FFT + "sp/src/arm/neon/omxSP_FFTFwd_RToCCS_S16_Sfs_s.S", + "sp/src/arm/neon/omxSP_FFTInv_CCSToR_S16_Sfs_s.S", + "sp/src/arm/neon/omxSP_FFTFwd_RToCCS_S16S32_Sfs_s.S", + "sp/src/arm/neon/omxSP_FFTInv_CCSToR_S32S16_Sfs_s.S", + # Complex floating-point FFT + "sp/src/arm/neon/armSP_FFT_CToC_FC32_Radix2_fs_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_FC32_Radix2_ls_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_FC32_Radix2_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_FC32_Radix4_fs_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_FC32_Radix4_ls_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_FC32_Radix4_unsafe_s.S", + "sp/src/arm/neon/armSP_FFT_CToC_FC32_Radix8_fs_unsafe_s.S", + "sp/src/arm/neon/omxSP_FFTFwd_CToC_FC32_Sfs_s.S", + "sp/src/arm/neon/omxSP_FFTInv_CToC_FC32_Sfs_s.S", + # Real floating-point FFT + "sp/src/arm/neon/armSP_FFTInv_CCSToR_F32_preTwiddleRadix2_unsafe_s.S", + "sp/src/arm/neon/omxSP_FFTFwd_RToCCS_F32_Sfs_s.S", + "sp/src/arm/neon/omxSP_FFTInv_CCSToR_F32_Sfs_s.S", + ] + } + + if (cpu_arch == "ia32" || cpu_arch == "x64") { + cflags += [ + "-msse2" + ] + + sources += [ + # Real 32-bit floating-point FFT. + "sp/api/x86SP.h", + "sp/src/x86/omxSP_FFTFwd_RToCCS_F32_Sfs.c", + "sp/src/x86/omxSP_FFTGetBufSize_R_F32.c", + "sp/src/x86/omxSP_FFTInit_R_F32.c", + "sp/src/x86/omxSP_FFTInv_CCSToR_F32_Sfs.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Fwd_Radix2_fs.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Fwd_Radix2_ls.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Fwd_Radix2_ls_sse.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Fwd_Radix2_ms.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Fwd_Radix4_fs.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Fwd_Radix4_fs_sse.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Fwd_Radix4_ls.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Fwd_Radix4_ls_sse.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Fwd_Radix4_ms.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Fwd_Radix4_ms_sse.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Inv_Radix2_fs.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Inv_Radix2_ls.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Inv_Radix2_ls_sse.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Inv_Radix2_ms.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Inv_Radix4_fs.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Inv_Radix4_fs_sse.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Inv_Radix4_ls.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Inv_Radix4_ls_sse.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Inv_Radix4_ms.c", + "sp/src/x86/x86SP_FFT_CToC_FC32_Inv_Radix4_ms_sse.c", + "sp/src/x86/x86SP_FFT_F32_radix2_kernel.c", + "sp/src/x86/x86SP_FFT_F32_radix4_kernel.c", + "sp/src/x86/x86SP_SSE_Math.h", + ] + } + if (cpu_arch == "arm64") { + sources += [ + "api/arm/arm64COMM_s.h", + + # Complex floating-point FFT + "sp/src/arm/arm64/armSP_FFT_CToC_FC32_Radix2_fs_s.S", + "sp/src/arm/arm64/armSP_FFT_CToC_FC32_Radix2_ls_s.S", + "sp/src/arm/arm64/armSP_FFT_CToC_FC32_Radix2_s.S", + "sp/src/arm/arm64/armSP_FFT_CToC_FC32_Radix4_fs_s.S", + "sp/src/arm/arm64/armSP_FFT_CToC_FC32_Radix4_ls_s.S", + "sp/src/arm/arm64/armSP_FFT_CToC_FC32_Radix4_s.S", + "sp/src/arm/arm64/armSP_FFT_CToC_FC32_Radix8_fs_s.S", + "sp/src/arm/arm64/omxSP_FFTInv_CToC_FC32.c", + "sp/src/arm/arm64/omxSP_FFTFwd_CToC_FC32.c", + # Real floating-point FFT + "sp/src/arm/arm64/armSP_FFTInv_CCSToR_F32_preTwiddleRadix2_s.S", + "sp/src/arm/arm64/omxSP_FFTFwd_RToCCS_F32.c", + "sp/src/arm/arm64/ComplexToRealFixup.S", + "sp/src/arm/arm64/omxSP_FFTInv_CCSToR_F32.c", + ] + } + if (cpu_arch == "mipsel") { + cflags += [ + "-std=c99", + ] + sources -= [ + "sp/src/armSP_FFT_F32TwiddleTable.c", + ] + + sources += [ + "sp/api/mipsSP.h", + "sp/src/mips/mips_FFTFwd_RToCCS_F32_complex.c", + "sp/src/mips/mips_FFTFwd_RToCCS_F32_real.c", + "sp/src/mips/mips_FFTInv_CCSToR_F32_complex.c", + "sp/src/mips/mips_FFTInv_CCSToR_F32_real.c", + "sp/src/mips/omxSP_FFT_F32TwiddleTable.c", + "sp/src/mips/omxSP_FFTFwd_RToCCS_F32_Sfs.c", + "sp/src/mips/omxSP_FFTGetBufSize_R_F32.c", + "sp/src/mips/omxSP_FFTInit_R_F32.c", + "sp/src/mips/omxSP_FFTInv_CCSToR_F32_Sfs.c", + ] + } +} + +if (cpu_arch == "arm") { + # GYP: third_party/openmax_dl/dl/dl.gyp:openmax_dl + # Non-NEON implementation of FFT. This library is NOT + # standalone. Applications must link with openmax_dl. + source_set("openmax_dl_armv7") { + configs += [ ":dl_config" ] + deps = [ "//third_party/android_tools:cpu_features" ] + visibility = [ ":*" ] + + #TODO(GYP): + #'cflags!': [ + #'-mfpu=neon', + #], + + libs = [ "log" ] + + sources = [ + # Detection routine + "sp/src/arm/detect.c", + # Complex floating-point FFT + "sp/src/arm/armv7/armSP_FFT_CToC_FC32_Radix2_fs_unsafe_s.S", + "sp/src/arm/armv7/armSP_FFT_CToC_FC32_Radix4_fs_unsafe_s.S", + "sp/src/arm/armv7/armSP_FFT_CToC_FC32_Radix4_unsafe_s.S", + "sp/src/arm/armv7/armSP_FFT_CToC_FC32_Radix8_fs_unsafe_s.S", + "sp/src/arm/armv7/omxSP_FFTInv_CToC_FC32_Sfs_s.S", + "sp/src/arm/armv7/omxSP_FFTFwd_CToC_FC32_Sfs_s.S", + # Real floating-point FFT + "sp/src/arm/armv7/armSP_FFTInv_CCSToR_F32_preTwiddleRadix2_unsafe_s.S", + "sp/src/arm/armv7/omxSP_FFTFwd_RToCCS_F32_Sfs_s.S", + "sp/src/arm/armv7/omxSP_FFTInv_CCSToR_F32_Sfs_s.S", + ] + } +} diff --git a/build/secondary/tools/grit/grit_rule.gni b/build/secondary/tools/grit/grit_rule.gni index bec147eebb..5103d73a2c 100644 --- a/build/secondary/tools/grit/grit_rule.gni +++ b/build/secondary/tools/grit/grit_rule.gni @@ -258,7 +258,7 @@ template("grit") { # The config and the action below get this visibility son only the generated # source set can depend on them. The variable "target_name" will get # overwritten inside the inner classes so we need to compute it here. - target_visibility = ":$target_name" + target_visibility = [ ":$target_name" ] # The current grit setup makes an file in $output_dir/grit/foo.h that # the source code expects to include via "grit/foo.h". It would be nice to @@ -301,7 +301,16 @@ template("grit") { args += grit_flags + assert_files_flags - visibility = target_visibility + if (defined(invoker.visibility)) { + # This needs to include both what the invoker specified (since they + # probably include generated headers from this target), as well as the + # generated source set (since there's no guarantee that the visibility + # specified by the invoker includes our target). + # + # Only define visibility at all if the invoker specified it. Otherwise, + # we want to keep the public "no visibility specified" default. + visibility = target_visibility + invoker.visibility + } deps = [ "//tools/grit:grit_sources" ] if (defined(invoker.deps)) { @@ -319,7 +328,7 @@ template("grit") { # Deps set on the template invocation will go on the grit script running # target rather than this library. deps = [ ":$grit_custom_target" ] - direct_dependent_configs = [ ":$grit_config" ] + public_configs = [ ":$grit_config" ] if (defined(invoker.visibility)) { visibility = invoker.visibility diff --git a/build/toolchain/android/BUILD.gn b/build/toolchain/android/BUILD.gn index 2d1b69a866..9ae2218340 100644 --- a/build/toolchain/android/BUILD.gn +++ b/build/toolchain/android/BUILD.gn @@ -53,14 +53,25 @@ template("android_gcc_toolchain") { # the following definition. soname = "{{target_output_name}}{{output_extension}}" - stripped_soname = "lib.stripped/${soname}.tmp" + stripped_soname = "lib.stripped/${soname}" temp_stripped_soname = "${stripped_soname}.tmp" android_strip = "${tool_prefix}strip" + mkdir_command = "mkdir -p lib.stripped" strip_command = "$android_strip --strip-unneeded -o $temp_stripped_soname $soname" replace_command = "if ! cmp -s $temp_stripped_soname $stripped_soname; then mv $temp_stripped_soname $stripped_soname; fi" postsolink = "$mkdir_command && $strip_command && $replace_command" + solink_outputs = [ stripped_soname ] + + # We make the assumption that the gcc_toolchain will produce an exe with + # the following definition. + exe = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" + stripped_exe = "exe.stripped/$exe" + mkdir_command = "mkdir -p exe.stripped" + strip_command = "$android_strip --strip-unneeded -o $stripped_exe $exe" + postlink = "$mkdir_command && $strip_command" + link_outputs = [ stripped_exe ] } } diff --git a/build/toolchain/cros/BUILD.gn b/build/toolchain/cros/BUILD.gn new file mode 100644 index 0000000000..d360f72572 --- /dev/null +++ b/build/toolchain/cros/BUILD.gn @@ -0,0 +1,35 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/toolchain/clang.gni") +import("//build/toolchain/gcc_toolchain.gni") + +declare_args() { + # The CrOS build system supports many different kinds of targets across + # many different architectures. Bringing your own toolchain is also supported, + # so it's actually impossible to enumerate all toolchains for all targets + # as GN toolchain specifications. + # These arguments provide a mechanism for specifying your CC, CXX and AR at + # buildfile-generation time, allowing the CrOS build system to always use + # the right tools for the current target. + cros_target_cc = "" + cros_target_cxx = "" + cros_target_ar = "" +} + +gcc_toolchain("target") { + assert(cros_target_cc != "", "Must provide target CC.") + assert(cros_target_cxx != "", "Must provide target CXX.") + assert(cros_target_ar != "", "Must provide target AR.") + + cc = "${cros_target_cc}" + cxx = "${cros_target_cxx}" + + ar = "${cros_target_ar}" + ld = cxx + + toolchain_cpu_arch = "${cpu_arch}" + toolchain_os = "linux" + is_clang = is_clang +} diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni index 8f5445b225..e415459eb0 100644 --- a/build/toolchain/gcc_toolchain.gni +++ b/build/toolchain/gcc_toolchain.gni @@ -2,6 +2,9 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +# This value will be inherited in the toolchain below. +concurrent_links = exec_script("get_concurrent_links.py", [], "value") + # This template defines a toolchain for something that works like gcc # (including clang). # @@ -124,17 +127,18 @@ template("gcc_toolchain") { tool("solink") { soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". - rspfile = soname + ".rsp" + sofile = "{{root_out_dir}}/$soname" # Possibly including toolchain dir. + rspfile = sofile + ".rsp" # These variables are not built into GN but are helpers that implement # (1) linking to produce a .so, (2) extracting the symbols from that file # to a temporary file, (3) if the temporary file has differences from the # existing .TOC file, overwrite it, otherwise, don't change it. - tocname = soname + ".TOC" - temporary_tocname = soname + ".tmp" - link_command = "$ld -shared {{ldflags}} -o $soname -Wl,-soname=$soname @$rspfile" - toc_command = "{ readelf -d $soname | grep SONAME ; nm -gD -f p $soname | cut -f1-2 -d' '; } > $temporary_tocname" - replace_command = "if ! cmp -s $temporary_tocname $tocname; then mv $temporary_tocname $tocname; fi" + tocfile = sofile + ".TOC" + temporary_tocname = sofile + ".tmp" + link_command = "$ld -shared {{ldflags}} -o $sofile -Wl,-soname=$soname @$rspfile" + toc_command = "{ readelf -d $sofile | grep SONAME ; nm -gD -f p $soname | cut -f1-2 -d' '; } > $temporary_tocname" + replace_command = "if ! cmp -s $temporary_tocname $tocfile; then mv $temporary_tocname $tocfile; fi" command = "$link_command && $toc_command && $replace_command" if (defined(invoker.postsolink)) { @@ -142,7 +146,7 @@ template("gcc_toolchain") { } rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" - description = "SOLINK $soname" + description = "SOLINK $sofile" # Use this for {{output_extension}} expansions unless a target manually # overrides it (in which case {{output_extension}} will be what the target @@ -156,23 +160,32 @@ template("gcc_toolchain") { # dependencies should be recompiled. restat = true - # Tell GN about the output files. It will link to the soname but use the - # tocname for dependency management. + # Tell GN about the output files. It will link to the sofile but use the + # tocfile for dependency management. outputs = [ - soname, - tocname, + sofile, + tocfile, ] - link_output = soname - depend_output = tocname + if (defined(invoker.solink_outputs)) { + outputs += invoker.solink_outputs + } + link_output = sofile + depend_output = tocfile } tool("link") { - outfile = "{{target_output_name}}{{output_extension}}" + outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" rspfile = "$outfile.rsp" command = "$ld {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix" + if (defined(invoker.postlink)) { + command += " && " + invoker.postlink + } description = "LINK $outfile" rspfile_content = "{{inputs}}" outputs = [ outfile ] + if (defined(invoker.link_outputs)) { + outputs += invoker.link_outputs + } } tool("stamp") { diff --git a/build/toolchain/get_concurrent_links.py b/build/toolchain/get_concurrent_links.py new file mode 100644 index 0000000000..629d67d503 --- /dev/null +++ b/build/toolchain/get_concurrent_links.py @@ -0,0 +1,64 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This script computs the number of concurrent links we want to run in the build +# as a function of machine spec. It's based on GetDefaultConcurrentLinks in GYP. + +import os +import re +import sys + +def GetDefaultConcurrentLinks(): + # Inherit the legacy environment variable for people that have set it in GYP. + pool_size = int(os.getenv('GYP_LINK_CONCURRENCY', 0)) + if pool_size: + return pool_size + + if sys.platform in ('win32', 'cygwin'): + import ctypes + + class MEMORYSTATUSEX(ctypes.Structure): + _fields_ = [ + ("dwLength", ctypes.c_ulong), + ("dwMemoryLoad", ctypes.c_ulong), + ("ullTotalPhys", ctypes.c_ulonglong), + ("ullAvailPhys", ctypes.c_ulonglong), + ("ullTotalPageFile", ctypes.c_ulonglong), + ("ullAvailPageFile", ctypes.c_ulonglong), + ("ullTotalVirtual", ctypes.c_ulonglong), + ("ullAvailVirtual", ctypes.c_ulonglong), + ("sullAvailExtendedVirtual", ctypes.c_ulonglong), + ] + + stat = MEMORYSTATUSEX() + stat.dwLength = ctypes.sizeof(stat) + ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat)) + + mem_limit = max(1, stat.ullTotalPhys / (4 * (2 ** 30))) # total / 4GB + hard_cap = max(1, int(os.getenv('GYP_LINK_CONCURRENCY_MAX', 2**32))) + return min(mem_limit, hard_cap) + elif sys.platform.startswith('linux'): + if os.path.exists("/proc/meminfo"): + with open("/proc/meminfo") as meminfo: + memtotal_re = re.compile(r'^MemTotal:\s*(\d*)\s*kB') + for line in meminfo: + match = memtotal_re.match(line) + if not match: + continue + # Allow 8Gb per link on Linux because Gold is quite memory hungry + return max(1, int(match.group(1)) / (8 * (2 ** 20))) + return 1 + elif sys.platform == 'darwin': + try: + avail_bytes = int(subprocess.check_output(['sysctl', '-n', 'hw.memsize'])) + # A static library debug build of Chromium's unit_tests takes ~2.7GB, so + # 4GB per ld process allows for some more bloat. + return max(1, avail_bytes / (4 * (2 ** 30))) # total / 4GB + except: + return 1 + else: + # TODO(scottmg): Implement this for other platforms. + return 1 + +print GetDefaultConcurrentLinks() diff --git a/build/toolchain/mac/BUILD.gn b/build/toolchain/mac/BUILD.gn index 65fb7c661b..b1cd36bef4 100644 --- a/build/toolchain/mac/BUILD.gn +++ b/build/toolchain/mac/BUILD.gn @@ -117,7 +117,7 @@ template("mac_clang_toolchain") { } tool("solink") { - dylib = "{{target_output_name}}{{output_extension}}" # eg "libfoo.dylib" + dylib = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" # eg "./libfoo.dylib" rspfile = dylib + ".rsp" # These variables are not build into GN but are helpers that implement @@ -165,7 +165,7 @@ template("mac_clang_toolchain") { } tool("link") { - outfile = "{{target_output_name}}{{output_extension}}" + outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" rspfile = "$outfile.rsp" command = "$ld {{ldflags}} -o $outfile -Wl,-filelist,$rspfile {{solibs}} {{libs}}" description = "LINK $outfile" diff --git a/build/toolchain/win/BUILD.gn b/build/toolchain/win/BUILD.gn index 0a5cf87ad4..3e8cd35058 100644 --- a/build/toolchain/win/BUILD.gn +++ b/build/toolchain/win/BUILD.gn @@ -18,11 +18,18 @@ gyp_win_tool_path = rebase_path("//tools/gyp/pylib/gyp/win_tool.py", exec_script("setup_toolchain.py", [ visual_studio_path, gyp_win_tool_path, windows_sdk_path ]) +# This value will be inherited in the toolchain below. +concurrent_links = exec_script("../get_concurrent_links.py", [], "value") + # Parameters: # cpu_arch: cpu_arch to pass as a build arg # environment: File name of environment file. # force_win64 (optional): value for this build arg. template("msvc_toolchain") { + if (defined(invoker.concurrent_links)) { + concurrent_links = invoker.concurrent_links + } + env = invoker.environment toolchain(target_name) { @@ -87,8 +94,8 @@ template("msvc_toolchain") { } tool("solink") { - dllname = "{{target_output_name}}{{output_extension}}" # e.g. foo.dll - libname = "{{target_output_name}}{{output_extension}}.lib" # e.g. foo.dll.lib + dllname = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" # e.g. foo.dll + libname = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}.lib" # e.g. foo.dll.lib rspfile = "${dllname}.rsp" link_command = "$python_path gyp-win-tool link-wrapper $env False link.exe /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:${dllname}.pdb @$rspfile" @@ -104,6 +111,8 @@ template("msvc_toolchain") { dllname, libname, ] + link_output = libname + depend_output = libname # The use of inputs_newline is to work around a fixed per-line buffer # size in the linker. rspfile_content = "{{libs}} {{solibs}} {{inputs_newline}} {{ldflags}}" @@ -122,7 +131,7 @@ template("msvc_toolchain") { default_output_extension = ".exe" description = "LINK {{output}}" outputs = [ - "{{target_output_name}}{{output_extension}}", + "{{root_out_dir}}/{{target_output_name}}{{output_extension}}", ] # The use of inputs_newline is to work around a fixed per-line buffer # size in the linker. diff --git a/build/toolchain/win/midl.gni b/build/toolchain/win/midl.gni index e0c2dd4363..7f068d01b1 100644 --- a/build/toolchain/win/midl.gni +++ b/build/toolchain/win/midl.gni @@ -37,7 +37,7 @@ template("midl") { type_library_file = "{{source_name_part}}.tlb" action_foreach(action_name) { - visibility = ":$source_set_name" + visibility = [ ":$source_set_name" ] # This functionality is handled by the win-tool because the GYP build has # MIDL support built-in. diff --git a/build/util/BUILD.gn b/build/util/BUILD.gn index e8f21cfcf6..320c5ee2d3 100644 --- a/build/util/BUILD.gn +++ b/build/util/BUILD.gn @@ -2,35 +2,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# This target generates a "last_change.h" header file in the generated files -# directory that contains a define of the last revision of the source tree -# of the form: -# #define LAST_CHANGE "123456" -# -# The version is a string rather than an integer for extra flexibility (for -# example, we may require git hashes in the future). -# -# All you need to do is depend on this target, and then from your source code: -# #include "build/util/last_change.h" -action("last_change") { - script = "lastchange.py" - - # Rerun the script any time this file changes. - inputs = [ "//build/util/LASTCHANGE" ] - - output_header = "$target_gen_dir/last_change.h" - outputs = [ output_header ] - - build_relative_src = rebase_path("//", root_build_dir) - build_relative_outputs = rebase_path(output_header, root_build_dir) - - args = [ - "--source-dir=$build_relative_src", - "--header=$build_relative_outputs", - "--version-macro=LAST_CHANGE", - ] -} - action("webkit_version") { script = "version.py" diff --git a/build/util/LASTCHANGE b/build/util/LASTCHANGE index a56ba749e0..9bdbfa388e 100644 --- a/build/util/LASTCHANGE +++ b/build/util/LASTCHANGE @@ -1 +1 @@ -LASTCHANGE=291560 +LASTCHANGE=267aeeb8d85c diff --git a/build/util/LASTCHANGE.blink b/build/util/LASTCHANGE.blink index e5b01e67b1..80db225cf6 100644 --- a/build/util/LASTCHANGE.blink +++ b/build/util/LASTCHANGE.blink @@ -1 +1 @@ -LASTCHANGE=180790 +LASTCHANGE=182778 diff --git a/build/vs_toolchain.py b/build/vs_toolchain.py index 735827e943..44c3017137 100644 --- a/build/vs_toolchain.py +++ b/build/vs_toolchain.py @@ -172,7 +172,7 @@ wdk_dir = "%s" os.environ['GYP_MSVS_OVERRIDE_PATH'], os.environ['WINDOWSSDKDIR'], os.environ['GYP_MSVS_VERSION'], - os.environ['WDK_DIR']) + os.environ.get('WDK_DIR', '')) def main(): diff --git a/build/whitespace_file.txt b/build/whitespace_file.txt index aac2b5ff1d..4e9bf3837e 100644 --- a/build/whitespace_file.txt +++ b/build/whitespace_file.txt @@ -1,4 +1,4 @@ -Copyright 20014 The Chromium Authors. All rights reserved. +Copyright 2014 The Chromium Authors. All rights reserved. Use of this useless file is governed by a BSD-style license that can be found in the LICENSE file. @@ -8,7 +8,7 @@ any modification below this line. ===================================================================== -Let's make a story. Add one sentence for every commit: +Let's make a story. Add zero+ sentences for every commit: CHÄPTER 1: It was a dark and blinky night; the rain fell in torrents -- except at @@ -95,6 +95,7 @@ This sentence is false. Beauty is in the eyes of a Beholder. +I'm the best at space. The first time Yossarian saw the chaplain, he fell madly in love with him. * @@ -131,3 +132,12 @@ As the git approaches, light begins to shine through the SCM thrice again... However, the git, is, after all, quite stupid. Suddenly Domo-Kun found itself in a room filled with dazzling mirrors. + +A herd of wild gits appears! Time for CQ :D +And one more for sizes.py... + +Sigh. + +It was love at first sight. The moment Yossarian first laid eyes on the chaplain, he fell madly in love with him. + +Cool whitespace change for git-cl land diff --git a/build/win/asan.gyp b/build/win/asan.gyp new file mode 100644 index 0000000000..9107db35af --- /dev/null +++ b/build/win/asan.gyp @@ -0,0 +1,30 @@ +# Copyright (c) 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'targets': [ + { + 'target_name': 'asan_dynamic_runtime', + 'type': 'none', + 'variables': { + # Every target is going to depend on asan_dynamic_runtime, so allow + # this one to depend on itself. + 'prune_self_dependency': 1, + }, + 'conditions': [ + ['OS=="win"', { + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)', + 'files': [ + # Path is relative to this GYP file. + '<(DEPTH)/<(make_clang_dir)/bin/clang_rt.asan_dynamic-i386.dll', + ], + }, + ], + }], + ], + }, + ], +} |