Skip to content

Commit

Permalink
Add initial support for API versioning (see #3836)
Browse files Browse the repository at this point in the history
- Generated files are now created when running cef_create_projects or
  the new version_manager.py tool. These files are still created in the
  cef/ source tree (same location as before) but Git ignores them due to
  the generated .gitignore file.
- API hashes are committed to Git as a new cef_api_versions.json file.
  This file is used for both code generation and CEF version calculation
  (replacing the previous usage of cef_api_hash.h for this purpose).
  It will be updated by the CEF admin before merging breaking API
  changes upstream.
- As an added benefit to the above, contributor PRs will no longer
  contain generated code that is susceptible to frequent merge conflicts.
- From a code generation perspective, the main difference is that we now
  use versioned structs (e.g. cef_browser_0_t instead of cef_browser_t)
  on the libcef (dll/framework) side. Most of the make_*.py tool changes
  are related to supporting this.
- From the client perspective, you can now define CEF_API_VERSION in the
  project configuration (or get CEF_EXPERIMENTAL by default). This
  define will change the API exposed in CEF’s include/ and include/capi
  header files. All client-side targets including libcef_dll_wrapper
  will need be recompiled when changing this define.
- Examples of the new API-related define usage are provided in
  cef_api_version_test.h, api_version_test_impl.cc and
  api_version_unittest.cc.

To test:
- Run `ceftests --gtest_filter=ApiVersionTest.*`
- Add `cef_api_version=13300` to GN_DEFINES. Re-run configure, build and
  ceftests steps.
- Repeat with 13301, 13302, 13303 (all supported test versions).
  • Loading branch information
magreenblatt committed Jan 8, 2025
1 parent 219bf34 commit dd81904
Show file tree
Hide file tree
Showing 68 changed files with 7,492 additions and 1,291 deletions.
55 changes: 55 additions & 0 deletions .gitignore.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
*.gypcmd
*.mk
*.ncb
*.opensdf
*.props
*.pyc
*.rules
*.sdf
*.sln
*.sublime-project
*.sublime-workspace
*.suo
*.targets
*.user
*.vcproj
*.vcxproj
*.vcxproj.filters
*.vpj
*.vpw
*.vpwhistu
*.vtg
*.xcodeproj
*.xcworkspace
*_proto.xml
*_proto_cpp.xml
*~
!Android.mk
.*.sw?
.DS_Store
.classpath
.cproject
.gdb_history
.gdbinit
.landmines
.metadata
.project
.pydevproject
.vscode
# Settings directory for eclipse
/.settings
.checkstyle
cscope.*
Session.vim
tags
Thumbs.db
# IDE's
.vs/
.kdev4/
*.kdev4
# CEF generated directories
/binary_distrib
/docs
# CEF generated files
.ccls-cache/
/cef_api_untracked.json
114 changes: 75 additions & 39 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ if (is_win) {
}

deps = [
":make_version_header",

"//components/crash/core/common", # crash_keys

# Required by chrome_switches.cc
Expand Down Expand Up @@ -441,6 +443,7 @@ source_set("libcef_test_support") {
"libcef/browser/test/test_helpers_impl.cc",
"libcef/browser/test/test_server_impl.cc",
"libcef/browser/test/test_server_impl.h",
"libcef/common/test/api_version_test_impl.cc",
"libcef/common/test/translator_test_impl.cc",
]

Expand All @@ -451,6 +454,10 @@ source_set("libcef_test_support") {
# Support for UI input events.
"//ui/views:test_support",
]

configs += [
":libcef_includes_config",
]
}


Expand Down Expand Up @@ -758,6 +765,7 @@ source_set("libcef_static") {
"libcef/browser/xml_reader_impl.h",
"libcef/browser/zip_reader_impl.cc",
"libcef/browser/zip_reader_impl.h",
"libcef/common/api_version_util.h",
"libcef/common/app_manager.cc",
"libcef/common/app_manager.h",
"libcef/common/base_impl.cc",
Expand Down Expand Up @@ -1159,6 +1167,10 @@ config("libcef_dll_wrapper_config") {
if (is_mac) {
cflags_objcc = [ "-std=c++17" ]
}

if (cef_api_version != "") {
defines = [ "CEF_API_VERSION=$cef_api_version" ]
}
}

# libcef_dll_wrapper target.
Expand Down Expand Up @@ -1245,16 +1257,16 @@ grit("cef_resources") {
# Helper for generating pack header files.
template("make_pack_header") {
assert(defined(invoker.header))
assert(defined(invoker.inc))
assert(defined(invoker.inputs))

action("make_pack_header_${target_name}") {
script = "tools/make_pack_header.py"

inputs = invoker.inputs
outputs = [ invoker.header ]
outputs = [ invoker.header, invoker.inc ]

args = rebase_path(outputs, root_build_dir) +
rebase_path(inputs, root_build_dir)
args = rebase_path(outputs + inputs, root_build_dir)

if (defined(invoker.deps)) {
deps = invoker.deps
Expand All @@ -1265,6 +1277,7 @@ template("make_pack_header") {
# Generate cef_pack_resources.h.
make_pack_header("resources") {
header = "$root_out_dir/includes/cef/include/cef_pack_resources.h"
inc = "$root_gen_dir/cef/libcef_dll/cef_pack_resources.inc"
inputs = [
"$root_gen_dir/base/tracing/protos/grit/tracing_proto_resources.h",
"$root_gen_dir/cef/grit/cef_resources.h",
Expand Down Expand Up @@ -1331,6 +1344,7 @@ make_pack_header("resources") {
# Generate cef_pack_strings.h.
make_pack_header("strings") {
header = "$root_out_dir/includes/cef/include/cef_pack_strings.h"
inc = "$root_gen_dir/cef/libcef_dll/cef_pack_strings.inc"
inputs = [
"$root_gen_dir/cef/grit/cef_strings.h",
"$root_gen_dir/chrome/grit/branded_strings.h",
Expand Down Expand Up @@ -1374,26 +1388,39 @@ make_pack_header("strings") {
# Generate cef_command_ids.h.
make_pack_header("command_ids") {
header = "$root_out_dir/includes/cef/include/cef_command_ids.h"
inc = "$root_gen_dir/cef/libcef_dll/cef_command_ids.inc"
inputs = [
"//chrome/app/chrome_command_ids.h",
]
}

# Generate cef_api_hash.h.
action("make_api_hash_header") {
script = "tools/make_api_hash_header.py"

# List of all C API files that will be checked for changes by cef_api_hash.py.
inputs = gypi_paths2.includes_common_capi +
gypi_paths2.includes_linux_capi +
gypi_paths2.includes_mac_capi +
gypi_paths2.includes_win_capi +
gypi_paths2.includes_capi +
gypi_paths.autogen_capi_includes
include_dir = [ "include" ]
outputs = [ "$root_out_dir/includes/cef/include/cef_api_hash.h" ]

args = rebase_path(outputs + include_dir, root_build_dir)
# Generate cef_api_versions.h.
action("make_api_versions_header") {
script = "tools/make_api_versions_header.py"

inputs = [
"cef_api_versions.json",
"cef_api_untracked.json",
]
outputs = [
"$root_out_dir/includes/cef/include/cef_api_versions.h",
"$root_gen_dir/cef/libcef_dll/cef_api_versions.inc",
]

args = rebase_path(outputs + inputs, root_build_dir)
}

# Generate cef_version.h.
action("make_version_header") {
script = "tools/make_version_header.py"

inputs = [
"VERSION.stamp",
"//chrome/VERSION",
]
outputs = [ "$root_out_dir/includes/cef/include/cef_version.h" ]

args = rebase_path(outputs, root_build_dir)
}

# This no-op action lists args.gn as an output, allowing it to be referenced as
Expand Down Expand Up @@ -1436,7 +1463,8 @@ group("cef_make_headers") {
":make_pack_header_resources",
":make_pack_header_strings",
":make_pack_header_command_ids",
":make_api_hash_header",
":make_api_versions_header",
":make_version_header",
":make_config_header",
":make_colorids_header",
]
Expand All @@ -1447,6 +1475,28 @@ group("cef_make_headers") {
# libcef dll/framework target.
#

libcef_sources_common = includes_common +
gypi_paths.autogen_cpp_includes +
gypi_paths2.includes_capi +
gypi_paths.autogen_capi_includes +
gypi_paths.autogen_capi_versions_includes +
gypi_paths2.libcef_sources_common +
gypi_paths.autogen_library_side + [
"$root_gen_dir/cef/libcef_dll/cef_pack_resources.inc",
"$root_gen_dir/cef/libcef_dll/cef_pack_strings.inc",
"$root_gen_dir/cef/libcef_dll/cef_command_ids.inc",
"$root_gen_dir/cef/libcef_dll/cef_api_versions.inc",
]

libcef_deps_common = [
":libcef_static",
":libcef_test_support",
":make_pack_header_resources",
":make_pack_header_strings",
":make_pack_header_command_ids",
":make_api_versions_header",
]

if (is_mac) {
cef_framework_name = "Chromium Embedded Framework"

Expand Down Expand Up @@ -1530,24 +1580,17 @@ if (is_mac) {
"Resources",
]

sources = includes_common +
includes_mac +
gypi_paths.autogen_cpp_includes +
gypi_paths2.includes_capi +
gypi_paths.autogen_capi_includes +
gypi_paths2.libcef_sources_common +
gypi_paths.autogen_library_side
sources = libcef_sources_common + includes_mac

deps = [
deps = libcef_deps_common + [
":cef_framework_angle_binaries",
":cef_framework_resources",
":cef_framework_swiftshader_binaries",
":libcef_static",
":libcef_test_support",
]

configs += [
":libcef_autogen_config",
":libcef_includes_config",
]

# We don't link the framework so just use the path from the main executable.
Expand Down Expand Up @@ -1586,20 +1629,13 @@ if (is_mac) {
# Necessary because the libcef_test_support target is testonly.
testonly = true

sources = includes_common +
gypi_paths.autogen_cpp_includes +
gypi_paths2.includes_capi +
gypi_paths.autogen_capi_includes +
gypi_paths2.libcef_sources_common +
gypi_paths.autogen_library_side
sources = libcef_sources_common

deps = [
":libcef_static",
":libcef_test_support",
]
deps = libcef_deps_common

configs += [
":libcef_autogen_config",
":libcef_includes_config",
":pdb_larger_than_4gb",
]

Expand Down
34 changes: 34 additions & 0 deletions cef_api_versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"hashes": {
"13300": {
"comment": "Added January 07, 2025.",
"linux": "f0b073047a026b83e911ba60aa1a83f036d31b0e",
"mac": "39c1f7df430aeaf39911147032b266416658c11d",
"universal": "dd40c0c97ba3f4a1f4ec53ff64d19fea30217d3d",
"windows": "4d97ebe2ed64b448b23625c6bd3943797ac3e137"
},
"13301": {
"comment": "Added January 07, 2025.",
"linux": "41f72b80f8a2d00ea8301cda42d37b8fdf0240a5",
"mac": "e44f5eb6d634f3d4353f52ff383bf213f3894bbd",
"universal": "f7edff150ad480bc2f5cfc85fd6bfa23fbc4a73f",
"windows": "130d2eed0662c065a1cee3c782a6d855c63d67e8"
},
"13302": {
"comment": "Added January 07, 2025.",
"linux": "2ef9e3f071838f2d7705d144cf66e0f5ae69b32f",
"mac": "ec74fb1f9aff97f55882dbb35ba979934c8ab1a7",
"universal": "d9c1eedf985ddcd4e9df05f7664b111462d45626",
"windows": "f4d05b712907d8d64df80029d9e2e8edbee814ac"
},
"13303": {
"comment": "Added January 07, 2025.",
"linux": "397ad962a3049dad4b36b356c8d108f78603de60",
"mac": "f7a5c733b8c3cd6fa3a284ce9b307566c6aa5860",
"universal": "91d5546d2b3f601ab2453f218a7bd69d2fd39b1b",
"windows": "b24722530b6b77bd1a633af5d72088225468eee2"
}
},
"last": "13303",
"min": "13300"
}
4 changes: 3 additions & 1 deletion cef_paths2.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@
'include/base/internal/cef_thread_checker_impl.h',
'include/cef_api_hash.h',
'include/cef_base.h',
'include/cef_version.h',
'include/internal/cef_export.h',
'include/internal/cef_ptr.h',
'include/internal/cef_string_wrappers.h',
'include/internal/cef_time_wrappers.h',
'include/internal/cef_types_wrappers.h',
],
'includes_common_capi': [
'include/cef_id_mappers.h',
'include/cef_version_info.h',
'include/internal/cef_dump_without_crashing_internal.h',
'include/internal/cef_logging_internal.h',
'include/internal/cef_string.h',
Expand Down Expand Up @@ -483,6 +484,7 @@
'tests/ceftests/resources/net/data/ssl/certificates/root_ca_cert.pem',
],
'ceftests_sources_common': [
'tests/ceftests/api_version_unittest.cc',
'tests/ceftests/audio_output_unittest.cc',
'tests/ceftests/browser_info_map_unittest.cc',
'tests/ceftests/certificate_error_unittest.cc',
Expand Down
14 changes: 14 additions & 0 deletions cmake/cef_variables.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ list(APPEND CEF_COMPILER_DEFINES
option(USE_SANDBOX "Enable or disable use of the sandbox." ON)


# Optionally configure the CEF API version by adding `-D api_version=XXXXX` to the
# cmake command-line where XXXXX is the desired version number. For background see
# https://bitbucket.org/chromiumembedded/cef/wiki/ApiVersioning.md
if(DEFINED api_version)
string(LENGTH "${api_version}" length)
if (NOT length EQUAL 5 OR NOT api_version MATCHES "^[0-9]+$")
message(FATAL_ERROR "Expected a 5 digit number for api_version, got '${api_version}'")
endif()
list(APPEND CEF_COMPILER_DEFINES
CEF_API_VERSION=${api_version}
)
endif()


#
# Linux configuration.
#
Expand Down
3 changes: 3 additions & 0 deletions include/base/cef_build.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@
#endif

#else // !USING_CHROMIUM_INCLUDES

#if !defined(GENERATING_CEF_API_HASH)
#include "include/cef_config.h"
#endif

// The following is substantially similar to the Chromium implementation.
// If the Chromium implementation diverges the below implementation should be
Expand Down
Loading

0 comments on commit dd81904

Please sign in to comment.