Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/wf-driver/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ runs:
- name: Build webfront-wf
shell: bash
run: |
cmake -S . -B build-driver -G Ninja -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON \
cmake -S . -B build-driver -G Ninja -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_ENABLE_TESTING=ON \
-DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK \
-DCMAKE_CXX_SCAN_FOR_MODULES=OFF
cmake --build build-driver --target webfront-wf --parallel 2
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/BuildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
build_type: Debug
test_env: {WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS: '1'}
# GCC 16 compiles the optional C++26 reflection layer of the forms (#383): its tests must not be skipped here.
options: -DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK -DENABLE_COVERAGE=ON -DWEBFRONT_REQUIRE_REFLECTION_TESTS=ON
options: -DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK -DWEBFRONT_ENABLE_COVERAGE=ON -DWEBFRONT_REQUIRE_REFLECTION_TESTS=ON
runs-on: ${{ matrix.os }}
# Only the Linux job runs in the prebuilt toolchain image; an empty value means no container.
container: ${{ matrix.use_image && fromJSON(format('{{"image":"{0}","credentials":{{"username":"{1}","password":"{2}"}},"options":"--shm-size=1g"}}', needs.linux-image.outputs.image, github.actor, github.token)) || '' }}
Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
- name: Configure
run: >-
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON
-DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_ENABLE_TESTING=ON
-DENABLE_CACHE=OFF -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
-DCMAKE_CXX_SCAN_FOR_MODULES=OFF
${{ matrix.options }}
Expand Down Expand Up @@ -323,7 +323,7 @@ jobs:
# No compiler cache: a new user compiles everything.
- name: Configure
shell: bash
run: cmake -S . -B build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON -DENABLE_CACHE=OFF -DCMAKE_CXX_SCAN_FOR_MODULES=OFF
run: cmake -S . -B build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_ENABLE_TESTING=ON -DENABLE_CACHE=OFF -DCMAKE_CXX_SCAN_FOR_MODULES=OFF
- name: Portability tests
shell: bash
run: ctest --test-dir build -C Release -L portability --output-on-failure --no-tests=error
Expand Down Expand Up @@ -375,9 +375,9 @@ jobs:
- name: Configure hardened sanitizer tests
run: >-
cmake -S . -B build-sanitizers -DCMAKE_BUILD_TYPE=RelWithDebInfo
-DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_BUILD_EXAMPLES=OFF -DENABLE_TESTING=ON -DENABLE_CACHE=OFF
-DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_BUILD_EXAMPLES=OFF -DWEBFRONT_ENABLE_TESTING=ON -DENABLE_CACHE=OFF
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_SCAN_FOR_MODULES=OFF
${{ matrix.sanitizer == 'thread' && '-DCMAKE_CXX_FLAGS=-stdlib=libc++ -DENABLE_SANITIZER_THREAD=ON' || '-DENABLE_SANITIZER_ADDRESS=ON -DENABLE_SANITIZER_UNDEFINED_BEHAVIOR=ON -DENABLE_FUZZING=ON -DWEBFRONT_GZIP_DIFFERENTIAL=ON' }}
${{ matrix.sanitizer == 'thread' && '-DCMAKE_CXX_FLAGS=-stdlib=libc++ -DWEBFRONT_ENABLE_SANITIZER_THREAD=ON' || '-DWEBFRONT_ENABLE_SANITIZER_ADDRESS=ON -DWEBFRONT_ENABLE_SANITIZER_UNDEFINED_BEHAVIOR=ON -DWEBFRONT_ENABLE_FUZZING=ON -DWEBFRONT_GZIP_DIFFERENTIAL=ON' }}
- name: Build
run: cmake --build build-sanitizers --parallel 2
- name: Run full CEF-off suite
Expand Down Expand Up @@ -459,7 +459,7 @@ jobs:

