From b92749a58af274d27e46ed41a62774d495db90cd Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Tue, 30 Apr 2024 12:03:59 -0400 Subject: [PATCH] Add DISABLE_ALLOY_BOOTSTRAP to cef_config.h (see #3681, see #3685) Include cef_config.h from base/cef_build.h and fix detection of args.gn changes so that defines are available everywhere by default. Fix include configuration for chrome_elf_set and sandbox targets. --- .gitignore | 1 - BUILD.gn | 50 ++++++++++++++++++++--------- include/base/cef_build.h | 15 +++++++++ include/internal/cef_types_linux.h | 1 - libcef/features/BUILD.gn | 6 ++-- tests/ceftests/run_all_unittests.cc | 1 - tools/make_config_header.py | 20 ++++++++---- 7 files changed, 68 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index c2f0cec2d..469db9a11 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,5 @@ Thumbs.db /binary_distrib /docs # CEF generated files -/include/cef_config.h /include/cef_version.h .ccls-cache/ diff --git a/BUILD.gn b/BUILD.gn index c2916a17c..161ea680d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -350,6 +350,10 @@ if (is_win) { "//build/config:precompiled_headers", ] + public_configs = [ + "libcef/features:config", + ] + if (is_component_build) { # Avoid linker errors with content_switches.cc in component build by not # defining CONTENT_EXPORT. @@ -1247,18 +1251,29 @@ config("libcef_autogen_config") { } } -# Configuration that will be applied to all targets that depend on -# libcef_dll_wrapper. -config("libcef_dll_wrapper_config") { +# Configuration that supports #include paths relative to src/cef/ for CEF +# client-side code. CEF library-side code (Chromium code and cef/libcef/ +# directory) uses #include paths relative to src/. See libcef/features:config +# for CEF library-side configuration. +config("libcef_includes_config") { include_dirs = [ - # CEF sources use include paths relative to the CEF root directory. + # cef/include/ directory and CEF client-side code use #includes relative to + # the cef/ directory. ".", - # CEF generates some header files that also need to be discoverable. + # CEF generated header files that also need to be discoverable. + # These #includes from client-side code will not be prefixed with cef/. # They will be copied to the include/ directory in the binary distribution. "$root_out_dir/includes/cef", ] +} - configs = [ ":libcef_autogen_config" ] +# Configuration that will be applied to all targets that depend on +# libcef_dll_wrapper. +config("libcef_dll_wrapper_config") { + configs = [ + ":libcef_autogen_config", + ":libcef_includes_config", + ] if (is_win) { if (current_cpu == "x86") { @@ -1274,10 +1289,6 @@ config("libcef_dll_wrapper_config") { ldflags = [ "/STACK:0x800000" ] } } - - if (!enable_alloy_bootstrap) { - defines = [ "DISABLE_ALLOY_BOOTSTRAP" ] - } } # libcef_dll_wrapper target. @@ -1311,8 +1322,7 @@ static_library("libcef_dll_wrapper") { if (is_win) { static_library("cef_sandbox") { sources = [ "libcef_dll/sandbox/sandbox_win.cc" ] - # CEF sources use include paths relative to the CEF root directory. - include_dirs = [ "." ] + configs += [ ":libcef_includes_config" ] deps = [ "libcef/features", "//sandbox" ] } } @@ -1320,8 +1330,7 @@ if (is_win) { if (is_mac) { static_library("cef_sandbox") { sources = [ "libcef_dll/sandbox/sandbox_mac.mm" ] - # CEF sources use include paths relative to the CEF root directory. - include_dirs = [ "." ] + configs += [ ":libcef_includes_config" ] deps = [ "//build/config:executable_deps", "//sandbox/mac:seatbelt" @@ -1505,13 +1514,24 @@ action("make_api_hash_header") { args = rebase_path(outputs + include_dir, root_build_dir) } +# This no-op action lists args.gn as an output, allowing it to be referenced as +# an input (trigger) for other actions. Otherwise, GN will complain that no +# target generates the args.gn file because it’s below the $root_out_dir. +action("args_gn_source") { + script = "//build/noop.py" + outputs = [ "$root_out_dir/args.gn" ] +} + # Generate cef_config.h. action("make_config_header") { script = "tools/make_config_header.py" + deps = [ ":args_gn_source" ] + + inputs = [ "$root_out_dir/args.gn" ] outputs = [ "$root_out_dir/includes/cef/include/cef_config.h" ] - args = rebase_path(outputs + [ "$root_out_dir/args.gn" ], root_build_dir) + args = rebase_path(outputs + inputs, root_build_dir) } # Generate cef_color_ids.h. diff --git a/include/base/cef_build.h b/include/base/cef_build.h index 6f20639a9..d287cf706 100644 --- a/include/base/cef_build.h +++ b/include/base/cef_build.h @@ -71,11 +71,26 @@ #include "build/build_config.h" #include "cef/libcef/features/features.h" +// The following #defines are used in cef/include/ headers and CEF client-side +// code. CEF library-side code should use BUILDFLAG checks directly instead of +// these #defines. CEF client-side code will get these #defines from +// cef_config.h so any changes must also be reflected in +// tools/make_config_header.py. + +#if BUILDFLAG(IS_LINUX) +#include "ui/base/ozone_buildflags.h" +#if BUILDFLAG(IS_OZONE_X11) +#define CEF_X11 1 +#endif +#endif + #if !BUILDFLAG(ENABLE_ALLOY_BOOTSTRAP) #define DISABLE_ALLOY_BOOTSTRAP 1 #endif #else // !USING_CHROMIUM_INCLUDES +#include "include/cef_config.h" + // The following is substantially similar to the Chromium implementation. // If the Chromium implementation diverges the below implementation should be // updated to match. diff --git a/include/internal/cef_types_linux.h b/include/internal/cef_types_linux.h index eb09f189e..84972cd7f 100644 --- a/include/internal/cef_types_linux.h +++ b/include/internal/cef_types_linux.h @@ -32,7 +32,6 @@ #pragma once #include "include/base/cef_build.h" -#include "include/cef_config.h" #if defined(OS_LINUX) diff --git a/libcef/features/BUILD.gn b/libcef/features/BUILD.gn index f917b9870..18d6e87ec 100644 --- a/libcef/features/BUILD.gn +++ b/libcef/features/BUILD.gn @@ -87,12 +87,14 @@ buildflag_header("features") { } # Configuration for all targets that include CEF source code library-side. +# See //cef/libcef_includes_config for CEF client-side configuration. config("config") { - # CEF sources use includes relative to the CEF root directory. include_dirs = [ + # cef/include/ directory uses #includes relative to the cef/ directory. "//cef", - # CEF generates some header files that also need to be discoverable. + # CEF generated header files that also need to be discoverable. + # These #includes from library-side code will always be prefixed with cef/. "$root_build_dir/includes", ] defines = [ diff --git a/tests/ceftests/run_all_unittests.cc b/tests/ceftests/run_all_unittests.cc index 53ee48b20..386ddaa41 100644 --- a/tests/ceftests/run_all_unittests.cc +++ b/tests/ceftests/run_all_unittests.cc @@ -5,7 +5,6 @@ #include #include "include/base/cef_build.h" -#include "include/cef_config.h" #if defined(OS_LINUX) && defined(CEF_X11) #include diff --git a/tools/make_config_header.py b/tools/make_config_header.py index e5d98ed36..bcf6aa87b 100644 --- a/tools/make_config_header.py +++ b/tools/make_config_header.py @@ -16,13 +16,21 @@ def make_config_header(gn_config): defines = [] - if sys.platform.startswith('linux'): - lines = read_file(gn_config).split("\n") + lines = read_file(gn_config).split("\n") - # All Linux builds use Ozone, and the X11 platform is enabled by default. - # Check if the config is explicitly disabling it. - if not 'ozone_platform_x11=false' in lines: - defines.append('#define CEF_X11 1') + # The following #defines are used in cef/include/ headers and CEF client-side code. + # CEF library-side code will get these #defines from include/base/cef_build.h so + # any changes must also be reflected there. + + # All Linux builds use Ozone, and the X11 platform is enabled by default. + # Check if the config is explicitly disabling it. + if sys.platform.startswith('linux') and \ + not 'ozone_platform_x11=false' in lines: + defines.append('#define CEF_X11 1') + + # Temporary define for disabling the Alloy bootstrap. See issue #3685. + if 'enable_alloy_bootstrap=false' in lines: + defines.append('#define DISABLE_ALLOY_BOOTSTRAP 1') result = get_copyright(full=True, translator=False) + \ """//