diff --git a/base/BUILD.gn b/base/BUILD.gn index 509aa373690d..8787dc42d72b 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn @@ -34,6 +34,7 @@ if (!is_starboard) { } import("//testing/libfuzzer/fuzzer_test.gni") import("//testing/test.gni") +import("//starboard/build/config/modular/helper_variables.gni") declare_args() { # Indicates if the Location object contains the source code information @@ -1582,7 +1583,7 @@ component("base") { # TODO(b/206642994): see if we can remove this condition. It's added for now # because linking atomic leads to linker errors for evergreen on arm-hardfp, # and it's apparently not really needed (i.e., we can build without it). - if (!is_starboard || !sb_is_modular) { + if (!is_starboard || !(sb_is_modular && current_toolchain == cobalt_toolchain)) { libs += [ "atomic" ] } } diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni index 1c1b364b1ec2..d80b2f3552f1 100644 --- a/build/toolchain/gcc_toolchain.gni +++ b/build/toolchain/gcc_toolchain.gni @@ -11,6 +11,7 @@ import("//build/toolchain/cc_wrapper.gni") import("//build/toolchain/goma.gni") import("//build/toolchain/rbe.gni") import("//build/toolchain/toolchain.gni") +import("//starboard/build/config/modular/helper_variables.gni") if (is_nacl) { # To keep NaCl variables out of builds that don't include NaCl, all diff --git a/cobalt/BUILD.gn b/cobalt/BUILD.gn index 8fea180c0c24..a41ca3623147 100644 --- a/cobalt/BUILD.gn +++ b/cobalt/BUILD.gn @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//starboard/build/config/modular/helper_variables.gni") + group("gn_all") { testonly = true deps = [ diff --git a/cobalt/media/sandbox/BUILD.gn b/cobalt/media/sandbox/BUILD.gn index 19be83551b45..789c09f3d092 100644 --- a/cobalt/media/sandbox/BUILD.gn +++ b/cobalt/media/sandbox/BUILD.gn @@ -15,6 +15,8 @@ # This is a sample sandbox application for experimenting with the Cobalt # media/renderer interface. +import("//starboard/build/config/modular/helper_variables.gni") + target(final_executable_type, "media_sandbox") { sources = [ "media2_sandbox.cc" ] diff --git a/cobalt/network/BUILD.gn b/cobalt/network/BUILD.gn index 1a4fd75969b0..e39e50e53a33 100644 --- a/cobalt/network/BUILD.gn +++ b/cobalt/network/BUILD.gn @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//starboard/build/config/modular/helper_variables.gni") + static_library("network") { has_pedantic_warnings = true diff --git a/starboard/BUILD.gn b/starboard/BUILD.gn index c0a010de11e2..50693fb0a8e3 100644 --- a/starboard/BUILD.gn +++ b/starboard/BUILD.gn @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//starboard/build/config/modular/helper_variables.gni") import("//starboard/build/config/starboard_target_type.gni") group("gn_all") { @@ -57,11 +58,6 @@ group("gn_all") { deps += [ "//starboard/benchmark" ] } - if (is_modular_toolchain && is_cobalt_toolchain) { - assert(sb_is_modular, - "sb_is_modular should be set when building with cobalt_toolchain") - } - if (!sb_is_evergreen) { deps += [ "//third_party/lz4_lib:lz4" ] @@ -89,7 +85,7 @@ group("starboard") { "//starboard/client_porting/eztime", ] - if (sb_is_modular) { + if (sb_is_modular && current_toolchain == cobalt_toolchain) { public_deps += [ "//third_party/llvm-project/compiler-rt:compiler_rt", "//third_party/llvm-project/libcxx:cxx", @@ -192,7 +188,7 @@ if (current_toolchain == starboard_toolchain) { } else { public_deps += [ "//third_party/crashpad/wrapper:wrapper_stub" ] } - if (!sb_is_modular) { + if (!(sb_is_modular && current_toolchain == cobalt_toolchain)) { public_deps += [ "//$starboard_path:starboard_platform" ] } } diff --git a/starboard/build/config/BUILD.gn b/starboard/build/config/BUILD.gn index a9653497f346..395ceb5790d9 100644 --- a/starboard/build/config/BUILD.gn +++ b/starboard/build/config/BUILD.gn @@ -13,6 +13,7 @@ # limitations under the License. import("//build/config/compiler/compiler.gni") +import("//starboard/build/config/modular/helper_variables.gni") config("base") { defines = [ "USE_COBALT_CUSTOMIZATIONS" ] @@ -104,6 +105,7 @@ config("target") { # however. # For windows based platforms this flag causes a linker error while building with cobalt toolchain if (!(host_os == "win" && sb_is_modular && + current_toolchain == cobalt_toolchain && current_toolchain == cobalt_toolchain)) { cflags = [ "-fPIC" ] } @@ -154,7 +156,7 @@ config("starboard") { } if (sb_is_modular) { - defines += [ "SB_IS_MODULAR=1" ] + defines += [ "SB_IS_MODULAR" ] } if (sb_is_evergreen) { @@ -229,7 +231,8 @@ config("warnings_as_errors") { # override flags specified in a platform's "platform_configuration" config, # which is where these particular flags would otherwise naturally fit. config("default_compiler_flags") { - if (is_starboardized_toolchain && sb_is_modular && target_cpu == "arm") { + if (is_starboardized_toolchain && sb_is_modular && + current_toolchain == cobalt_toolchain && target_cpu == "arm") { cflags = [ "-mfpu=vfpv3" ] asmflags = cflags } diff --git a/starboard/build/config/base_configuration.gni b/starboard/build/config/base_configuration.gni index 3c60204516c2..8e19f4c331e6 100644 --- a/starboard/build/config/base_configuration.gni +++ b/starboard/build/config/base_configuration.gni @@ -44,9 +44,6 @@ declare_args() { # Directory path to static contents' data. sb_static_contents_output_data_dir = "$root_out_dir/content/data" - # Whether this is a modular build. - sb_is_modular = false - # Whether this is an Evergreen build. sb_is_evergreen = false diff --git a/starboard/build/config/modular/helper_variables.gni b/starboard/build/config/modular/helper_variables.gni new file mode 100644 index 000000000000..2f37e61164dc --- /dev/null +++ b/starboard/build/config/modular/helper_variables.gni @@ -0,0 +1,15 @@ +# Copyright 2023 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. + +sb_is_modular = sb_is_evergreen || is_modular_toolchain diff --git a/starboard/evergreen/shared/platform_configuration/configuration.gni b/starboard/evergreen/shared/platform_configuration/configuration.gni index c76baea77b99..f3aab3370c76 100644 --- a/starboard/evergreen/shared/platform_configuration/configuration.gni +++ b/starboard/evergreen/shared/platform_configuration/configuration.gni @@ -14,8 +14,6 @@ import("//starboard/build/config/base_configuration.gni") -sb_is_modular = true - sb_is_evergreen = true cobalt_font_package = "empty" diff --git a/starboard/extension/BUILD.gn b/starboard/extension/BUILD.gn index 5212664b2e01..6319447c1cb9 100644 --- a/starboard/extension/BUILD.gn +++ b/starboard/extension/BUILD.gn @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//starboard/build/config/modular/helper_variables.gni") target(gtest_target_type, "extension_test") { testonly = true has_pedantic_warnings = true @@ -26,7 +27,7 @@ target(gtest_target_type, "extension_test") { "//testing/gmock", "//testing/gtest", ] - if (sb_is_modular) { + if (sb_is_modular && current_toolchain == cobalt_toolchain) { deps += cobalt_platform_dependencies } } diff --git a/starboard/linux/shared/platform_configuration/BUILD.gn b/starboard/linux/shared/platform_configuration/BUILD.gn index dcdaa48c857e..ad379e6021cf 100644 --- a/starboard/linux/shared/platform_configuration/BUILD.gn +++ b/starboard/linux/shared/platform_configuration/BUILD.gn @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//starboard/build/config/modular/helper_variables.gni") + config("compiler_flags") { cflags = [] cflags_c = [] diff --git a/third_party/boringssl/BUILD.gn b/third_party/boringssl/BUILD.gn index f90940c03088..201b95f2713d 100644 --- a/third_party/boringssl/BUILD.gn +++ b/third_party/boringssl/BUILD.gn @@ -1,5 +1,6 @@ import("//starboard/sabi/sabi.gni") import("//third_party/boringssl/buildfiles.gni") +import("//starboard/build/config/modular/helper_variables.gni") declare_args() { asm_target_arch = target_cpu @@ -102,7 +103,7 @@ static_library("crypto") { configs -= [ "//starboard/build/config:size" ] configs += [ "//starboard/build/config:speed" ] - if (sb_is_modular) { + if (sb_is_modular && current_toolchain == cobalt_toolchain) { calling_convention = sabi_variables.calling_convention if ((calling_convention != "aarch64" && calling_convention != "eabi" && calling_convention != "sysv" && calling_convention != "windows") || diff --git a/third_party/libjpeg-turbo/BUILD.gn b/third_party/libjpeg-turbo/BUILD.gn index 43731152d8f5..35a8d07679cd 100644 --- a/third_party/libjpeg-turbo/BUILD.gn +++ b/third_party/libjpeg-turbo/BUILD.gn @@ -5,6 +5,7 @@ # Do not use the targets in this file unless you need a certain libjpeg # implementation. Use the meta target //third_party:jpeg instead. +import("//starboard/build/config/modular/helper_variables.gni") import("//build/config/sanitizers/sanitizers.gni") if (current_cpu == "arm" || current_cpu == "arm64") { import("//build/config/arm.gni") @@ -205,7 +206,7 @@ static_library("simd") { } configs += [ "//build/config/compiler:optimize_speed" ] - if (is_starboard && sb_is_modular && current_cpu == "arm") { + if (is_starboard && sb_is_modular && current_toolchain == cobalt_toolchain && current_cpu == "arm") { configs += [ ":simd_arm_config" ] } } else { @@ -316,7 +317,7 @@ static_library("libjpeg") { # TODO(b/236258535): Enable neon instructions once the code is updated # to use SbCPUFeatures() at runtime. if ((is_msan && (current_cpu == "x86" || current_cpu == "x64")) || - (is_starboard && sb_is_modular)) { + (is_starboard && sb_is_modular && current_toolchain == cobalt_toolchain)) { sources += [ "jsimd_none.c" ] } else { public_deps += [ ":simd" ] diff --git a/third_party/zlib/BUILD.gn b/third_party/zlib/BUILD.gn index 83cb3275eadf..f474e07998cb 100644 --- a/third_party/zlib/BUILD.gn +++ b/third_party/zlib/BUILD.gn @@ -2,6 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//starboard/build/config/modular/helper_variables.gni") + import("//build/config/compiler/compiler.gni") if (current_cpu == "arm" || current_cpu == "arm64") { import("//build/config/arm.gni") @@ -25,7 +27,7 @@ if (current_cpu == "arm" || current_cpu == "arm64") { # TODO(b/206642994): look into whether we should condition on the # floating_point_fpu SABI variable, rather than sb_is_modular, here as we did # in third_party/zlib/zlib.gyp. -if (is_starboard && sb_is_modular && target_cpu == "arm" && +if (is_starboard && sb_is_modular && current_toolchain == cobalt_toolchain && target_cpu == "arm" && use_arm_neon_optimizations) { config("zlib_neon_fpu_config") { cflags = [ "-mfpu=neon" ] @@ -80,7 +82,7 @@ source_set("zlib_adler32_simd") { configs += [ "//starboard/build/config:speed" ] } - if (is_starboard && sb_is_modular && target_cpu == "arm" && + if (is_starboard && sb_is_modular && current_toolchain == cobalt_toolchain && target_cpu == "arm" && use_arm_neon_optimizations) { configs += [ ":zlib_neon_fpu_config" ] } @@ -161,7 +163,7 @@ if (use_arm_neon_optimizations) { deps = [ "//starboard:starboard_headers_only" ] } - if (is_starboard && sb_is_modular && target_cpu == "arm" && + if (is_starboard && sb_is_modular && current_toolchain == cobalt_toolchain && target_cpu == "arm" && use_arm_neon_optimizations) { configs += [ ":zlib_neon_fpu_config" ] } @@ -236,7 +238,7 @@ source_set("zlib_inflate_chunk_simd") { configs += [ "//starboard/build/config:speed" ] } - if (is_starboard && sb_is_modular && target_cpu == "arm" && + if (is_starboard && sb_is_modular && current_toolchain == cobalt_toolchain && target_cpu == "arm" && use_arm_neon_optimizations) { configs += [ ":zlib_neon_fpu_config" ] }