# The registry packages and the pinned bootstrap environment are downloaded and verified here; wf then builds the rest.
- name: Configure CEF integration build
run: cmake . -B ${{github.workspace}}/build-cef -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_EMBED_CEF=ON -DWEBFRONT_BUILD_EXAMPLES=OFF -DENABLE_TESTING=ON -DENABLE_CACHE=OFF -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_SCAN_FOR_MODULES=OFF
run: cmake . -B ${{github.workspace}}/build-cef -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_EMBED_CEF=ON -DWEBFRONT_BUILD_EXAMPLES=OFF -DWEBFRONT_ENABLE_TESTING=ON -DENABLE_CACHE=OFF -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_SCAN_FOR_MODULES=OFF

- name: Build browser test
run: cmake --build ${{github.workspace}}/build-cef --target webtest developer_integration webfront-wf --parallel 2
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/MddlogIntegration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Configure source integration
run: >-
cmake -S . -B build-mddlog-source -G Ninja
-DCMAKE_BUILD_TYPE=Release -DENABLE_CACHE=OFF -DENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF
-DCMAKE_BUILD_TYPE=Release -DENABLE_CACHE=OFF -DWEBFRONT_ENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/dependencies/mddlog/cmake/toolchains/linux-clang21-libcxx.cmake
-DWEBFRONT_USE_MDDLOG=ON
-DWEBFRONT_MDDLOG_SOURCE_DIR=${{ github.workspace }}/dependencies/mddlog
Expand All @@ -60,7 +60,7 @@ jobs:
- name: Configure installed integration
run: >-
cmake -S . -B build-mddlog-install -G Ninja
-DCMAKE_BUILD_TYPE=Release -DENABLE_CACHE=OFF -DENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF
-DCMAKE_BUILD_TYPE=Release -DENABLE_CACHE=OFF -DWEBFRONT_ENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/dependencies/mddlog/cmake/toolchains/linux-clang21-libcxx.cmake
-DWEBFRONT_USE_MDDLOG=ON
-DCMAKE_PREFIX_PATH=${{ github.workspace }}/mddlog-install
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
- name: Configure instrumented source integration
run: >-
cmake -S . -B build-sanitized -G Ninja
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_CACHE=OFF -DENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_CACHE=OFF -DWEBFRONT_ENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/dependencies/mddlog/cmake/toolchains/linux-clang21-libcxx.cmake
"-DCMAKE_CXX_FLAGS=-stdlib=libc++ ${{ matrix.flags }} -fno-omit-frame-pointer"
"-DCMAKE_EXE_LINKER_FLAGS=${{ matrix.flags }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ReleaseVersion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
with:
version: '4.4.4'
- name: Detect project version with CMake
run: cmake -S . -B build -DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF
run: cmake -S . -B build -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_ENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF
- name: Compare release tag with header and CMake
env:
RELEASE_TAG: ${{ github.event.release.tag_name || github.ref_name }}
Expand Down
12 changes: 6 additions & 6 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ cmake --build . --parallel 2

# Fast, portable C++ baseline (no CEF download)
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
-DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON
-DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_ENABLE_TESTING=ON
cmake --build build --parallel
ctest --test-dir build --output-on-failure --parallel 4

Expand All @@ -58,13 +58,13 @@ ctest --test-dir build --output-on-failure --parallel 4
# Linux real-browser integration test: configure downloads and verifies the pinned bootstrap environment and the packages
# of the local npm registry; the tests build the rest with wf
cmake -S . -B build-cef -DCMAKE_BUILD_TYPE=Release \
-DWEBFRONT_EMBED_CEF=ON -DENABLE_TESTING=ON
-DWEBFRONT_EMBED_CEF=ON -DWEBFRONT_ENABLE_TESTING=ON
cmake --build build-cef --target webtest webfront-wf --parallel
ctest --test-dir build-cef -L web-integration --output-on-failure --parallel 4

```

Build the developer environment with wf (the driver comes from any build with `ENABLE_TESTING=ON`), as
Build the developer environment with wf (the driver comes from any build with `WEBFRONT_ENABLE_TESTING=ON`), as
`js/developer/tools/PUBLISHING.md` describes:

```bash
Expand All @@ -78,17 +78,17 @@ Important CMake options:

