(zilch lang ninja): support CMake

Change-Id: I6a6a696445c5513215b7e1df512514586a1dfd3a
This commit is contained in:
puck 2025-05-11 22:21:07 +00:00
parent 48692fc50d
commit 268b6fb8c2
2 changed files with 18 additions and 4 deletions

View file

@ -258,6 +258,10 @@
(define copies (list))
(define (process-input path)
(define input-file (mapping-ref edges path (lambda () (mapping-ref/default edges (normalize-path path) #f))))
(define input-edge (force (cdr input-file)))
; Passthru CMake library symlinks, as CMake assumes this is valid
(when (and input-edge (string=? (build-edge-rule (built-edge-edge input-edge)) "CMAKE_SYMLINK_LIBRARY"))
(for-each process-input (build-edge-inputs (built-edge-edge input-edge))))
(if (eq? (car input-file) 'phony)
(for-each process-input (built-edge-phony-inputs (force (cdr input-file))))
(set! copies (cons #~,(string-append "mkdir -p \"$out/$(dirname " path ")\"; cp -rf " #$(force (car input-file)) " $out/" path) copies))))

View file

@ -25,7 +25,7 @@
"zilchPreConfigure() {\n"
" cd $NIX_BUILD_TOP; mkdir bdir; mv $sourceRoot bdir/src; sourceRoot=bdir/src; cd $sourceRoot\n"
"}\n"
"mesonBuildDir=$NIX_BUILD_TOP/bdir/build\n"
"mesonBuildDir=$NIX_BUILD_TOP/bdir/build cmakeBuildDir=$NIX_BUILD_TOP/bdir/build cmakeDir=\"$NIX_BUILD_TOP/bdir/src/${cmakeDir:-.}\"\n"
"phases=\"${prePhases[*]:-} unpackPhase patchPhase ${preConfigurePhases[*]:-} zilchPreConfigure configurePhase ${preBuildPhases[*]:-}\"\n"
"for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done\n"
"find . '(' -name cmake_trace.txt -o -name meson-log.txt -o -name CMakeConfigureLog.yaml ')' -delete\n"
@ -150,8 +150,7 @@
"cp -rf --no-preserve=ownership " #$realised-built "/* bdir/build\n"
"cd bdir/build\n"
"}\n"
"mesonBuildDir=$NIX_BUILD_TOP/bdir/build\n"
"installPhase=zilchInstall; checkPhase=mesonCheckPhase\n"
"mesonBuildDir=$NIX_BUILD_TOP/bdir/build cmakeBuildDir=$NIX_BUILD_TOP/bdir/build cmakeDir=\"$NIX_BUILD_TOP/bdir/src/${cmakeDir:-.}\"\n"
"zilchFixPlaceholder() {\n"
" find ../out -type f -exec sed -i -e \"s|$1|$2|g\" \"{}\" \";\" || exit 1\n"
" find \"../out\" -type l | while read link; do\n"
@ -163,7 +162,7 @@
fix-placeholders-command
copy-in-place-command
"}\n"
"zilchInstall() {\n"
"zilchMesonInstall() {\n"
" runHook preInstall\n"
" local flagsArray=()\n"
" if [[ -n \"$mesonInstallTags\" ]]; then\n"
@ -174,6 +173,17 @@
" zilchFixup\n"
" runHook postInstall\n"
"}\n"
"zilchCmakeInstall() {\n"
" runHook preInstall\n"
" DESTDIR=$NIX_BUILD_TOP/bdir/out cmake --install .\n"
" zilchFixup\n"
" runHook postInstall\n"
"}\n"
"if [[ $(type -t mesonInstallPhase) == function ]]; then\n"
" installPhase=zilchMesonInstall; checkPhase=mesonCheckPhase\n"
"else\n"
" installPhase=zilchCmakeInstall; checkPhase=ninjaCheckPhase\n"
"fi\n"
"phases=\"zilchPlace checkPhase ${preInstallPhases[*]:-} installPhase ${preFixupPhases[*]:-} fixupPhase installCheckPhase ${preDistPhases[*]:-} distPhase ${postPhases[*]:-}\"\n"
"for curPhase in ${phases[*]}; do runPhase \"$curPhase\"; done\n"))