From f11f66be68240ef6f723e42161e23a8684d369c8 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Thu, 19 Jul 2018 14:46:01 -0700 Subject: [PATCH] build: define is_mas_build as a GN arg This is to support the GN build, which won't read the MAS_BUILD environment variable, and will instead rely on the GN args system to toggle between MAS/non-MAS. --- chromiumcontent/args/ffmpeg.gn | 1 + chromiumcontent/args/native_mksnapshot.gn | 1 + chromiumcontent/args/shared_library.gn | 1 + chromiumcontent/args/static_library.gn | 1 + chromiumcontent/args/tests.gn | 1 + chromiumcontent/config/BUILD.gn | 2 +- patches/common/chromium/build_gn.patch | 47 ++++++++++++----------- 7 files changed, 30 insertions(+), 24 deletions(-) diff --git a/chromiumcontent/args/ffmpeg.gn b/chromiumcontent/args/ffmpeg.gn index f6e8dcb0..7fe4f2e6 100644 --- a/chromiumcontent/args/ffmpeg.gn +++ b/chromiumcontent/args/ffmpeg.gn @@ -1,5 +1,6 @@ root_extra_deps = [ "//libchromiumcontent/chromiumcontent" ] is_component_build = false +is_mas_build = getenv("MAS_BUILD") != "" is_debug = false enable_nacl = false enable_widevine = true diff --git a/chromiumcontent/args/native_mksnapshot.gn b/chromiumcontent/args/native_mksnapshot.gn index c98ec046..a83e7658 100644 --- a/chromiumcontent/args/native_mksnapshot.gn +++ b/chromiumcontent/args/native_mksnapshot.gn @@ -1,5 +1,6 @@ root_extra_deps = [ "//v8:v8_maybe_snapshot" ] is_electron_build = true +is_mas_build = getenv("MAS_BUILD") != "" is_component_build = false is_debug = false enable_linux_installer = false diff --git a/chromiumcontent/args/shared_library.gn b/chromiumcontent/args/shared_library.gn index 5e15083e..bd30267f 100644 --- a/chromiumcontent/args/shared_library.gn +++ b/chromiumcontent/args/shared_library.gn @@ -1,6 +1,7 @@ root_extra_deps = [ "//libchromiumcontent/chromiumcontent" ] is_electron_build = true is_component_build = true +is_mas_build = getenv("MAS_BUILD") != "" is_debug = true symbol_level = 2 use_allocator = "none" # on Linux this defaults to "tcmalloc", but tcmalloc deadlocks when Electron CI tests are run inside Docker diff --git a/chromiumcontent/args/static_library.gn b/chromiumcontent/args/static_library.gn index 8518c8e1..bc81e062 100644 --- a/chromiumcontent/args/static_library.gn +++ b/chromiumcontent/args/static_library.gn @@ -1,6 +1,7 @@ root_extra_deps = [ "//libchromiumcontent/chromiumcontent" ] is_electron_build = true is_component_build = false +is_mas_build = getenv("MAS_BUILD") != "" is_official_build = true symbol_level = 2 enable_nacl = false diff --git a/chromiumcontent/args/tests.gn b/chromiumcontent/args/tests.gn index 4b06a694..e2757d5e 100644 --- a/chromiumcontent/args/tests.gn +++ b/chromiumcontent/args/tests.gn @@ -1,6 +1,7 @@ root_extra_deps = [ "//libchromiumcontent/chromiumcontent:chromiumcontent_tests" ] is_debug = false is_electron_build = true +is_mas_build = getenv("MAS_BUILD") != "" is_component_build = true dcheck_always_on = true symbol_level = 1 diff --git a/chromiumcontent/config/BUILD.gn b/chromiumcontent/config/BUILD.gn index a8337f91..d034309c 100644 --- a/chromiumcontent/config/BUILD.gn +++ b/chromiumcontent/config/BUILD.gn @@ -23,7 +23,7 @@ config("build_time_executable") { # For MAS build, we force defining "MAS_BUILD". config("mas_build") { - if (getenv("MAS_BUILD") != "") { + if (is_mas_build) { defines = [ "MAS_BUILD" ] } } diff --git a/patches/common/chromium/build_gn.patch b/patches/common/chromium/build_gn.patch index 8d3974f9..9c725d6c 100644 --- a/patches/common/chromium/build_gn.patch +++ b/patches/common/chromium/build_gn.patch @@ -1,18 +1,32 @@ +diff --git a/.gn b/.gn +index 50a8a2fe9f1e..66ced79f1627 100644 +--- a/.gn ++++ b/.gn +@@ -259,4 +259,8 @@ exec_script_whitelist = + # Not gypi-to-gn. + "//google_apis/BUILD.gn", + "//printing/BUILD.gn", ++ # While electron transitions to GN, we use gypi_to_gn to synchronize ++ # file lists ++ "//electron/BUILD.gn", ++ "//electron/brightray/BUILD.gn", + ] diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn -index de3f35f124aa..a52003f1b5e1 100644 +index 7d60dd920904..d2f2cbc99915 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn -@@ -123,6 +123,9 @@ if (current_os == "") { +@@ -123,6 +123,10 @@ if (current_os == "") { # even if the value is overridden, which is wasteful. See first bullet. declare_args() { + is_electron_build = false + is_electron_gn_build = false ++ is_mas_build = false + # Set to enable the official build level of optimization. This has nothing # to do with branding, but enables an additional level of optimization above # release (!is_debug). This might be better expressed as a tri-state -@@ -529,6 +529,7 @@ default_compiler_configs = [ +@@ -534,6 +538,7 @@ default_compiler_configs = [ "//build/config/compiler:runtime_library", "//build/config/coverage:default_coverage", "//build/config/sanitizers:default_sanitizer_flags", @@ -20,7 +34,7 @@ index de3f35f124aa..a52003f1b5e1 100644 ] if (is_win) { default_compiler_configs += [ -@@ -642,6 +645,7 @@ template("component") { +@@ -660,6 +665,7 @@ template("component") { _component_mode = "shared_library" } else if (defined(invoker.static_component_type)) { assert(invoker.static_component_type == "static_library" || @@ -29,10 +43,10 @@ index de3f35f124aa..a52003f1b5e1 100644 _component_mode = invoker.static_component_type } else if (is_android || !defined(invoker.sources)) { diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn -index 7888e2f8589d..b95cef9596d4 100644 +index 9a10137aa405..bb33e5450eaa 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn -@@ -553,10 +553,13 @@ config("compiler") { +@@ -579,10 +579,13 @@ config("compiler") { ldflags += [ "-Wl,--lto-O0" ] } @@ -51,10 +65,10 @@ index 7888e2f8589d..b95cef9596d4 100644 # Work-around for http://openradar.appspot.com/20356002 if (is_mac) { diff --git a/build/config/win/BUILD.gn b/build/config/win/BUILD.gn -index 5e1f7fcc4d83..15723e6b7184 100644 +index 1f6bc13e087f..4630045ff554 100644 --- a/build/config/win/BUILD.gn +++ b/build/config/win/BUILD.gn -@@ -276,7 +276,7 @@ config("common_linker_setup") { +@@ -314,7 +314,7 @@ config("cfi_linker") { # See https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx for a reference of # what each value does. config("default_crt") { @@ -64,10 +78,10 @@ index 5e1f7fcc4d83..15723e6b7184 100644 # exceptions or will give errors about things not matching, so keep # exceptions on. diff --git a/third_party/WebKit/Source/platform/BUILD.gn b/third_party/WebKit/Source/platform/BUILD.gn -index 6c86a6454256..2bc8c31396af 100644 +index dc6e613e7c7e..36abbd583faf 100644 --- a/third_party/WebKit/Source/platform/BUILD.gn +++ b/third_party/WebKit/Source/platform/BUILD.gn -@@ -160,6 +160,7 @@ action("instrumentation_probes") { +@@ -135,6 +135,7 @@ action("instrumentation_probes") { } executable("character_data_generator") { @@ -75,16 +89,3 @@ index 6c86a6454256..2bc8c31396af 100644 sources = [ "text/CharacterPropertyDataGenerator.cpp", "text/CharacterPropertyDataGenerator.h", -diff --git a/.gn b/.gn -index 9e744b9940e2..09208f2e98fa 100644 ---- a/.gn -+++ b/.gn -@@ -245,4 +245,8 @@ exec_script_whitelist = - # Not gypi-to-gn. - "//google_apis/BUILD.gn", - "//printing/BUILD.gn", -+ # While electron transitions to GN, we use gypi_to_gn to synchronize -+ # file lists -+ "//electron/BUILD.gn", -+ "//electron/brightray/BUILD.gn", - ]