The headers of the embedded assets are generated, and checked by CTest, in pure CMake (`js/core/EmbedAsset.cmake`; the
`webfront-embedded-assets` target regenerates them). Normal C++ builds consume the versioned headers. Configuring with
`ENABLE_TESTING=ON` downloads the pinned bootstrap environment and the packages of the test registry, each verified
`WEBFRONT_ENABLE_TESTING=ON` downloads the pinned bootstrap environment and the packages of the test registry, each verified
against its SHA-512; `-DWEBFRONT_BOOTSTRAP_DIR` and `-DWEBFRONT_REGISTRY_DIR` replace those downloads on a machine
without network access.

- `WEBFRONT_EMBED_CEF=OFF` (default): CEF is unavailable; this is the normal unit-test build. `ON` downloads/links CEF and enables the automated browser test; it makes `CEFFrontend` available but does not select it: `webfront::WebFront` always uses the system browser.
- `WEBFRONT_EMBED_WEBVIEW2=OFF` (default): Windows-only opt-in SDK and static loader for `WebView2Frontend`; requires the separately installed Evergreen runtime. Select it explicitly with `WebFrontWithFrontend<frontend::WebView2Frontend>`. With tests enabled, `WEBFRONT_WEBTEST_FRONTEND=WebView2` runs the shared Jasmine suite and lifecycle cases.
- `WEBFRONT_EMBED_WKWEBVIEW=OFF` (default): macOS 13.3+ opt-in Cocoa/WebKit frontend, with no engine download. Select `WebFrontWithFrontend<frontend::WKWebViewFrontend>` on the main thread; `WEBFRONT_WEBTEST_FRONTEND=WKWebView` runs Jasmine and lifecycle coverage.

- `ENABLE_TESTING=ON` (default `OFF`): build Catch2 and Jasmine test targets. CI and contributor commands must pass it explicitly.
- `WEBFRONT_ENABLE_TESTING=ON` (default `OFF`): build Catch2 and Jasmine test targets. CI and contributor commands must pass it explicitly. The test, fuzzing, coverage and sanitizer options (`WEBFRONT_ENABLE_SANITIZER_*`) carry the `WEBFRONT_` prefix so that a parent's own `ENABLE_TESTING` or `ENABLE_SANITIZER_ADDRESS` never builds or instruments WebFront's tests; the former unprefixed names are accepted, with a deprecation warning, only at the top level and until 0.7.0, and a prefixed name given by the same configure always wins (`cmake/WebFrontTestOptions.cmake` documents the rules).
- `WEBFRONT_BUILD_EXAMPLES` (default `ON` only for the top-level project): build the examples. As a subproject (`add_subdirectory`), link `WebFront::WebFront`; no examples, tests or global compiler settings are added.
- `ENABLE_COVERAGE=ON`: add GCC/Clang coverage instrumentation to the C++ tests.
- `WEBFRONT_ENABLE_COVERAGE=ON`: add GCC/Clang coverage instrumentation to the C++ tests.

If the environment provides a read-only default ccache directory, set `CCACHE_DIR` to a writable temporary directory for local builds. Do not encode machine-specific cache paths in project files. In CI, `ENABLE_CACHE=OFF` disables automatic cache discovery while `CMAKE_CXX_COMPILER_LAUNCHER=sccache` explicitly enables sccache; a PATH/version probe runs on all three platforms. The combined Linux job uses Debug with GCC coverage on every PR; Windows and macOS use Release. The WebKitGTK sandbox opt-out is confined to the Linux test step and trusted fixtures.

Expand Down
17 changes: 8 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ else()
endif()

