Add initial support for API versioning (see #3836)

- 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).
This commit is contained in:
Marshall Greenblatt
2024-12-09 15:20:44 -05:00
parent 219bf3406c
commit dd81904a2f
68 changed files with 7466 additions and 1265 deletions

View File

@ -7,6 +7,7 @@ from __future__ import print_function
from file_util import *
import git_util as git
import os
from version_util import read_version_last, version_parse, VERSIONS_JSON_FILE
class VersionFormatter:
@ -46,15 +47,18 @@ class VersionFormatter:
if not bool(self._chrome_version):
file_path = os.path.join(self.src_path, 'chrome', 'VERSION')
assert os.path.isfile(file_path), file_path
read_version_file(file_path, self._chrome_version)
assert read_version_file(file_path, self._chrome_version), file_path
return self._chrome_version
def get_chrome_major_version(self):
return self.get_chrome_version_components()['MAJOR']
def get_cef_version_components(self):
""" Returns CEF version components. """
if not bool(self._cef_version):
file_path = os.path.join(self.cef_path, 'VERSION.in')
assert os.path.isfile(file_path), file_path
read_version_file(file_path, self._cef_version)
assert read_version_file(file_path, self._cef_version), file_path
return self._cef_version
def get_cef_commit_components(self):
@ -75,11 +79,11 @@ class VersionFormatter:
# branch since branching from origin/master.
hashes = git.get_branch_hashes(self.cef_path)
for hash in hashes:
# Determine if the API hash file was modified by the commit.
# Determine if the API versions file was modified by the commit.
found = False
files = git.get_changed_files(self.cef_path, hash)
for file in files:
if file.find('cef_api_hash.h') >= 0:
if file.find(VERSIONS_JSON_FILE) >= 0:
found = True
break
@ -89,6 +93,14 @@ class VersionFormatter:
else:
bugfix += 1
last_version = read_version_last(
os.path.join(self.cef_path, VERSIONS_JSON_FILE))
if not last_version is None:
major, revision = version_parse(last_version)
if major == int(self.get_chrome_major_version()) and revision > minor:
# Override the computed minor version with the last specified API version.
minor = revision
self._branch_version = {'MINOR': minor, 'PATCH': bugfix}
return self._branch_version
@ -149,8 +161,8 @@ class VersionFormatter:
# - "X" is the Chromium major version (e.g. 74).
# - "Y" is an incremental number that starts at 0 when a release branch is
# created and changes only when the CEF C/C++ API changes (similar to how
# the CEF_API_HASH_UNIVERSAL value behaves in cef_version.h) (release branch
# only).
# the CEF_API_HASH_UNIVERSAL value behaves in cef_api_hash.h) (release
# branch only).
# - "Z" is an incremental number that starts at 0 when a release branch is
# created and changes on each commit, with reset to 0 when "Y" changes
# (release branch only).
@ -186,9 +198,15 @@ class VersionFormatter:
# if we can get the name of the branch we are on (may be just "HEAD").
cef_branch_name = git.get_branch_name(self.cef_path).split('/')[-1]
cef_minor = cef_patch = 0
if cef_branch_name != 'HEAD' and cef_branch_name != 'master':
cef_branch = self.get_cef_branch_version_components()
cef_minor = cef_branch['MINOR']
cef_patch = cef_branch['PATCH']
self._version_parts = {'MAJOR': int(chrome_major), 'MINOR': 0, 'PATCH': 0}
self._version_string = '%s.0.0-%s.%s+%s+%s' % \
(chrome_major, cef_branch_name, cef_commit['NUMBER'],
self._version_string = '%s.%d.%d-%s.%s+%s+%s' % \
(chrome_major, cef_minor, cef_patch, cef_branch_name, cef_commit['NUMBER'],
cef_commit_hash, chrome_version_part)
else:
cef_branch = self.get_cef_branch_version_components()