From dba68c026cc291adf6111352af81ac81ec043b66 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Wed, 27 Dec 2017 13:26:14 -0500 Subject: [PATCH] Merge webkit_set target into //WebKit/source/controller to fix deps race (issue #2339) --- BUILD.gn | 58 +----------------- libcef/features/BUILD.gn | 78 +++++++++++++++++++++++- patch/patches/component_build_1617.patch | 25 +++++--- 3 files changed, 97 insertions(+), 64 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 795bc6932..3afe3b78f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -229,58 +229,6 @@ group("cef") { # libcef static target. # -# Configuration that will be applied to all targets that depend on -# libcef_static. -config("libcef_static_config") { - # CEF targets use includes relative to the CEF root directory. - include_dirs = [ "." ] - defines = [ - "BUILDING_CEF_SHARED", - "USING_CHROMIUM_INCLUDES", - ] -} - -# Target for building code that accesses Blink internals. Included from the -# //third_party/WebKit/Source/web target. -source_set("webkit_set") { - sources = [ - "libcef/renderer/webkit_glue.cc", - "libcef/renderer/webkit_glue.h", - ] - - configs += [ - ":libcef_static_config", - "//build/config:precompiled_headers", - - # Blink-internal include paths. - "//third_party/WebKit/Source/core:core_include_dirs", - ] - - include_dirs = [ - # Blink code uses paths relative to these directories. We need them because - # we include Blink headers. - "//third_party/WebKit", - "//third_party/WebKit/public/platform", - "//third_party/WebKit/public/web", - "//third_party/WebKit/Source", - "$root_gen_dir/blink", - "$root_gen_dir/third_party/WebKit", - ] - - defines = [ - # Blink-internal defines. - "BLINK_IMPLEMENTATION=1", - "INSIDE_BLINK", - ] - - deps = [ - "//skia", - "//third_party/icu", - "//third_party/boringssl", - "//v8", - ] -} - if (is_win) { # Target for building code that accesses chrome_elf internals. Included from # the //chrome_elf:crash target. Defined as a static_library instead of a @@ -301,7 +249,7 @@ if (is_win) { ] configs += [ - ":libcef_static_config", + "libcef/features:config", "//build/config:precompiled_headers", ] @@ -675,7 +623,7 @@ static_library("libcef_static") { ] configs += [ - ":libcef_static_config", + "libcef/features:config", "//build/config:precompiled_headers", # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. @@ -683,7 +631,7 @@ static_library("libcef_static") { ] public_configs = [ - ":libcef_static_config", + "libcef/features:config", ] include_dirs = [ diff --git a/libcef/features/BUILD.gn b/libcef/features/BUILD.gn index bdedff82c..8c19cd247 100644 --- a/libcef/features/BUILD.gn +++ b/libcef/features/BUILD.gn @@ -8,7 +8,73 @@ import("//cef/libcef/features/features.gni") # This file is in a separate directory so all targets in the build can refer to # the buildflag header to get the necessary preprocessor defines without # bringing in any CEF targets. Other targets can depend on this target -# regardless of whether CEF is being built. +# regardless of whether CEF is being built. Set the `enable_cef=false` GN arg to +# disable the CEF changes when building Chrome. +# +# Example usage: +# +# 1. An existing GN configuration file at path/to/foo/BUILD.gn: +# +# # Import the `enable_cef` arg. +# import("//cef/libcef/features/features.gni") +# ... +# +# # An existing target that is modified for CEF. +# # The target type might instead be `component`, `source_set`, etc. +# static_library("foo") { +# sources = [ ... ] +# +# deps = [ +# # Always include the CEF features. +# "//cef/libcef/features", +# ... +# ] +# +# if (enable_cef) { +# # Actions to perform when the CEF build is enabled. +# +# # Optionally include CEF source files directly in this target. This +# # approach is required for targets that are either directly or +# # indirectly included in a `component` target (otherwise +# # `is_component_build=true` builds will fail). Keep in mind that these +# # files are part of this target instead of the `libcef_static` target +# # and therefore subject to any target-specific configuration settings +# # such as include paths, defines, compiler flags, etc. +# sources += [ +# "//cef/libcef/browser/foo_helper.cc", +# "//cef/libcef/browser/foo_helper.h", +# ] +# +# # Always include the CEF configuration. +# configs += [ "//cef/libcef/features:config" ] +# } +# ... +# } +# +# 2. An existing C++ source file at path/to/foo/foo.cc: +# +# // Include the `BUILDFLAG(ENABLE_CEF)` definition. +# #include "cef/libcef/features/features.h" +# ... +# +# #if BUILDFLAG(ENABLE_CEF) +# // CEF headers here... +# #include "cef/libcef/browser/foo_helper.h" +# #else +# // Chrome headers here... +# #endif +# +# // An existing function that is modified for CEF. +# void DoFoo() { +# #if BUILDFLAG(ENABLE_CEF) +# // CEF implementation here... +# cef_foo_helper::DoFoo(); +# #else +# // Chrome implementation here... +# #endif // !BUILDFLAG(ENABLE_CEF) +# } +# ... +# buildflag_header("features") { header = "features.h" @@ -17,3 +83,13 @@ buildflag_header("features") { "ENABLE_CEF=$enable_cef", ] } + +# Configuration for all targets that include CEF source code library-side. +config("config") { + # CEF sources use includes relative to the CEF root directory. + include_dirs = [ "//cef" ] + defines = [ + "BUILDING_CEF_SHARED", + "USING_CHROMIUM_INCLUDES", + ] +} diff --git a/patch/patches/component_build_1617.patch b/patch/patches/component_build_1617.patch index 4c8cb6674..bb36e91e2 100644 --- a/patch/patches/component_build_1617.patch +++ b/patch/patches/component_build_1617.patch @@ -25,14 +25,23 @@ index 7563ce48bf5e..6c594749d57b 100644 explicit ContentServiceManagerMainDelegate(const ContentMainParams& params); ~ContentServiceManagerMainDelegate() override; diff --git third_party/WebKit/Source/controller/BUILD.gn third_party/WebKit/Source/controller/BUILD.gn -index 1d29633ba10d..1a42fe1d37fa 100644 +index 1d29633ba10d..a4e738f0e199 100644 --- third_party/WebKit/Source/controller/BUILD.gn +++ third_party/WebKit/Source/controller/BUILD.gn -@@ -16,6 +16,7 @@ component("controller") { - output_name = "blink_controller" +@@ -25,6 +25,7 @@ component("controller") { - deps = [ -+ "//cef:webkit_set", - "//skia", - "//third_party/WebKit/Source/core", - "//third_party/WebKit/Source/modules", + configs += [ + "//build/config/compiler:wexit_time_destructors", ++ "//cef/libcef/features:config", + "//third_party/WebKit/Source:config", + "//third_party/WebKit/Source:inside_blink", + "//third_party/WebKit/Source:non_test_config", +@@ -36,6 +37,8 @@ component("controller") { + sources = [ + "BlinkInitializer.cpp", + "ControllerExport.h", ++ "//cef/libcef/renderer/webkit_glue.cc", ++ "//cef/libcef/renderer/webkit_glue.h", + ] + + if (is_mac) {