Skip to content

Commit

Permalink
Modify sb_is_modular definition
Browse files Browse the repository at this point in the history
b/294267479

Set sb_is_modular = is_modular_toolchain || sb_is_evergreen in
starboard/build/config/modular/helper_variables.gni.
Define SB_IS_MODULAR when sb_is_modular = true.

Change-Id: Ieab0a66181c8ef1fa4b6e46746c714652dd6238c
  • Loading branch information
niranjanyardi committed Aug 8, 2023
1 parent b618328 commit 05cb206
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 23 deletions.
3 changes: 2 additions & 1 deletion base/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" ]
}
}
Expand Down
1 change: 1 addition & 0 deletions build/toolchain/gcc_toolchain.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cobalt/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 2 additions & 0 deletions cobalt/media/sandbox/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]

Expand Down
2 changes: 2 additions & 0 deletions cobalt/network/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 3 additions & 7 deletions starboard/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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" ]

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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" ]
}
}
Expand Down
7 changes: 5 additions & 2 deletions starboard/build/config/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand Down Expand Up @@ -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" ]
}
Expand Down Expand Up @@ -154,7 +156,7 @@ config("starboard") {
}

if (sb_is_modular) {
defines += [ "SB_IS_MODULAR=1" ]
defines += [ "SB_IS_MODULAR" ]
}

if (sb_is_evergreen) {
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 0 additions & 3 deletions starboard/build/config/base_configuration.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions starboard/build/config/modular/helper_variables.gni
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

import("//starboard/build/config/base_configuration.gni")

sb_is_modular = true

sb_is_evergreen = true

cobalt_font_package = "empty"
Expand Down
3 changes: 2 additions & 1 deletion starboard/extension/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}
2 changes: 2 additions & 0 deletions starboard/linux/shared/platform_configuration/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
3 changes: 2 additions & 1 deletion third_party/boringssl/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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") ||
Expand Down
5 changes: 3 additions & 2 deletions third_party/libjpeg-turbo/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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" ]
Expand Down
10 changes: 6 additions & 4 deletions third_party/zlib/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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" ]
Expand Down Expand Up @@ -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" ]
}
Expand Down Expand Up @@ -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" ]
}
Expand Down Expand Up @@ -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" ]
}
Expand Down

0 comments on commit 05cb206

Please sign in to comment.