Skip to content

build: degrade BUILD_FFI gracefully when src/ffi is absent - #1265

Merged
caomengxuan666 merged 1 commit into
mainfrom
fix/1261
Oct 20, 2026
Merged

caomengxuan666 merged 1 commit into
mainfrom
fix/1261

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Fixes #1261

Problem

BUILD_FFI=ON (set by every preset in CMakePresets.json) could not configure on a clean checkout: add_subdirectory(src/ffi) fails because the src/ffi sources were removed from git in d62be40 ("build: remove dead FFI integration") while the subdirectory hook and the BUILD_FFI=ON presets came back in 2097a07. The BUILD_FFI option declaration itself was also dropped in d62be40 — only its comment survived — so the variable only existed via preset cache entries.

Fix

Ticket option 3 (private component → detect + degrade, documented):

  • Re-declare option(BUILD_FFI ...) (default OFF) where its orphaned comment still sits.
  • Guard add_subdirectory(src/ffi) with EXISTS src/ffi/CMakeLists.txt:
    • checkout carrying the FFI sources → builds winuxcore.dll as before;
    • clean checkout → configure succeeds with a clear CMake Warning explaining the sources are not distributed and how to silence it, and BUILD_FFI is forced OFF for that configure.

CMakePresets.json is unchanged — presets keep BUILD_FFI=ON so a checkout that has the sources still builds the FFI library.

Verification

  • scripts/build-with-vs.ps1 -ConfigureOnly on this clean worktree (no src/ffi): configure succeeds — FFI Library: DISABLED (same as before).
  • Same with -DBUILD_FFI=ON: configure succeeds, emits
    CMake Warning: BUILD_FFI=ON but src/ffi is not present in this checkout (the FFI sources are not distributed with the repository). Continuing with the FFI library disabled; pass -DBUILD_FFI=OFF to silence this warning.

No I18N impact: the new text is a CMake configure-time message; the catalog extractor only scans .cpp/.cppm/.h/.hpp.

The src/ffi sources were dropped from git in d62be40 but the
add_subdirectory(src/ffi) hook and the BUILD_FFI=ON presets came back,
so every preset failed to configure on a clean checkout.

Guard the subdirectory on src/ffi actually existing: a checkout that
carries the (private) FFI sources still builds winuxcore.dll, while a
clean checkout configures successfully with a clear warning instead of
a hard error. BUILD_FFI is also declared as a real option again (the
declaration was removed in d62be40 but its comment survived).

Fixes #1261
@caomengxuan666
caomengxuan666 merged commit f3eb437 into main Oct 20, 2026
8 checks passed
@caomengxuan666

Copy link
Copy Markdown
Member Author

Non-blocking, for the record: the with-source posture (src/ffi restored from d62be40^) configures fine and winuxcore lands in build.ninja; its link line uses /WHOLEARCHIVE:winuxcmd-commands without the .lib suffix (unlike the main exe), harmless while FFI stays dead code.

@caomengxuan666
caomengxuan666 deleted the fix/1261 branch October 21, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUILD_FFI=ON 在干净 checkout 无法 configure(src/ffi 不在 git 追踪)——#1255 CR 环境备注

1 participant