Skip to content

Commit

Permalink
Move cobalt variables to build_config.h (#4313)
Browse files Browse the repository at this point in the history
b/375617387
  • Loading branch information
andrewsavage1 authored Oct 28, 2024
1 parent 9be9fc6 commit a4c526d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 11 deletions.
12 changes: 12 additions & 0 deletions build/build_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,18 @@
#define BUILDFLAG_INTERNAL_IS_OZONE() (0)
#endif

#if defined(IS_COBALT)
#define BUILDFLAG_INTERNAL_IS_COBALT() (1)
#else
#define BUILDFLAG_INTERNAL_IS_COBALT() (0)
#endif

#if defined(USE_STARBOARD)
#define BUILDFLAG_INTERNAL_USE_STARBOARD() (1)
#else
#define BUILDFLAG_INTERNAL_USE_STARBOARD() (0)
#endif

// Compiler detection. Note: clang masquerades as GCC on POSIX and as MSVC on
// Windows.
#if defined(__GNUC__)
Expand Down
5 changes: 5 additions & 0 deletions cobalt/build/configs/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ config("cobalt_config") {
if (current_toolchain == starboard_toolchain) {
configs += [ "//${starboard_path}/platform_configuration" ]
}

defines = [
"IS_COBALT",
"USE_STARBOARD",
]
}

config("default_includes") {
Expand Down
26 changes: 15 additions & 11 deletions starboard/build/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,31 @@
# limitations under the License.

import("//build/buildflag_header.gni")
import("//cobalt/build/configs/cobalt.gni")
import("//cobalt/build/configs/variables.gni")

declare_args() {
use_starboard = target_os != "android"
use_starboard_media = is_cobalt
use_evergreen = false
}
import("//starboard/build/buildflags.gni")

# To use these build flags from i.e. "foo.cc", add a dependency from the target
# containing "foo.cc" on this target, then have "foo.cc" include
# containing "foo.cc" on this target, then have "foo.cc" conditionally include
# "starboard/build/starboard_buildflags.h". After that you can use i.e.
# BUILDFLAG(USE_STARBOARD) in your code.
# BUILDFLAG(USE_STARBOARD_MEDIA) in your code.
#
# Example:
#
# #include "build/build_config.h"
# #if BUILDFLAG(IS_COBALT)
# #include "starboard/build/starboard_buildflags.h"
# #endif
#
# #if BUILDFLAG(USE_STARBOARD_MEDIA)
# // Do something
# #endif
#
buildflag_header("starboard_buildflags") {
header = "starboard_buildflags.h"

flags = [
"USE_STARBOARD=$use_starboard",
"USE_STARBOARD_MEDIA=$use_starboard_media",
"USE_EVERGREEN=$use_evergreen",
"IS_COBALT=$is_cobalt",
"IS_MODULAR_BUILD=$sb_is_modular",
]
}
7 changes: 7 additions & 0 deletions starboard/build/buildflags.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import("//cobalt/build/configs/cobalt.gni")

declare_args() {
use_starboard = target_os != "android"
use_starboard_media = is_cobalt
use_evergreen = false
}

0 comments on commit a4c526d

Please sign in to comment.