Skip to content

Commit

Permalink
Refactor linux shared, stub config.
Browse files Browse the repository at this point in the history
Refactor linux, stub platform config flags into 'default_cpp_standard'.

Only apply `default_cpp_standard` to default toolchain, avoid applying
it to other toolchains like host_toolchain.

Change-Id: Ia533601ceb7a0bd8f906dbb5ba885191ea4adb04
  • Loading branch information
niranjanyardi committed Mar 25, 2024
1 parent 27dad7e commit e138be0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 24 deletions.
56 changes: 34 additions & 22 deletions starboard/build/config/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -235,36 +235,48 @@ config("default_compiler_flags") {
}

# This config is intended to encapsulate all platform-specific logic for selecting the C++ standard
# version in shared code. Starboard platform-specific build code should not attempt to overload this.
# TODO: b/329683364 - Refactor the remaining related flags from each platforms platform_configuration to here.
# version in shared code while building with the default toolchain.
# Starboard platform-specific build code should not attempt to overload this.
config("default_cpp_standard") {
if ((sb_is_modular && current_toolchain == cobalt_toolchain) || is_android) {
cflags_cc = [ "-std=c++17" ]
}
if (current_toolchain == default_toolchain) {
if (sb_is_modular || is_android) {
cflags_cc = [ "-std=c++17" ]
}

# These flags apply to non-modular windows platforms which includes win32, xb1.
if (is_host_win && !sb_is_modular) {
cflags = [ "/std:c++17" ]
}
# These flags apply to non-modular windows platforms which includes win32, xb1.
if (is_host_win && !sb_is_modular) {
cflags = [ "/std:c++17" ]
}

if (is_apple) {
cflags_cc = [ "-std=gnu++17" ]
cflags_objcc = [ "-std=gnu++17" ]
if (is_linux && !sb_is_modular) {
cflags_cc = [ "-std=gnu++17" ]
}

if (is_apple) {
cflags_cc = [ "-std=gnu++17" ]
cflags_objcc = [ "-std=gnu++17" ]
}
}
}

config("cpp20_supported_config") {
if ((sb_is_modular && current_toolchain == cobalt_toolchain) || is_android) {
cflags_cc = [ "-std=c++20" ]
}
if (current_toolchain == default_toolchain) {
if (sb_is_modular || is_android) {
cflags_cc = [ "-std=c++20" ]
}

# These flags apply to non-modular windows platforms which includes win32, xb1.
if (is_host_win && !sb_is_modular) {
cflags = [ "/std:c++20" ]
}
# These flags apply to non-modular windows platforms which includes win32, xb1.
if (is_host_win && !sb_is_modular) {
cflags = [ "/std:c++20" ]
}

if (is_apple) {
cflags_cc = [ "-std=gnu++20" ]
cflags_objcc = [ "-std=gnu++20" ]
if (is_linux && !sb_is_modular) {
cflags_cc = [ "-std=gnu++20" ]
}

if (is_apple) {
cflags_cc = [ "-std=gnu++20" ]
cflags_objcc = [ "-std=gnu++20" ]
}
}
}
1 change: 0 additions & 1 deletion starboard/linux/shared/platform_configuration/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ config("compiler_flags") {
"MESA_EGL_NO_X11_HEADERS",
]
cflags_c += [ "-std=c11" ]
cflags_cc = [ "-std=gnu++17" ]

if (use_asan) {
cflags += [
Expand Down
1 change: 0 additions & 1 deletion starboard/stub/platform_configuration/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ config("platform_configuration") {
configs = [ "//starboard/build/config/sabi" ]
cflags = []

cflags_cc = [ "-std=gnu++17" ]
ldflags = [ "-static-libstdc++" ]

libs = [ "pthread" ]
Expand Down

0 comments on commit e138be0

Please sign in to comment.