diff --git a/build/BUILD.gn b/build/BUILD.gn index 58f5f20fb4b4..663413278785 100644 --- a/build/BUILD.gn +++ b/build/BUILD.gn @@ -40,6 +40,7 @@ buildflag_header("chromecast_buildflags") { header = "chromecast_buildflags.h" flags = [ + "IS_CHROMECAST=$is_chromecast", "IS_CASTOS=$is_castos", "IS_CAST_ANDROID=$is_cast_android", "ENABLE_CAST_RECEIVER=$enable_cast_receiver", diff --git a/build/android/docs/coverage.md b/build/android/docs/coverage.md index c7f3c1ffe6e0..2f362f687acf 100644 --- a/build/android/docs/coverage.md +++ b/build/android/docs/coverage.md @@ -29,6 +29,10 @@ class files and runtime **.exec** files. Then we need to process them using the 3. The coverage results of JUnit and instrumentation tests will be merged automatically if they are in the same directory. +4. If generating coverage and there are duplicate class files, as can happen + when generating coverage for downstream targets, use the + --include-substr-filter option to choose jars in the desired directory. + ## How to generate coverage report 1. Now we have generated .exec files already. We can create a JaCoCo HTML/XML/CSV diff --git a/build/android/pylib/gtest/gtest_test_instance_test.py b/build/android/pylib/gtest/gtest_test_instance_test.py index c714ba0cfc9e..6502f5f0e04c 100755 --- a/build/android/pylib/gtest/gtest_test_instance_test.py +++ b/build/android/pylib/gtest/gtest_test_instance_test.py @@ -312,6 +312,37 @@ def testParseGTestJSON_skippedTest_example(self): actual[0].GetName()) self.assertEqual(base_test_result.ResultType.SKIP, actual[0].GetType()) + def testParseGTestJSON_skippedTest_example(self): + raw_json = """ + { + "tests": { + "mojom_tests": { + "parse": { + "ast_unittest": { + "ASTTest": { + "testNodeBase": { + "expected": "SKIP", + "actual": "SKIP", + } + } + } + } + } + }, + "interrupted": false, + "path_delimiter": ".", + "version": 3, + "seconds_since_epoch": 1406662283.764424, + "num_failures_by_type": { + "SKIP": 1 + }, + }""" + actual = gtest_test_instance.ParseGTestJSON(raw_json) + self.assertEquals(1, len(actual)) + self.assertEquals('mojom_tests.parse.ast_unittest.ASTTest.testNodeBase', + actual[0].GetName()) + self.assertEquals(base_test_result.ResultType.SKIP, actual[0].GetType()) + def testTestNameWithoutDisabledPrefix_disabled(self): test_name_list = [ 'A.DISABLED_B', diff --git a/build/android/pylib/local/device/local_device_test_run.py b/build/android/pylib/local/device/local_device_test_run.py index 0e0b93033400..e3862d14b497 100644 --- a/build/android/pylib/local/device/local_device_test_run.py +++ b/build/android/pylib/local/device/local_device_test_run.py @@ -99,6 +99,13 @@ def run_tests_on_device(dev, tests, results): # of bad device detection. consecutive_device_errors = 0 + # TODO(crbug.com/1181389): Remove this workaround once the deadlocks + # in ArCore are resolved + def GetResultTypeForTest(t): + if 'WebXrAr' in self._GetUniqueTestName(t): + return base_test_result.ResultType.PASS + return base_test_result.ResultType.TIMEOUT + if isinstance(test, list): results.AddResults( base_test_result.BaseTestResult( diff --git a/build/android/pylib/results/json_results_test.py b/build/android/pylib/results/json_results_test.py index 6cf6487e54f8..8b2cb3623abc 100755 --- a/build/android/pylib/results/json_results_test.py +++ b/build/android/pylib/results/json_results_test.py @@ -270,6 +270,34 @@ def testGenerateJsonTestResultFormatDict_skippedResult(self): self.assertIn('SKIP', results_dict['num_failures_by_type']) self.assertEqual(1, results_dict['num_failures_by_type']['SKIP']) + def testGenerateJsonTestResultFormatDict_skippedResult(self): + result = base_test_result.BaseTestResult('test.package.TestName', + base_test_result.ResultType.SKIP) + + all_results = base_test_result.TestRunResults() + all_results.AddResult(result) + + results_dict = json_results.GenerateJsonTestResultFormatDict([all_results], + False) + self.assertEquals(1, len(results_dict['tests'])) + self.assertEquals(1, len(results_dict['tests']['test'])) + self.assertEquals(1, len(results_dict['tests']['test']['package'])) + self.assertEquals( + 'PASS', + results_dict['tests']['test']['package']['TestName']['expected']) + self.assertEquals( + 'FAIL', results_dict['tests']['test']['package']['TestName']['actual']) + self.assertEquals( + True, + results_dict['tests']['test']['package']['TestName']['is_unexpected']) + + self.assertTrue('FAIL' not in results_dict['num_failures_by_type'] + or results_dict['num_failures_by_type']['FAIL'] == 0) + self.assertTrue('PASS' not in results_dict['num_failures_by_type'] + or results_dict['num_failures_by_type']['PASS'] == 0) + self.assertIn('SKIP', results_dict['num_failures_by_type']) + self.assertEquals(1, results_dict['num_failures_by_type']['SKIP']) + def testGenerateJsonTestResultFormatDict_failedResultWithRetry(self): result_1 = base_test_result.BaseTestResult('test.package.TestName', base_test_result.ResultType.FAIL) diff --git a/build/build_config.h b/build/build_config.h index 6db5d9bca059..798b49467a07 100644 --- a/build/build_config.h +++ b/build/build_config.h @@ -55,7 +55,9 @@ #include "build/buildflag.h" // IWYU pragma: export // A set of macros to use for platform detection. -#if defined(__native_client__) +#if defined(STARBOARD) +// noop +#elif defined(__native_client__) // __native_client__ must be first, so that other OS_ defines are not set. #define OS_NACL 1 #elif defined(ANDROID) @@ -268,7 +270,33 @@ // http://msdn.microsoft.com/en-us/library/b0084kay.aspx // http://www.agner.org/optimize/calling_conventions.pdf // or with gcc, run: "echo | gcc -E -dM -" -#if defined(_M_X64) || defined(__x86_64__) +#if defined(STARBOARD) +#include "starboard/configuration.h" +#if SB_IS(32_BIT) +#define ARCH_CPU_32_BITS 1 +#elif SB_IS(64_BIT) +#define ARCH_CPU_64_BITS 1 +#endif // SB_IS(32_BIT) +#if SB_IS(BIG_ENDIAN) +#define ARCH_CPU_BIG_ENDIAN 1 +#else // SB_IS(BIG_ENDIAN) +#define ARCH_CPU_LITTLE_ENDIAN 1 +#endif // SB_IS(BIG_ENDIAN) +#if SB_IS(ARCH_X86) +#define ARCH_CPU_X86_FAMILY 1 +#define ARCH_CPU_X86 1 +#elif SB_IS(ARCH_X64) +#define ARCH_CPU_X86_FAMILY 1 +#define ARCH_CPU_X86_64 1 +#elif SB_IS(ARCH_ARM) || SB_IS(ARCH_ARM64) +#define ARCH_CPU_ARM_FAMILY 1 +#if SB_IS(BIG_ENDIAN) +#define ARCH_CPU_ARM 1 +#else // SB_IS(BIG_ENDIAN) +#define ARCH_CPU_ARMEL 1 +#endif // SB_IS(BIG_ENDIAN) +#endif +#elif defined(_M_X64) || defined(__x86_64__) #define ARCH_CPU_X86_FAMILY 1 #define ARCH_CPU_X86_64 1 #define ARCH_CPU_64_BITS 1 @@ -355,7 +383,13 @@ #endif // Type detection for wchar_t. -#if defined(OS_WIN) +#if defined(STARBOARD) +#if SB_IS(WCHAR_T_UTF16) +#define WCHAR_T_IS_UTF16 +#elif SB_IS(WCHAR_T_UTF32) +#define WCHAR_T_IS_UTF32 +#endif +#elif defined(OS_WIN) #define WCHAR_T_IS_UTF16 #elif defined(OS_FUCHSIA) #define WCHAR_T_IS_UTF32 diff --git a/build/config/BUILD.gn b/build/config/BUILD.gn index 749b0855ff2a..2106261c1f2c 100644 --- a/build/config/BUILD.gn +++ b/build/config/BUILD.gn @@ -245,7 +245,7 @@ group("common_deps") { public_deps += [ "//build/config/sanitizers:deps" ] } - if (use_custom_libcxx) { + if (!is_starboard && use_custom_libcxx) { public_deps += [ "//buildtools/third_party/libc++" ] } diff --git a/build/config/android/internal_rules.gni b/build/config/android/internal_rules.gni index 41abf539fe96..427fa0dca401 100644 --- a/build/config/android/internal_rules.gni +++ b/build/config/android/internal_rules.gni @@ -15,7 +15,7 @@ import("//build/toolchain/goma.gni") import("//build/toolchain/kythe.gni") import("//build/util/generate_wrapper.gni") import("//build_overrides/build.gni") -if (current_toolchain == default_toolchain) { +if (is_starboardized_toolchain || current_toolchain == default_toolchain) { import("//build/toolchain/concurrent_links.gni") } assert(is_android) diff --git a/build/config/apple/sdk_info.py b/build/config/apple/sdk_info.py index 81b06d438df1..bac73feec791 100755 --- a/build/config/apple/sdk_info.py +++ b/build/config/apple/sdk_info.py @@ -134,7 +134,8 @@ def main(): default='.', help='Value of gn $root_build_dir') parser.add_argument('platform', - choices=['iphoneos', 'iphonesimulator', 'macosx']) + choices=['iphoneos', 'iphonesimulator', 'macosx', + 'appletvos']) args = parser.parse_args() if args.developer_dir: os.environ['DEVELOPER_DIR'] = args.developer_dir diff --git a/build/config/arm.gni b/build/config/arm.gni index cc82ed5ba922..8d180ad64c4b 100644 --- a/build/config/arm.gni +++ b/build/config/arm.gni @@ -5,6 +5,10 @@ import("//build/config/chromeos/ui_mode.gni") import("//build/config/v8_target_cpu.gni") +if (is_starboard) { + import("//starboard/sabi/sabi.gni") +} + # These are primarily relevant in current_cpu == "arm" contexts, where # ARM code is being compiled. But they can also be relevant in the # other contexts when the code will change its behavior based on the @@ -45,14 +49,19 @@ if (current_cpu == "arm" || v8_current_cpu == "arm") { arm_arch = "armv8-a+crc" } - if (current_os == "android" || target_os == "android") { - arm_float_abi = "softfp" + if (is_starboard) { + arm_float_abi = sabi_variables.floating_point_abi + arm_fpu = sabi_variables.floating_point_fpu } else { - declare_args() { - # The ARM floating point mode. This is either the string "hard", "soft", - # or "softfp". An empty string means to use the default one for the - # arm_version. - arm_float_abi = "" + if (current_os == "android" || target_os == "android") { + arm_float_abi = "softfp" + } else { + declare_args() { + # The ARM floating point mode. This is either the string "hard", "soft", + # or "softfp". An empty string means to use the default one for the + # arm_version. + arm_float_abi = "" + } } } assert(arm_float_abi == "" || arm_float_abi == "hard" || diff --git a/build/config/clang/clang.gni b/build/config/clang/clang.gni index 1aad3d60b840..ff978bcd0dde 100644 --- a/build/config/clang/clang.gni +++ b/build/config/clang/clang.gni @@ -4,7 +4,9 @@ import("//build/toolchain/toolchain.gni") -default_clang_base_path = "//third_party/llvm-build/Release+Asserts" +if (!use_cobalt_customizations) { + default_clang_base_path = "//third_party/llvm-build/Release+Asserts" +} declare_args() { # Indicates if the build should use the Chrome-specific plugins for enforcing @@ -18,5 +20,7 @@ declare_args() { build_with_chromium && !is_official_build && ((is_linux && !is_castos) || (is_android && !is_cast_android)) - clang_base_path = default_clang_base_path + if (!use_cobalt_customizations) { + clang_base_path = default_clang_base_path + } } diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 28c2255ba809..12742fd5c37b 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -12,7 +12,9 @@ import("//build/config/clang/clang.gni") import("//build/config/compiler/compiler.gni") import("//build/config/coverage/coverage.gni") import("//build/config/dcheck_always_on.gni") +if (!use_cobalt_customizations) { import("//build/config/gclient_args.gni") +} import("//build/config/host_byteorder.gni") import("//build/config/rust.gni") import("//build/config/sanitizers/sanitizers.gni") @@ -1407,7 +1409,8 @@ config("compiler_deterministic") { } config("clang_revision") { - if (is_clang && clang_base_path == default_clang_base_path) { + if (!use_cobalt_customizations && is_clang && + clang_base_path == default_clang_base_path) { update_args = [ "--print-revision", "--verify-version=$clang_version", @@ -1481,7 +1484,7 @@ config("runtime_library") { # android:runtime_library. This is to ensure libc++ appears before # libandroid_support in the -isystem include order. Otherwise, there will be # build errors related to symbols declared in math.h. - if (use_custom_libcxx) { + if (!use_cobalt_customizations && use_custom_libcxx) { configs += [ "//build/config/c++:runtime_library" ] } @@ -1565,7 +1568,7 @@ config("default_warnings") { # Suppress warnings about ABI changes on ARM (Clang doesn't give this # warning). - if (current_cpu == "arm" && !is_clang) { + if (!is_starboard && current_cpu == "arm" && !is_clang) { cflags += [ "-Wno-psabi" ] } @@ -1610,7 +1613,7 @@ config("default_warnings") { "-Wno-unused-parameter", # Unused function parameters. ] - if (!is_nacl || is_nacl_saigo) { + if (!is_starboard && (!is_nacl || is_nacl_saigo)) { cflags += [ # An ABI compat warning we don't care about, https://crbug.com/1102157 # TODO(thakis): Push this to the (few) targets that need it, @@ -1628,8 +1631,19 @@ config("default_warnings") { # which we no longer use. Check if it makes sense to remove # this as well. http://crbug.com/316352 "-Wno-unneeded-internal-declaration", + + "-Wno-extra-semi", + "-Wno-pessimizing-move", + "-Wno-shadow", ] + if (use_cobalt_customizations) { + cflags += [ + "-Wno-range-loop-bind-reference", + "-Wno-range-loop-construct", + ] + } + if (!is_nacl || is_nacl_saigo) { if (is_win) { # TODO(thakis): https://crbug.com/617318 @@ -1637,15 +1651,17 @@ config("default_warnings") { cflags += [ "-Wno-nonportable-include-path" ] } - cflags += [ - "-Wenum-compare-conditional", + if (!use_cobalt_customizations) { + cflags += [ + "-Wenum-compare-conditional", - # Ignore warnings about MSVC optimization pragmas. - # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662 - "-Wno-ignored-pragma-optimize", - ] + # Ignore warnings about MSVC optimization pragmas. + # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662 + "-Wno-ignored-pragma-optimize", + ] + } - if (!is_nacl) { + if (!use_cobalt_customizations && !is_nacl) { cflags += [ # TODO(crbug.com/1343975) Evaluate and possibly enable. "-Wno-deprecated-builtins", @@ -1685,13 +1701,18 @@ config("default_warnings") { # configs += [ "//build/config/compiler:prevent_unsafe_narrowing" ] config("prevent_unsafe_narrowing") { + cflags = [] if (is_clang) { - cflags = [ - "-Wshorten-64-to-32", + cflags += [ "-Wimplicit-int-conversion", "-Wsign-compare", "-Wsign-conversion", ] + if (!is_starboard) { + cflags += [ + "-Wshorten-64-to-32", + ] + } if (!is_nacl) { cflags += [ # Avoid bugs of the form `if (size_t i = size; i >= 0; --i)` while @@ -1709,12 +1730,24 @@ config("prevent_unsafe_narrowing") { config("chromium_code") { if (is_win) { - if (is_clang) { - cflags = [ "/W4" ] # Warning level 4. + if (is_starboard) { + # The platform should set warning flags. + cflags = [] + } else { + if (is_clang) { + cflags = [ "/W4" ] # Warning level 4. - # Opt in to additional [[nodiscard]] on standard library methods. - defines = [ "_HAS_NODISCARD" ] + # Opt in to additional [[nodiscard]] on standard library methods. + defines = [ "_HAS_NODISCARD" ] + } } + } else if (is_starboard) { + # TODO(b/205790602): Revisit this code to be more compatible with platforms. + defines = [ + "__STDC_CONSTANT_MACROS", + "__STDC_FORMAT_MACROS", + ] + cflags = [ "-Werror" ] } else { cflags = [ "-Wall" ] if (treat_warnings_as_errors) { @@ -1773,13 +1806,38 @@ config("chromium_code") { # For intentional fallthrough, use [[fallthrough]]. "-Wimplicit-fallthrough", - # Warn on unnecessary extra semicolons outside of function definitions. - "-Wextra-semi", ] + if (!is_starboard) { + cflags += [ + # Warn on unnecessary extra semicolons outside of function definitions. + "-Wextra-semi", + ] + } + + # Suppress warning in old //net. + if (is_starboard) { + cflags += [ + "-Wno-reorder-ctor", + "-Wno-unused-const-variable", + "-Wno-unused-variable", + "-Wno-unused-private-field", + "-Wno-missing-braces", + "-Wno-string-concatenation", + ] + } + + # Suppress warnings in old //base and //net. + if (is_starboard) { + cflags += [ + "-Wno-sign-compare", + "-Wno-shorten-64-to-32", + ] + } + # TODO(thakis): Enable this more often, https://crbug.com/346399 # use_fuzzing_engine_with_lpm: https://crbug.com/1063180 - if ((!is_nacl || is_nacl_saigo) && !use_fuzzing_engine_with_lpm) { + if (!is_starboard && (!is_nacl || is_nacl_saigo) && !use_fuzzing_engine_with_lpm) { cflags += [ "-Wunreachable-code-aggressive" ] } @@ -1793,10 +1851,13 @@ config("chromium_code") { } } - configs = [ - ":default_warnings", - ":noshadowing", - ] + configs = [ ":default_warnings" ] + + if (!is_starboard) { + configs += [ + ":noshadowing", + ] + } } config("no_chromium_code") { @@ -1805,7 +1866,7 @@ config("no_chromium_code") { defines = [] if (is_win) { - if (is_clang) { + if (!is_starboard && is_clang) { cflags += [ "/W3" ] # Warning level 3. } cflags += [ @@ -1836,7 +1897,8 @@ config("no_chromium_code") { # third-party libraries. "-Wno-c++11-narrowing", ] - if (!is_nacl) { + if (!use_cobalt_customizations && !is_nacl && + (current_toolchain == host_toolchain || !use_xcode_clang)) { cflags += [ # Disabled for similar reasons as -Wunused-variable. "-Wno-unused-but-set-variable", @@ -1985,6 +2047,50 @@ config("wexit_time_destructors") { } } +# On Windows compiling on x64, VC will issue a warning when converting +# size_t to int because it will truncate the value. Our code should not have +# these warnings and one should use a static_cast or a checked_cast for the +# conversion depending on the case. However, a lot of code still needs to be +# fixed. Apply this config to such targets to disable the warning. +# +# Note that this can be applied regardless of platform and architecture to +# clean up the call sites. This will only apply the flag when necessary. +# +# This config is just an alias to no_shorten_64_warnings and will +# suppress a superset of warning 4267 and any 64-bit -> 32-bit implicit +# conversions. Having both for a time means not having to go through and +# update all references to no_size_t_to_int_warning throughout the codebase +# atomically. +# +# Any new warning suppressions should use the no_shorten_64_warnings +# config below and not this. +# +# TODO(jschuh): crbug.com/167187 fix this and delete this config. +config("no_size_t_to_int_warning") { + configs = [ ":no_shorten_64_warnings" ] +} + +# As part of re-enabling -Wconversion (see issue 588506) some code +# will continue to generate warnings. +# The first warning to be enabled will be -Wshorten-64-to-32. +# +# Code that currently generates warnings for this can include this +# config to disable them. +config("no_shorten_64_warnings") { + if (current_cpu == "x64" || current_cpu == "arm64") { + if (is_clang) { + cflags = [ "-Wno-shorten-64-to-32" ] + } else { + if (is_win) { + # MSVC does not have an explicit warning equivalent to + # -Wshorten-64-to-32 but 4267 warns for size_t -> int + # on 64-bit builds, so is the closest. + cflags = [ "/wd4267" ] + } + } + } +} + # Some code presumes that pointers to structures/objects are compatible # regardless of whether what they point to is already known to be valid. # gcc 4.9 and earlier had no way of suppressing this warning without @@ -2016,11 +2122,15 @@ config("no_incompatible_pointer_warnings") { # Shared settings for both "optimize" and "optimize_max" configs. # IMPORTANT: On Windows "/O1" and "/O2" must go before the common flags. if (is_win) { + if (is_starboard) { + common_optimize_on_cflags = [] + } else { common_optimize_on_cflags = [ "/Ob2", # Both explicit and auto inlining. "/Oy-", # Disable omitting frame pointers, must be after /O2. "/Zc:inline", # Remove unreferenced COMDAT (faster links). ] + } if (!is_asan) { common_optimize_on_cflags += [ # Put data in separate COMDATs. This allows the linker diff --git a/build/config/compiler/compiler.gni b/build/config/compiler/compiler.gni index 4738ee80d307..aa5f37fd0b06 100644 --- a/build/config/compiler/compiler.gni +++ b/build/config/compiler/compiler.gni @@ -37,6 +37,10 @@ declare_args() { # The default linker everywhere else. use_lld = is_clang && current_os != "zos" + if (use_cobalt_customizations && is_apple) { + use_lld = false + } + # If true, optimize for size. # Default to favoring speed over size for platforms not listed below. optimize_for_size = diff --git a/build/config/dcheck_always_on.gni b/build/config/dcheck_always_on.gni index cca3a547cd55..c14c5882ace8 100644 --- a/build/config/dcheck_always_on.gni +++ b/build/config/dcheck_always_on.gni @@ -5,7 +5,6 @@ # TODO(crbug.com/1233050): Until the bug is resolved we need to include # gclient_args for the definition of build_with_chromium and build_overrides # for client overrides of that flag. The latter should go away. -import("//build/config/gclient_args.gni") import("//build_overrides/build.gni") declare_args() { # Enables DCHECKs to be built-in, but to default to being non-fatal/log-only. diff --git a/build/config/fuchsia/test/web_instance_host_capabilities.test-cmx b/build/config/fuchsia/test/web_instance_host_capabilities.test-cmx new file mode 100644 index 000000000000..762916ba9f6d --- /dev/null +++ b/build/config/fuchsia/test/web_instance_host_capabilities.test-cmx @@ -0,0 +1,8 @@ +{ + "sandbox": { + "services": [ + "fuchsia.sys.Environment", + "fuchsia.sys.Loader" + ] + } +} \ No newline at end of file diff --git a/build/config/mac/mac_sdk.gni b/build/config/mac/mac_sdk.gni index d3c4e3c7fdd1..db7c236d726f 100644 --- a/build/config/mac/mac_sdk.gni +++ b/build/config/mac/mac_sdk.gni @@ -3,7 +3,9 @@ # found in the LICENSE file. import("//build/config/chrome_build.gni") +if (!is_starboard) { import("//build/config/gclient_args.gni") +} import("//build/config/mac/mac_sdk_overrides.gni") import("//build/toolchain/goma.gni") import("//build/toolchain/rbe.gni") diff --git a/build/config/ozone.gni b/build/config/ozone.gni index 8bb512ad634b..00eac5ee5bd3 100644 --- a/build/config/ozone.gni +++ b/build/config/ozone.gni @@ -9,7 +9,7 @@ import("//build/toolchain/toolchain.gni") declare_args() { # Indicates if Ozone is enabled. Ozone is a low-level library layer for Linux # that does not require X11. - use_ozone = is_chromeos || is_fuchsia || is_linux + use_ozone = is_chromeos || is_fuchsia || is_linux && !is_starboard } declare_args() { diff --git a/build/config/pch.gni b/build/config/pch.gni index bc4e9e6d150b..9cb42033189f 100644 --- a/build/config/pch.gni +++ b/build/config/pch.gni @@ -11,5 +11,5 @@ declare_args() { # doing official builds. # On Linux it slows down the build, so don't enable it by default. enable_precompiled_headers = - !is_official_build && !(use_goma || use_remoteexec) && !is_linux + !is_official_build && !(use_goma || use_remoteexec) && !is_linux && !is_starboard } diff --git a/build/config/sanitizers/BUILD.gn b/build/config/sanitizers/BUILD.gn index c320ed8d9969..67ca2ed253f5 100644 --- a/build/config/sanitizers/BUILD.gn +++ b/build/config/sanitizers/BUILD.gn @@ -123,10 +123,12 @@ static_library("options_sources") { ] sources = [ "//build/sanitizers/sanitizer_options.cc" ] + if (!use_cobalt_customizations) { # Don't compile this target with any sanitizer code. It can be called from # the sanitizer runtimes, so instrumenting these functions could cause # recursive calls into the runtime if there is an error. configs -= [ "//build/config/sanitizers:default_sanitizer_flags" ] + } if (is_asan) { if (!defined(asan_suppressions_file)) { diff --git a/build/config/sysroot.gni b/build/config/sysroot.gni index dea380727e73..b81eb0055745 100644 --- a/build/config/sysroot.gni +++ b/build/config/sysroot.gni @@ -22,6 +22,10 @@ declare_args() { use_sysroot = current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm" || current_cpu == "arm64" || current_cpu == "mipsel" || current_cpu == "mips64el" + + if (use_cobalt_customizations) { + use_sysroot = false + } } if (sysroot == "") { diff --git a/build/config/ui.gni b/build/config/ui.gni index b560f372c638..f9e6bb9a6141 100644 --- a/build/config/ui.gni +++ b/build/config/ui.gni @@ -23,6 +23,11 @@ import("//build/config/chromeos/ui_mode.gni") import("//build/config/ozone.gni") declare_args() { + # Indicates if the UI toolkit depends on X11. + # Enabled by default. Can be disabled if Ozone only build is required and + # vice-versa. + use_x11 = is_linux && !is_chromecast && !is_chromeos_lacros + # Indicates if Aura is enabled. Aura is a low-level windowing library, sort # of a replacement for GDI or GTK. use_aura = is_win || is_linux || is_chromeos || is_fuchsia @@ -33,7 +38,7 @@ declare_args() { toolkit_views = is_mac || is_win || is_linux || is_chromeos || is_fuchsia use_glib = - is_linux && !is_castos && + is_linux && !is_castos && !is_starboard && # Avoid the need for glib when Android is building things via secondary # toolchains. target_os != "android" diff --git a/build/config/win/BUILD.gn b/build/config/win/BUILD.gn index 8a3bfbbb526e..a0a28102a789 100644 --- a/build/config/win/BUILD.gn +++ b/build/config/win/BUILD.gn @@ -9,7 +9,9 @@ import("//build/config/compiler/compiler.gni") import("//build/config/sanitizers/sanitizers.gni") import("//build/config/win/control_flow_guard.gni") import("//build/config/win/visual_studio_version.gni") +if (!is_starboard) { import("//build/timestamp.gni") +} import("//build/toolchain/goma.gni") import("//build/toolchain/rbe.gni") import("//build/toolchain/toolchain.gni") diff --git a/build/config/win/visual_studio_version.gni b/build/config/win/visual_studio_version.gni index 1da479dd5eeb..5c2c27e8732c 100644 --- a/build/config/win/visual_studio_version.gni +++ b/build/config/win/visual_studio_version.gni @@ -2,6 +2,47 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +if (is_starboard) { + declare_args() { + visual_studio_version = "14.34.31933" + + # Full path to the Windows SDK, not including a backslash at the end. + # This value is the default location, override if you have a different + # installation location. + windows_sdk_path = "C:/Program Files (x86)/Windows Kits/10" + + # Version of Windows SDK. XB1 requires >=10.0.22000.0. + if (current_os == "winuwp") { + wdk_version = "10.0.22000.0" + } else { + wdk_version = "10.0.18362.0" + } + } + + if (is_docker_build) { + _default_visual_studio_path = "C:/BuildTools" + } else { + _default_visual_studio_path = getenv("VSINSTALLDIR") + if (_default_visual_studio_path == "") { + _default_visual_studio_path = "C:/Program Files (x86)/Microsoft Visual Studio/2022/Professional" + } + } + + declare_args() { + # Path to Visual Studio. + visual_studio_path = _default_visual_studio_path + + wdk_include_path = "$windows_sdk_path/include/$wdk_version" + + wdk_lib_path = "$windows_sdk_path/lib/$wdk_version" + } + + declare_args() { + msvc_path = "$visual_studio_path/VC/Tools/MSVC/$visual_studio_version" + + llvm_clang_path = "$visual_studio_path/VC/Tools/Llvm/x64/bin" + } +} else { declare_args() { # Path to Visual Studio. If empty, the default is used which is to use the # automatic toolchain in depot_tools. If set, you must also set the @@ -23,6 +64,7 @@ declare_args() { # Version of the Windows SDK pointed to by the windows_sdk_path. windows_sdk_version = "" } +} if (visual_studio_path == "") { toolchain_data = @@ -33,7 +75,7 @@ if (visual_studio_path == "") { visual_studio_version = toolchain_data.vs_version wdk_path = toolchain_data.wdk_dir visual_studio_runtime_dirs = toolchain_data.runtime_dirs -} else { +} else if (!is_starboard) { assert(visual_studio_version != "", "You must set the visual_studio_version if you set the path") assert(windows_sdk_version != "", diff --git a/build/lacros/lacros_resource_sizes.pydeps b/build/lacros/lacros_resource_sizes.pydeps index c2437ca51252..dc6a11699674 100644 --- a/build/lacros/lacros_resource_sizes.pydeps +++ b/build/lacros/lacros_resource_sizes.pydeps @@ -1,5 +1,6 @@ # Generated by running: # build/print_python_deps.py --root build/lacros --output build/lacros/lacros_resource_sizes.pydeps build/lacros/lacros_resource_sizes.py +../../third_party/catapult/third_party/six/six.py ../../third_party/catapult/third_party/vinn/vinn/__init__.py ../../third_party/catapult/third_party/vinn/vinn/_vinn.py ../../third_party/catapult/tracing/tracing/__init__.py diff --git a/build/lacros/test_runner.py b/build/lacros/test_runner.py index ab319dec62e3..856acd012e69 100755 --- a/build/lacros/test_runner.py +++ b/build/lacros/test_runner.py @@ -843,6 +843,16 @@ def Main(): action='store_true', help='Whether to run subprocess log outputs through the asan symbolizer.') + # This is for version skew testing. The current CI/CQ builder builds + # an ash chrome and pass it using --ash-chrome-path. In order to use the same + # builder for version skew testing, we use a new argument to override + # the ash chrome. + test_parser.add_argument( + '--ash-chrome-path-override', + type=str, + help='The same as --ash-chrome-path. But this will override ' + '--ash-chrome-path or --ash-chrome-version if any of these ' + 'arguments exist.') args = arg_parser.parse_known_args() if not hasattr(args[0], "func"): # No command specified. diff --git a/build/toolchain/BUILD.gn b/build/toolchain/BUILD.gn index a3bd8c58cc70..73e3a71cc21b 100644 --- a/build/toolchain/BUILD.gn +++ b/build/toolchain/BUILD.gn @@ -11,7 +11,7 @@ declare_args() { action_pool_depth = -1 } -if (current_toolchain == default_toolchain) { +if (is_starboardized_toolchain || current_toolchain == default_toolchain) { if (action_pool_depth == -1 || (use_goma || use_remoteexec)) { action_pool_depth = exec_script("get_cpu_count.py", [], "value") } diff --git a/build/toolchain/apple/toolchain.gni b/build/toolchain/apple/toolchain.gni index 70d7c036392a..a3803e157d0b 100644 --- a/build/toolchain/apple/toolchain.gni +++ b/build/toolchain/apple/toolchain.gni @@ -157,7 +157,20 @@ template("single_apple_toolchain") { toolchain_is_component_build = is_component_build } - prefix = rebase_path("$clang_base_path/bin/", root_build_dir) + if (defined(toolchain_args.use_xcode_clang)) { + toolchain_uses_xcode_clang = toolchain_args.use_xcode_clang + } else { + toolchain_uses_xcode_clang = use_xcode_clang + } + + # Supports building with the version of clang shipped with Xcode when + # targeting iOS by not respecting clang_base_path. + if (toolchain_uses_xcode_clang) { + prefix = invoker.bin_path + } else { + prefix = rebase_path("$clang_base_path/bin/", root_build_dir) + } + _cc = "${prefix}clang" _cxx = "${prefix}clang++" diff --git a/build/toolchain/cc_wrapper.gni b/build/toolchain/cc_wrapper.gni index d70fa7f23427..577a1fbef63e 100644 --- a/build/toolchain/cc_wrapper.gni +++ b/build/toolchain/cc_wrapper.gni @@ -35,6 +35,46 @@ import("//build/toolchain/rbe.gni") declare_args() { # Set to "ccache", "icecc" or "distcc". Probably doesn't work on windows. cc_wrapper = "" + + if (is_starboard) { + enable_sccache = getenv("SCCACHE") == "1" + } +} + +if (is_starboard) { + declare_args() { + # Set to false to completely ignore the cc_wrapper. + enable_cc_wrapper = true + } + assert(enable_cc_wrapper || cc_wrapper == "", + "Do not set `cc_wrapper` if you set `enable_cc_wrapper` to false.") +} + +if (is_starboard && getenv("SCCACHE") == "") { + enable_sccache = host_os == "win" && cobalt_fastbuild +} + +if (is_starboard && enable_sccache) { + _set_sccache_gcs_bucket = getenv("SCCACHE_GCS_BUCKET") != "" + _set_sccache_gcs_key_path = getenv("SCCACHE_GCS_KEY_PATH") != "" + _set_sccache_gcs_oauth_url = getenv("SCCACHE_GCS_OAUTH_URL") != "" + _set_sccache_gcs_rw_mode = getenv("SCCACHE_GCS_RW_MODE") != "" + _set_sccache_dir = getenv("SCCACHE_DIR") != "" + assert(_set_sccache_dir || + (_set_sccache_gcs_bucket && + (_set_sccache_gcs_key_path || _set_sccache_gcs_oauth_url) && + _set_sccache_gcs_rw_mode), + "Set Sccache environment variables before use.") +} + +if (is_starboard && cc_wrapper == "" && enable_cc_wrapper) { + # TODO(https://crbug.com/gn/273): Use sccache locally as well. + if (enable_sccache) { + cc_wrapper = "sccache" + } else if (host_os != "win") { + cc_wrapper = "ccache" + } + print("Build Accelerator: " + cc_wrapper) } assert(!use_goma || cc_wrapper == "", diff --git a/build/toolchain/concurrent_links.gni b/build/toolchain/concurrent_links.gni index e3590228e347..a10a5cd526fc 100644 --- a/build/toolchain/concurrent_links.gni +++ b/build/toolchain/concurrent_links.gni @@ -20,10 +20,10 @@ declare_args() { # links at once than we do compiles, because linking is memory-intensive. # The default to use varies by platform and by the amount of memory # available, so we call out to a script to get the right value. - concurrent_links = -1 + concurrent_links = getenv("COBALT_CONCURRENT_LINKS") } -if (concurrent_links == -1) { +if (concurrent_links == "") { if (use_thin_lto) { _args = [ "--reserve_mem_gb=10" ] if (use_goma_thin_lto) { diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni index ad994319cd6f..422ed5570bfd 100644 --- a/build/toolchain/gcc_toolchain.gni +++ b/build/toolchain/gcc_toolchain.gni @@ -13,6 +13,10 @@ import("//build/toolchain/goma.gni") import("//build/toolchain/rbe.gni") import("//build/toolchain/toolchain.gni") +if (use_cobalt_customizations) { + import("//starboard/build/config/os_definitions.gni") +} + if (is_nacl) { # To keep NaCl variables out of builds that don't include NaCl, all # variables defined in nacl/config.gni referenced here should be protected by @@ -113,6 +117,10 @@ if (enable_resource_allowlist_generation) { # without sanitizers for host-side tools. template("single_gcc_toolchain") { toolchain(target_name) { + is_starboard_toolchain = target_name == "starboard" + if (!sb_is_modular || sb_is_evergreen) { + not_needed(["is_starboard_toolchain"]) + } assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value") assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value") assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value") @@ -132,6 +140,12 @@ template("single_gcc_toolchain") { assert(defined(invoker.toolchain_args), "Toolchains must specify toolchain_args") invoker_toolchain_args = invoker.toolchain_args + if (is_starboard && !defined(invoker_toolchain_args.current_cpu)) { + invoker_toolchain_args.current_cpu = target_cpu + } + if (is_starboard && !defined(invoker_toolchain_args.current_os)) { + invoker_toolchain_args.current_os = target_os + } assert(defined(invoker_toolchain_args.current_cpu), "toolchain_args must specify a current_cpu") assert(defined(invoker_toolchain_args.current_os), @@ -142,11 +156,13 @@ template("single_gcc_toolchain") { toolchain_args = { # Populate toolchain args from the invoker. forward_variables_from(invoker_toolchain_args, "*") + build_with_separate_cobalt_toolchain = build_with_separate_cobalt_toolchain # The host toolchain value computed by the default toolchain's setup # needs to be passed through unchanged to all secondary toolchains to # ensure that it's always the same, regardless of the values that may be # set on those toolchains. + if (!use_cobalt_customizations) { host_toolchain = host_toolchain # The same applies to the toolchain we use to build Rust procedural @@ -156,6 +172,7 @@ template("single_gcc_toolchain") { if (!defined(invoker_toolchain_args.v8_current_cpu)) { v8_current_cpu = invoker_toolchain_args.current_cpu } + } } # When the invoker has explicitly overridden use_remoteexec, use_goma or @@ -295,9 +312,9 @@ template("single_gcc_toolchain") { "\"$python_path\" ${_coverage_wrapper} " + compiler_prefix } - cc = compiler_prefix + invoker.cc - cxx = compiler_prefix + invoker.cxx - asm = asm_prefix + invoker.cc + cc = "$compiler_prefix\"${invoker.cc}\"" + cxx = "$compiler_prefix\"${invoker.cxx}\"" + asm = "$asm_prefix\"${invoker.cc}\"" ar = invoker.ar ld = link_prefix + invoker.ld if (defined(invoker.readelf)) { @@ -381,6 +398,12 @@ template("single_gcc_toolchain") { # Object files go in this directory. object_subdir = "{{target_out_dir}}/{{label_name}}" + if (defined(invoker.tail_lib_dependencies)) { + tail_lib_dependencies = " " + invoker.tail_lib_dependencies + } else { + tail_lib_dependencies = "" + } + tool("cc") { depfile = "{{output}}.d" precompiled_header_type = "gcc" @@ -402,7 +425,16 @@ template("single_gcc_toolchain") { tool("asm") { # For GCC we can just use the C compiler to compile assembly. depfile = "{{output}}.d" - command = "$asm $md -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{asmflags}}${extra_asmflags} -c {{source}} -o {{output}}" + + # TODO(b/206642994): see if we can remove this condition. It's needed for + # now to add cflags for evergreen platforms but we haven't yet decided + # whether cflags should be added here for all platforms. + if (!is_starboard_toolchain && is_starboard && sb_is_modular) { + command = "$asm $md -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{asmflags}}${extra_asmflags} -c {{source}} -o {{output}}" + } else { + command = "$asm $md -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{asmflags}}${extra_asmflags} -c {{source}} -o {{output}}" + } + depsformat = "gcc" description = "ASM {{output}}" outputs = [ "$object_subdir/{{source_name_part}}.o" ] @@ -637,7 +669,17 @@ template("single_gcc_toolchain") { start_group_flag = "-Wl,--start-group" end_group_flag = "-Wl,--end-group " } - link_command = "$ld {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" $start_group_flag @\"$rspfile\" {{solibs}} $end_group_flag {{libs}} {{rlibs}}" + + if (using_old_compiler) { + link_command = "$ld {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" $start_group_flag @\"$rspfile\" {{solibs}} $end_group_flag {{libs}} $tail_lib_dependencies" + } else { + # Windows based platform modular builds dont link directly with the shared library. + if (is_host_win && sb_is_modular) { + link_command = "$ld {{ldflags}}${extra_ldflags} {{libs}} -o \"$unstripped_outfile\" $start_group_flag @\"$rspfile\" $end_group_flag$tail_lib_dependencies" + } else { + link_command = "$ld {{ldflags}}${extra_ldflags} {{libs}} -o \"$unstripped_outfile\" $start_group_flag @\"$rspfile\" {{solibs}} $end_group_flag$tail_lib_dependencies" + } + } # Generate a map file to be used for binary size analysis. # Map file adds ~10% to the link time on a z620. @@ -858,6 +900,9 @@ template("gcc_toolchain") { # actually just be doing a native compile. The invoker can optionally override # use_gold too. template("clang_toolchain") { + if (is_starboard) { + clang_base_path = invoker.clang_base_path + } gcc_toolchain(target_name) { _path = "$clang_base_path/bin" _is_path_absolute = get_path_info(_path, "abspath") == _path diff --git a/build/toolchain/ios/compile_xcassets.py b/build/toolchain/ios/compile_xcassets.py index a62b96a4d7b6..418bde507b6c 100644 --- a/build/toolchain/ios/compile_xcassets.py +++ b/build/toolchain/ios/compile_xcassets.py @@ -46,6 +46,15 @@ def FixAbsolutePathInLine(line, relative_paths): return relative_path + line[len(absolute_path):] +def FixAbsolutePathInLine(line, relative_paths): + """Fix absolute paths present in |line| to relative paths.""" + absolute_path = line.split(':')[0] + relative_path = relative_paths.get(absolute_path, absolute_path) + if absolute_path == relative_path: + return line + return relative_path + line[len(absolute_path):] + + def FilterCompilerOutput(compiler_output, relative_paths): """Filers actool compilation output. diff --git a/build/toolchain/win/msvc_toolchain.gni b/build/toolchain/win/msvc_toolchain.gni new file mode 100644 index 000000000000..01c3ebbdcf69 --- /dev/null +++ b/build/toolchain/win/msvc_toolchain.gni @@ -0,0 +1,244 @@ +# Copyright 2021 The Cobalt Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +assert(use_cobalt_customizations) + +import("//build/toolchain/cc_wrapper.gni") +import("//build/toolchain/toolchain.gni") + +tool_wrapper_path = rebase_path("tool_wrapper.py", root_build_dir) + +template("msvc_toolchain") { + # Write the environment variables file in the out directory. + required_environment_variables = [ + "SYSTEMROOT", + "TEMP", + "TMP", + ] + optional_environment_variables = [ + "INCLUDE", + "LIB", + "PATH", + "PATHEXT", + "XEDK", # TODO: What does this do? + "IS_DOCKER", # needed for ninja to invoke docker-specific logic + "IS_CI", # needed for ninja to exclude some logic on GKE + + # The remaining variables should be explicitly enumerated. + # "cell_.*", + # "sn_.*", + # "sce_.*", + ] + + environment_key_value_pairs = [] + + foreach(key, required_environment_variables) { + value = getenv(key) + assert(value != "", "Envionment variable $key is required to be set.") + environment_key_value_pairs += [ "$key=$value" ] + } + foreach(key, optional_environment_variables) { + value = getenv(key) + if (value != "") { + environment_key_value_pairs += [ "$key=$value" ] + } + } + + nul = "$0x00" + env_block = string_join(nul, environment_key_value_pairs) + nul + + # If the default toolchain shares its name with another toolchain, + # there could be a deadlock where both toolchains try to write to the same environment file. + # See b/297227714 for more context. + write_file("$root_build_dir/$target_name/environment.$target_cpu", env_block) + + toolchain(target_name) { + # When invoking this toolchain not as the default one, these args will be + # passed to the build. They are ignored when this is the default toolchain. + assert(defined(invoker.toolchain_args)) + toolchain_args = { + if (defined(invoker.toolchain_args)) { + forward_variables_from(invoker.toolchain_args, "*") + } + } + + # Make these apply to all tools below. + lib_switch = "" + lib_dir_switch = "/LIBPATH:" + + # Object files go in this directory. + object_subdir = "{{target_out_dir}}/{{label_name}}" + + env = "$target_name/environment.$target_cpu" + cl = invoker.cl + lib = invoker.lib + link = invoker.link + asm = invoker.asm + + env_wrapper = "ninja -t msvc -e $env -- " # Note trailing space. + + # TODO(https://crbug.com/gn/273): Always use sccache for cc and cxx tools. + if (cc_wrapper != "") { + cl_prefix = "${cc_wrapper} " # Note trailing space. + } else { + cl_prefix = env_wrapper + } + + sys_include_flags = "" + + tool("cc") { + precompiled_header_type = "msvc" + pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb" + + # Label names may have spaces in them so the pdbname must be quoted. The + # source and output don't need to be quoted because GN knows they're a + # full file name and will quote automatically when necessary. + depsformat = "msvc" + description = "CC {{output}}" + outputs = [ "$object_subdir/{{source_name_part}}.obj" ] + + command = "$cl_prefix\"$cl\" /nologo /showIncludes $sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" + } + + tool("cxx") { + precompiled_header_type = "msvc" + + # The PDB name needs to be different between C and C++ compiled files. + pdbname = "{{target_out_dir}}/{{label_name}}_cc.pdb" + + # See comment in CC tool about quoting. + depsformat = "msvc" + description = "CXX {{output}}" + outputs = [ "$object_subdir/{{source_name_part}}.obj" ] + + command = "$cl_prefix\"$cl\" /nologo /showIncludes $sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" + } + + tool("asm") { + description = "ASM {{output}}" + outputs = [ "$object_subdir/{{source_name_part}}.obj" ] + command = "$env_wrapper$asm /nologo /Fo{{output}} /c {{defines}} {{include_dirs}} {{asmflags}} {{source}}" + } + + sys_lib_flags = "${invoker.sys_lib_flags} " # Note trailing space. + + tool("alink") { + rspfile = "{{output}}.rsp" + command = "$env_wrapper$lib /ignore:4221 /OUT:{{output}} /nologo ${sys_lib_flags}{{arflags}} @$rspfile" + description = "LIB {{output}}" + outputs = [ + # Ignore {{output_extension}} and always use .lib, there's no reason to + # allow targets to override this extension on Windows. + "{{output_dir}}/{{target_output_name}}.lib", + ] + default_output_extension = ".lib" + default_output_dir = "{{target_out_dir}}" + + # The use of inputs_newline is to work around a fixed per-line buffer + # size in the linker. + rspfile_content = "{{inputs_newline}}" + } + + # TODO(b/217794556): All following linker tools should list the PDB file in + # their outputs. It has been removed as it is not always generated, and + # ninja will treat the missing file as a dirty edge. + tool("solink") { + # E.g. "foo.dll": + dllname = "{{output_dir}}/{{target_output_name}}{{output_extension}}" + libname = "${dllname}.lib" # e.g. foo.dll.lib + pdbname = "${dllname}.pdb" + rspfile = "${dllname}.rsp" + pool = "//build/toolchain:link_pool($default_toolchain)" + + command = "$env_wrapper$link /OUT:$dllname /nologo ${sys_lib_flags}/IMPLIB:$libname /DLL /PDB:$pdbname @$rspfile" + + default_output_extension = ".dll" + default_output_dir = "{{root_out_dir}}" + description = "LINK(DLL) {{output}}" + outputs = [ + dllname, + libname, + ] + link_output = libname + depend_output = libname + runtime_outputs = [ dllname ] + + # Since the above commands only updates the .lib file when it changes, ask + # Ninja to check if the timestamp actually changed to know if downstream + # dependencies should be recompiled. + restat = true + + # 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}}" + } + + tool("solink_module") { + # E.g. "foo.dll": + dllname = "{{output_dir}}/{{target_output_name}}{{output_extension}}" + pdbname = "${dllname}.pdb" + rspfile = "${dllname}.rsp" + pool = "//build/toolchain:link_pool($default_toolchain)" + + command = "$env_wrapper$link /OUT:$dllname /nologo ${sys_lib_flags}/DLL /PDB:$pdbname @$rspfile" + + default_output_extension = ".dll" + default_output_dir = "{{root_out_dir}}" + description = "LINK_MODULE(DLL) {{output}}" + outputs = [ dllname ] + runtime_outputs = outputs + + # 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}}" + } + + tool("link") { + exename = "{{output_dir}}/{{target_output_name}}{{output_extension}}" + pdbname = "$exename.pdb" + rspfile = "$exename.rsp" + pool = "//build/toolchain:link_pool($default_toolchain)" + + command = "$env_wrapper$link /OUT:$exename /nologo ${sys_lib_flags} /PDB:$pdbname @$rspfile" + + default_output_extension = ".exe" + default_output_dir = "{{root_out_dir}}" + description = "LINK {{output}}" + outputs = [ exename ] + runtime_outputs = outputs + + # The use of inputs_newline is to work around a fixed per-line buffer + # size in the linker. + rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}" + } + + # These two are really entirely generic, but have to be repeated in + # each toolchain because GN doesn't allow a template to be used here. + # See //build/toolchain/toolchain.gni for details. + tool("stamp") { + command = stamp_command + description = stamp_description + pool = "//build/toolchain:action_pool($default_toolchain)" + } + tool("copy") { + command = copy_command + description = copy_description + pool = "//build/toolchain:action_pool($default_toolchain)" + } + + tool("action") { + pool = "//build/toolchain:action_pool($default_toolchain)" + } + } +} diff --git a/build/win/BUILD.gn b/build/win/BUILD.gn index 864581851519..cfb8d162f7d3 100644 --- a/build/win/BUILD.gn +++ b/build/win/BUILD.gn @@ -6,6 +6,10 @@ import("//build/config/clang/clang.gni") import("//build/config/sanitizers/sanitizers.gni") import("//build/config/win/manifest.gni") +if (is_starboard) { + # Never use a manifest in Starboard. + group("default_exe_manifest") {} +} else { # Depending on this target will cause the manifests for Chrome's default # Windows and common control compatibility and elevation for executables. windows_manifest("default_exe_manifest") { @@ -15,11 +19,13 @@ windows_manifest("default_exe_manifest") { default_compatibility_manifest, ] } +} if (is_win) { assert(host_os != "mac" || target_cpu != "x86", "Windows cross-builds from Mac must be 64-bit.") + if (!is_starboard) { action("copy_cdb_to_output") { script = "//build/win/copy_cdb_to_output.py" inputs = [ @@ -41,6 +47,7 @@ if (is_win) { current_cpu, ] } + } group("runtime_libs") { # These are needed for any tests that need to decode stacks. diff --git a/build_overrides/build.gni b/build_overrides/build.gni index c69e1f649542..b5c8bd720371 100644 --- a/build_overrides/build.gni +++ b/build_overrides/build.gni @@ -13,12 +13,14 @@ # limitations under the License. build_with_chromium = false +is_nacl_nonsfi = false declare_args() { # Android 32-bit non-component, non-clang builds cannot have symbol_level=2 # due to 4GiB file size limit, see https://crbug.com/648948. # Set this flag to true to skip the assertion. ignore_elf32_limitations = false + is_chromecast = false } enable_java_templates = false diff --git a/build_overrides/crypto.gni b/build_overrides/crypto.gni new file mode 100644 index 000000000000..ff40f763c88d --- /dev/null +++ b/build_overrides/crypto.gni @@ -0,0 +1,17 @@ +# Copyright 2024 The Cobalt Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + use_nss_certs = false +} diff --git a/crypto/BUILD.gn b/crypto/BUILD.gn index a8d6f2b7a30b..4208bb092d09 100644 --- a/crypto/BUILD.gn +++ b/crypto/BUILD.gn @@ -2,7 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -import("//build/config/crypto.gni") +import("//build_overrides/crypto.gni") import("//testing/test.gni") component("crypto") { diff --git a/starboard/build/config/BUILDCONFIG.gn b/starboard/build/config/BUILDCONFIG.gn index f17850279d29..bf7076396711 100644 --- a/starboard/build/config/BUILDCONFIG.gn +++ b/starboard/build/config/BUILDCONFIG.gn @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -_is_python2 = exec_script("//build/util/is_python2.py", [], "json") +_is_python2 = exec_script("//starboard/build/util/is_python2.py", [], "json") assert(!_is_python2, "`python` must resolve to Python 3 when building with GN.") declare_args() { diff --git a/starboard/build/util/is_python2.py b/starboard/build/util/is_python2.py new file mode 100644 index 000000000000..fbfa431ae76f --- /dev/null +++ b/starboard/build/util/is_python2.py @@ -0,0 +1,10 @@ +# Copyright 2024 The Cobalt Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +"""Script for checking if we're running Python 2 or 3.""" + +from __future__ import print_function + +import sys + +print("true" if sys.version_info.major == 2 else "false") diff --git a/starboard/linux/x64x11/clang/3.9/platform_configuration/BUILD.gn b/starboard/linux/x64x11/clang/3.9/platform_configuration/BUILD.gn index b2037fdd0b9c..6d6b6bd9f81f 100644 --- a/starboard/linux/x64x11/clang/3.9/platform_configuration/BUILD.gn +++ b/starboard/linux/x64x11/clang/3.9/platform_configuration/BUILD.gn @@ -97,6 +97,9 @@ config("compiler_flags") { # Suppress warnings in libjpeg "-Wno-shift-negative-value", + + # Let older Clangs ignore newer Clangs' warnings. + "-Wno-unknown-warning-option", ] cflags_c += [ diff --git a/third_party/angle/gni/angle.gni b/third_party/angle/gni/angle.gni index 75ea0c5ae4ad..26d0cff78002 100644 --- a/third_party/angle/gni/angle.gni +++ b/third_party/angle/gni/angle.gni @@ -38,7 +38,7 @@ if (angle_has_build) { if (build_with_chromium) { import("//ui/ozone/ozone.gni") -} else { +} else if (!defined(ozone_platform_gbm)) { declare_args() { ozone_platform_gbm = false }