Skip to content

Commit f47da8b

Browse files
linesightclaude
andcommitted
refactor(cef): re-import clean CEF 147 headers; source generated headers from CEF_ROOT
The vendored src/include tree had drifted from upstream: a stale internal/cef_types.h missing the CEF 147 CEF_API_ADDED(14700) ABI content (new result codes, permission types, CPAIT enums) while the build links the 147 binary, plus AI cosmetic edits (em-dashes, license reflow), removed-upstream headers (cef_extension*, base/cef_callback_list, cef_auto_reset, cef_ptr_util, cef_tuple, ...), and checked-in generated release headers. Re-import src/include cleanly from the upstream CEF source repository at the exact build commit (chromiumembedded/cef@d58e84d = 147.0.10+gd58e84d), verified byte-identical to all three platform binary distributions (Linux/macOS exact; Windows exact after CRLF normalization). The platform-generated headers are intentionally NOT vendored (they are produced during CEF packaging and differ per platform): cef_version.h, cef_config.h, cef_api_versions.h, cef_color_ids.h, cef_command_ids.h, cef_pack_resources.h, cef_pack_strings.h, and base/internal/cef_net_error_list.h. They are still required at compile time because upstream headers include them transitively (e.g. cef_browser.h -> cef_command_ids.h; cef_api_hash.h -> cef_version.h; cef_types.h -> cef_net_error_list.h), so they are now resolved from CEF_ROOT/include: - CMake lists CEF_ROOT after src/ on the include path (module, client_handler, cpp_utils, subprocess) so vendored source headers take precedence and only the generated headers fall through to the CEF SDK. - automate.py --prebuilt-cef copies include/ into the prebuilt CEF_ROOT so it is a complete SDK; the copy is idempotent so a CI-cached prebuilt dir created before this change is repaired. Also removes the unused capi/ headers and documents the reproducible header re-import procedure in docs/Contributing-code.md ("Updating CEF version") so future upgrades stay clean. Verified on Linux: clean build, 85/85 unit tests, hello_world. Windows/macOS rely on CI; their headers were verified byte-identical to the respective dists. Addresses review feedback on PR cztomczak#691 (cztomczak/cefpython). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent f722886 commit f47da8b

31 files changed

Lines changed: 239 additions & 22615 deletions

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,12 @@ target_include_directories(${MODULE_NAME} PRIVATE
252252
"${SRC_DIR}/extern"
253253
"${SRC_DIR}/extern/cef"
254254
"${PYX_STAGE_DIR}"
255+
# After src/: resolves the platform-generated CEF headers that are not
256+
# vendored in src/include (cef_version.h, cef_api_versions.h, cef_pack_*.h,
257+
# cef_color_ids.h, cef_command_ids.h, cef_config.h,
258+
# base/internal/cef_net_error_list.h). Vendored source headers in
259+
# src/include take precedence because SRC_DIR is listed first.
260+
"${CEF_ROOT}"
255261
)
256262

257263
if(ENABLE_LINE_TRACING)

docs/Contributing-code.md

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,67 @@ to add your name and encoded email.
149149

150150
## Updating CEF version
151151

152-
If you want to update CEF version then take a look at
153-
[Issue #264](../../../issues/264)("Workflow when updating CEF version").
152+
For the general workflow see
153+
[Issue #264](../../../issues/264) ("Workflow when updating CEF version").
154+
155+
### Re-importing the CEF headers
156+
157+
cefpython compiles against the CEF headers vendored in `src/include/` (the
158+
include path starts at `src/`, so `#include "include/cef_*.h"` resolves there).
159+
On every CEF upgrade these headers must be re-imported cleanly from the upstream
160+
**CEF source repository** — not copied from the binary distribution — so they
161+
stay byte-identical to upstream and don't accumulate stale/edited content.
162+
163+
`src/include/` holds only the stable, hand-written public headers. The
164+
following **generated** headers are intentionally *not* vendored; they are
165+
produced during CEF release packaging (and differ per platform), and are
166+
resolved at build time from `CEF_ROOT/include` instead:
167+
168+
- `cef_version.h`, `cef_config.h`, `cef_api_versions.h`
169+
- `cef_color_ids.h`, `cef_command_ids.h`
170+
- `cef_pack_resources.h`, `cef_pack_strings.h`
171+
- `base/internal/cef_net_error_list.h`
172+
173+
`tools/automate.py --prebuilt-cef` copies the distribution's `include/` into the
174+
prebuilt `CEF_ROOT` directory so those generated headers are available, and the
175+
CMake include path lists `CEF_ROOT` *after* `src/` so the vendored source
176+
headers always take precedence. The `capi/` C API headers are not used by
177+
cefpython and are not vendored either.
178+
179+
Steps:
180+
181+
1. Bump the version/hashes in `src/version/cef_version_{win,linux,macarm64}.h`.
182+
183+
2. Find the CEF source commit — it is the `g<hash>` in the `CEF_VERSION`
184+
string. For `147.0.10+gd58e84d+chromium-147.0.7727.118` the commit is
185+
`d58e84d`.
186+
187+
3. Fetch that exact source tree and replace `src/include/`:
188+
189+
```bash
190+
commit=d58e84d # from CEF_VERSION above
191+
curl -sL "https://codeload.github.com/chromiumembedded/cef/tar.gz/$commit" \
192+
| tar xz
193+
rm -rf src/include
194+
cp -r "cef-$commit/include" src/include
195+
# capi/ and base/internal/cef_net_error_list.h are placeholder stubs in the
196+
# source tree (the stub #includes a Chromium path and is replaced with the
197+
# real content during CEF packaging). Remove them so the build resolves the
198+
# real versions from CEF_ROOT/include.
199+
rm -rf src/include/capi
200+
rm -f src/include/base/internal/cef_net_error_list.h
201+
# Drop any non-header docs the source tree ships under include/ (e.g. *.md):
202+
find src/include -type f ! -name '*.h' ! -name '*.inc' -delete
203+
```
204+
205+
The remaining generated headers (`cef_version.h`, `cef_config.h`,
206+
`cef_api_versions.h`, `cef_color_ids.h`, `cef_command_ids.h`,
207+
`cef_pack_resources.h`, `cef_pack_strings.h`) do **not** exist in the source
208+
tree at all — they are created during CEF packaging — so a clean source
209+
import already excludes them and there is nothing to delete. They are
210+
resolved from `CEF_ROOT/include` at build time.
211+
212+
4. Sanity check: the vendored headers should be byte-identical to the same
213+
files in the downloaded CEF binary distribution's `include/` (ignoring the
214+
Windows distribution's CRLF line endings). Then rebuild and run the unit
215+
tests (`unittests/_test_runner.py`).

src/client_handler/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ target_include_directories(client_handler PRIVATE
2121
"${CEFPYTHON_SRC_DIR}/common"
2222
"${CEFPYTHON_PYX_STAGE_DIR}"
2323
${Python_INCLUDE_DIRS}
24+
# After src/: platform-generated CEF headers not vendored in src/include.
25+
"${CEFPYTHON_CEF_ROOT}"
2426
)
2527

2628
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")

src/cpp_utils/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ target_include_directories(cpp_utils PRIVATE
88
"${CEFPYTHON_SRC_DIR}/common"
99
"${CEFPYTHON_PYX_STAGE_DIR}"
1010
${Python_INCLUDE_DIRS}
11+
# After src/: platform-generated CEF headers not vendored in src/include.
12+
"${CEFPYTHON_CEF_ROOT}"
1113
)
1214

1315
# Common browser-process flags come from cefpython_common_flags defined in the

src/include/base/cef_auto_reset.h

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)