option(BUILD_SHARED_LIBS "Enable compilation of shared libraries" OFF)
option(ENABLE_TESTING "Enable Test Builds" OFF)
option(WEBFRONT_BUILD_AUTOMATION "Build the optional local developer CLI/MCP launcher" OFF)
option(WEBFRONT_BUILD_EXAMPLES "Build the example applications" ${WEBFRONT_IS_TOP_LEVEL})
option(ENABLE_COVERAGE "Enable test coverage instrumentation" OFF)
option(ENABLE_FUZZING "Enable Fuzzing Builds" OFF)
option(WEBFRONT_GZIP_DIFFERENTIAL "Build test-only gzip/zlib differential checks" OFF)
option(WEBFRONT_USE_MDDLOG "Use the compiled mddlog diagnostic adapter" OFF)
# The experimental gate must be selected before project() probes the compiler.
Expand All @@ -28,12 +25,14 @@ set(VERSION_STRING_REGEX "inline constexpr std::string_view version = \"([0-9]+\
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/include/webfront/WebFront.hpp" VERSION_STRING REGEX ${VERSION_STRING_REGEX})
string(REGEX MATCH "([0-9]+\\.[0-9]+\\.[0-9]+)" VERSION_STRING "${VERSION_STRING}")
project(WebFront LANGUAGES CXX VERSION ${VERSION_STRING})
# After project(): a toolchain file's variables are then visible, as they were to the former option() calls.
include(cmake/WebFrontTestOptions.cmake)
webfront_declare_test_options(${WEBFRONT_IS_TOP_LEVEL})

include(cmake/Frontends.cmake)
# Applications need no -DWEBFRONT_EMBED_* option: unless the user decided, this platform's native window
# engine is enabled when its dependencies are present. Test and fuzzing builds keep explicit selection.
# An embedding parent's variables of those names do not decide for its consumers.
if(NOT WEBFRONT_IS_TOP_LEVEL OR (NOT ENABLE_TESTING AND NOT ENABLE_FUZZING))
if(NOT WEBFRONT_ENABLE_TESTING AND NOT WEBFRONT_ENABLE_FUZZING)
set(WEBFRONT_AUTODETECT_NATIVE_DEFAULT ON)
else()
set(WEBFRONT_AUTODETECT_NATIVE_DEFAULT OFF)
Expand Down Expand Up @@ -127,7 +126,7 @@ webfront_add_embedded_assets()
# Opt-in consumer test registration; inclusion alone downloads nothing and registers no tests.
include(WebFrontJasmine)

