Skip to content

Commit

Permalink
Add DISABLE_ALLOY_BOOTSTRAP to cef_config.h (see #3681, see #3685)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
magreenblatt committed May 1, 2024
1 parent 49a34d9 commit b92749a
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 26 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,5 @@ Thumbs.db
/binary_distrib
/docs
# CEF generated files
/include/cef_config.h
/include/cef_version.h
.ccls-cache/
50 changes: 35 additions & 15 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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") {
Expand All @@ -1274,10 +1289,6 @@ config("libcef_dll_wrapper_config") {
ldflags = [ "/STACK:0x800000" ]
}
}

if (!enable_alloy_bootstrap) {
defines = [ "DISABLE_ALLOY_BOOTSTRAP" ]
}
}

# libcef_dll_wrapper target.
Expand Down Expand Up @@ -1311,17 +1322,15 @@ 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" ]
}
}

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"
Expand Down Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions include/base/cef_build.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion include/internal/cef_types_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#pragma once

#include "include/base/cef_build.h"
#include "include/cef_config.h"

#if defined(OS_LINUX)

Expand Down
6 changes: 4 additions & 2 deletions libcef/features/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
1 change: 0 additions & 1 deletion tests/ceftests/run_all_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <memory>

#include "include/base/cef_build.h"
#include "include/cef_config.h"

#if defined(OS_LINUX) && defined(CEF_X11)
#include <X11/Xlib.h>
Expand Down
20 changes: 14 additions & 6 deletions tools/make_config_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) + \
"""//
Expand Down

0 comments on commit b92749a

Please sign in to comment.