build/build: dry, clean, rebuild list

This commit is contained in:
dzaima 2024-04-20 03:10:13 +03:00
parent a6a088868c
commit 68f0ec749f
2 changed files with 42 additions and 14 deletions

View File

@ -1,8 +1,8 @@
t0g •MonoTime@ t0g •MonoTime@
#!build/obj2/for_build #!build/obj2/for_build
# todo: # todo:
# clean
# forcing bytecode/singeli/replxx directories to whatever's applicable # forcing bytecode/singeli/replxx directories to whatever's applicable
# cache warning messages
Spawn, WaitForOne •Import "fork.bqn" Spawn, WaitForOne •Import "fork.bqn"
Serialize, Deserialize •Import "serialize.bqn" Serialize, Deserialize •Import "serialize.bqn"
@ -20,11 +20,12 @@ opts ← ⟨
0, "j", @, "Number of parallel jobs" 0, "j", @, "Number of parallel jobs"
1, "verbose", 0, "Log more things" 1, "verbose", 0, "Log more things"
1, "rebuild", 0, "Forcibly rebuild everything" 2, "rebuild",, "Forcibly rebuild cbqn/replxx/singeli/linker"
1, "notui", @, "disable live-updating status display" 2, "clean", , "Instead of building, clean cbqn/replxx/singeli/linker"
1, "nogit", 0, "error if something attempts to use git" 1, "dry", 0, "Dry run: don't run/modify/delete anything other than submodules"
1, "notui", @, "Disable live-updating status display"
1, "nogit", 0, "Error if something attempts to use git"
1, "quiet", 0, "Don't output final status line (or any, combined with notui)"@+10 1, "quiet", 0, "Don't output final status line (or any, combined with notui)"@+10
1, "rebuild-singeli", 0, @
0, "CC", @, "The used C compiler" 0, "CC", @, "The used C compiler"
0, "LD", @, "Linker of the final binary; defaults to CC, or CXX if REPLXX=1" 0, "LD", @, "Linker of the final binary; defaults to CC, or CXX if REPLXX=1"
@ -170,10 +171,11 @@ updateSubmodule ← {
rootDir •file.Parent2 •file.path rootDir •file.Parent2 •file.path
AtRoot rootDir•file.At AtRoot rootDir•file.At
allCaches "cbqn", "singeli", "replxx", "linker"
po { # parsed options po { # parsed options
verbose, J, rebuildAll, rebuildSingeli, tui, loud, output, clangd, versionName, verbose, J, clean, rebuild, tui, loud, output, clangd, versionName,
os, arch, native, has, os, arch, native, has,
emcc, wasm, replxx, singeli, staticLib, emcc, wasm, replxx, singeli, staticLib,
usz, ffi, o3, debug, rtverify, heapverify, usz, ffi, o3, debug, rtverify, heapverify,
@ -186,12 +188,22 @@ po ← { # parsed options
clangd GetOpt "clangd" clangd GetOpt "clangd"
DOpt {@,𝕨 GetOpt 𝕩} DOpt {@,𝕨 GetOpt 𝕩}
J {𝕊: vGetOpt "j" v@? •ParseFloat v; •ParseFloat4 ¯1"4" TrySH "nproc"} J {𝕊: vGetOpt "j" v@? •ParseFloat v; •ParseFloat4 ¯1"4" TrySH "nproc"}
rebuildAll GetOpt "rebuild"
rebuildSingeli GetOpt "rebuild-singeli"
tui @¬{𝕊: f@•FFI"i32""isatty"">i32" F 1} GetOpt "notui" tui @¬{𝕊: f@•FFI"i32""isatty"">i32" F 1} GetOpt "notui"
loud ¬GetOpt "quiet" loud ¬GetOpt "quiet"
nogit GetOpt "nogit" nogit GetOpt "nogit"
dry GetOpt "dry"
CacheList {
vs ','SplitLowercase¨ GetOpt 𝕩
{
vs"all"? allCaches;
𝕩 {"Error: Invalid target in ",𝕨," list: ",𝕩}_assert_(0=) vs (¬/) allCaches
vs
}𝕩
}
clean CacheList "clean"
rebuild CacheList "rebuild"
{𝕊: _verboseLog {Log𝕨𝔽𝕩𝕩}} verboseGetOpt "verbose" {𝕊: _verboseLog {Log𝕨𝔽𝕩𝕩}} verboseGetOpt "verbose"
ErrBoth {ab: "Error: '",a,"' and '",b,"' cannot both be enabled"} ErrBoth {ab: "Error: '",a,"' and '",b,"' cannot both be enabled"}
@ -422,11 +434,15 @@ isFileTheSame ← {
} }
# gets/creates a directory of cacheable objects; key is the unique identifier of when it can be reused # gets/creates a directory of cacheable objects; key is the unique identifier of when it can be reused
GetCache { 𝕊 basenamedesckey: madeCaches
GetCache {madeCaches𝕩𝕩} { 𝕊 basenamedesckey:
folderHash Hash key folderHash Hash key
folder allObjDir•file.At basename"-"folderHash folder allObjDir•file.At basename"-"folderHash
MkDir AtRoot folder MkDir AtRoot folder
name basename
! (<name) allCaches
File folder•file.At File folder•file.At
{𝕊: desc": "AtRoot𝕩} _verboseLog folder {𝕊: desc": "AtRoot𝕩} _verboseLog folder
@ -462,13 +478,20 @@ GetCache ← { 𝕊 basename‿desc‿key:
newKs <key newKs <key
newVs <data newVs <data
} }
onExitList {{𝕊: dataPath •FBytes 8,8'c'•bit._cast FinalData@}{𝕊: 0newKs}} onExitList {{𝕊: dataPath •FBytes 8,8'c'•bit._cast FinalData@}{𝕊: (0newKs) ¬po.dry}}
} }
ruleKsruleVs ruleKsruleVs
# dependency resolution & thread management # dependency resolution & thread management
Run { 𝕊: Run { 𝕊:
0po.clean?
{
Log(po.verbosepo.dry) "recursively deleting ", AtRoot 𝕩.folder
SH(¬po.dry) "rm", "-r", "--", AtRoot 𝕩.folder
}¨ ( /˜ {𝕩.name}¨ po.clean˙) madeCaches
•Exit 0
;
ruleDeps {{𝕩.dst}¨ 𝕩.ruleDeps}¨ ruleVs ruleDeps {{𝕩.dst}¨ 𝕩.ruleDeps}¨ ruleVs
ruleSrcs0 ruleKsruleDeps ruleSrcs0 ruleKsruleDeps
! ´ ruleSrcs0<ruleKs ! ´ ruleSrcs0<ruleKs
@ -479,8 +502,9 @@ Run ← { 𝕊:
Require { Require {
v 𝕩ruleVs v 𝕩ruleVs
rebuild po.rebuildAll # rebuild ← po.rebuildAll
{𝕊: rebuild ".singeli"¯8v.disp} po.rebuildSingeli # {𝕊: rebuild↩ ".singeli"≡¯8↑v.disp}⍟⊢ po.rebuildSingeli
rebuild (<v.cache.name)po.rebuild
chi 𝕩ruleSrcs chi 𝕩ruleSrcs
chr Require¨ chi chr Require¨ chi
rebuild ´ chr rebuild ´ chr
@ -550,7 +574,7 @@ Run ← { 𝕊:
t ¯1free free˜ ¯1 t ¯1free free˜ ¯1
i RequestJob@ viruleVs i RequestJob@ viruleVs
t.Request v.CMD@ t.Request "dry"po.dry v.CMD@
work {tt, ii, vv, t0•MonoTime@} work {tt, ii, vv, t0•MonoTime@}
}•_while_{𝕊: ´0<¨ leftfree}¬ stopping }•_while_{𝕊: ´0<¨ leftfree}¬ stopping
@ -771,7 +795,7 @@ outPath ← •wdpath •file.At po.output
SH "cp", AtRoot linkerCache.File "BQN.wasm", outPath •file.At "BQN.wasm" SH "cp", AtRoot linkerCache.File "BQN.wasm", outPath •file.At "BQN.wasm"
; ;
SH "cp", "-f", AtRoot cachedBin, outPath SH "cp", "-f", AtRoot cachedBin, outPath
} success } success ¬po.dry
OnExit@ OnExit@
•Exit ¬success •Exit ¬success
} }

View File

@ -56,6 +56,10 @@ _runSingeli_ ← { runArgs GetDeps _𝕣_ dir runFile:
; ;
"runbqn"dirfileargsdeps: "runbqn"dirfileargsdeps:
args deps _runSingeli_ dir file args deps _runSingeli_ dir file
;
"dry"args:
dir 1args
Good dir, 1, 2, "", "",
; ;
0"unknown command" 0"unknown command"
} }