if(WEBFRONT_BUILD_AUTOMATION OR (ENABLE_TESTING AND
if(WEBFRONT_BUILD_AUTOMATION OR (WEBFRONT_ENABLE_TESTING AND
(WEBFRONT_EMBED_CEF OR WEBFRONT_EMBED_WKWEBVIEW OR WEBFRONT_EMBED_WEBVIEW2 OR WEBFRONT_EMBED_WEBKITGTK)))
webfront_default_embedded_frontend(_automation_default FALLBACK CEF)
webfront_select_frontend(WEBFRONT_AUTOMATION_FRONTEND "${_automation_default}"
Expand All @@ -144,15 +143,15 @@ if(WEBFRONT_BUILD_AUTOMATION OR (ENABLE_TESTING AND
webfront_setup_frontends_for_target(webfront-agent)
endif()

if(ENABLE_TESTING OR ENABLE_FUZZING)
if(WEBFRONT_ENABLE_TESTING OR WEBFRONT_ENABLE_FUZZING)
include(TestHardening)
endif()

if(ENABLE_FUZZING)
if(WEBFRONT_ENABLE_FUZZING)
add_subdirectory(test/fuzz)
endif()

if(ENABLE_TESTING)
if(WEBFRONT_ENABLE_TESTING)
enable_testing()
add_subdirectory(test/unit)
add_subdirectory(test/web)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ When the engine is missing, configuration still succeeds. CMake prints a `Native

**Advanced options.**

- Choose the engine yourself with `-DWEBFRONT_EMBED_WEBVIEW2=ON|OFF`, `-DWEBFRONT_EMBED_WKWEBVIEW=ON|OFF` or `-DWEBFRONT_EMBED_WEBKITGTK=ON|OFF`; an explicit value is never replaced by the detection. `-DWEBFRONT_AUTODETECT_NATIVE=OFF` disables it. Test builds (`-DENABLE_TESTING=ON`) keep the explicit selection.
- Choose the engine yourself with `-DWEBFRONT_EMBED_WEBVIEW2=ON|OFF`, `-DWEBFRONT_EMBED_WKWEBVIEW=ON|OFF` or `-DWEBFRONT_EMBED_WEBKITGTK=ON|OFF`; an explicit value is never replaced by the detection. `-DWEBFRONT_AUTODETECT_NATIVE=OFF` disables it. Test builds (`-DWEBFRONT_ENABLE_TESTING=ON`) keep the explicit selection.
- Automatic engine choices are recalculated on each configuration and do not create an engine option in the cache. To return from an explicit macOS choice to automatic detection, run `cmake .. -UWEBFRONT_EMBED_WKWEBVIEW` (or remove the corresponding engine option on another platform).
- Another project directory, and another environment archive, can be passed: `examples/WebFrontLifeDeveloper <project> [<environment-url> <sha512-integrity>]`, for instance an environment [built from the sources](docs/DEVELOPER_ENVIRONMENT.md#environment-distribution-and-offline-tests-maintainers).

Expand Down Expand Up @@ -295,15 +295,15 @@ int main() {

To get a native window when one can be opened and the system browser otherwise (for example over SSH, in a container or in CI, where no display exists), use `WebFrontWithFrontend<webfront::frontend::NativeOrBrowserFrontend>`: no `#if` is needed, and the reason for a fallback is printed once. See [docs/FRONTENDS.md](docs/FRONTENDS.md).

Native engines are detected by default for consumer builds, whatever variables the parent project defines, and for standalone builds except with `ENABLE_TESTING=ON` or `ENABLE_FUZZING=ON`. The helper applies the native engine's target setup and defines `WEBFRONT_NATIVE_WINDOW` only when that engine is enabled; otherwise CMake prints installation advice and the application uses the default browser. On Windows, detection requires an MSVC-compatible compiler and downloads the pinned WebView2 SDK; the Evergreen runtime must be installed separately. Linux needs WebKitGTK 6.0 development files, and macOS needs Clang and macOS 13.3 or later. Explicit `WEBFRONT_EMBED_<ENGINE>=ON|OFF` values take precedence; `WEBFRONT_AUTODETECT_NATIVE=OFF` disables detection. No option needs to be set before `add_subdirectory`/CPM for the default path.
Native engines are detected by default, except in WebFront's own test and fuzzing builds (`WEBFRONT_ENABLE_TESTING=ON` or `WEBFRONT_ENABLE_FUZZING=ON`); a parent project's own `ENABLE_TESTING` or `ENABLE_FUZZING` affects neither the detection nor WebFront's tests. The helper applies the native engine's target setup and defines `WEBFRONT_NATIVE_WINDOW` only when that engine is enabled; otherwise CMake prints installation advice and the application uses the default browser. On Windows, detection requires an MSVC-compatible compiler and downloads the pinned WebView2 SDK; the Evergreen runtime must be installed separately. Linux needs WebKitGTK 6.0 development files, and macOS needs Clang and macOS 13.3 or later. Explicit `WEBFRONT_EMBED_<ENGINE>=ON|OFF` values take precedence; `WEBFRONT_AUTODETECT_NATIVE=OFF` disables detection. No option needs to be set before `add_subdirectory`/CPM for the default path.

For explicit engine selection, `webfront_native_frontend_option(out)` and `webfront_setup_frontends_for_target(MyApp)` are also callable from the parent or other directories. The latter applies setup for all enabled engines; the native helper selects only the platform's native engine and never CEF. See [WKWebView](docs/WKWEBVIEW.md), [WebKitGTK](docs/WEBKITGTK.md) and the [frontend architecture](docs/adr/README.md).

## Build and test

```bash
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
-DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON
-DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_ENABLE_TESTING=ON
cmake --build build --parallel 2
ctest --test-dir build --output-on-failure --parallel 4
```
Expand Down
Loading
Loading