build.bqn: proper rule object
This commit is contained in:
parent
6baa96c1e3
commit
f637fa7746
@ -315,42 +315,36 @@ updateSubmodule ← {
|
|||||||
|
|
||||||
# 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 ← { 𝕊 basename‿desc‿key:
|
GetCache ← { 𝕊 basename‿desc‿key:
|
||||||
hash ⇐ Hash key
|
folderHash ⇐ Hash key
|
||||||
folder ⇐ allObjDir•file.At basename∾"-"∾hash
|
folder ⇐ allObjDir•file.At basename∾"-"∾folderHash
|
||||||
MkDir AtRoot folder
|
MkDir AtRoot folder
|
||||||
|
|
||||||
File ⇐ folder⊸•file.At
|
File ⇐ folder⊸•file.At
|
||||||
{𝕊: desc∾": "∾AtRoot𝕩} _verboseLog folder
|
{𝕊: desc∾": "∾AtRoot𝕩} _verboseLog folder
|
||||||
|
|
||||||
dataPath ← AtRoot File "data"
|
dataPath ← AtRoot File "data"
|
||||||
prevKs‿prevVs ← •file.Exists◶⟨⟨⟩‿⟨⟩, {Deserialize ⟨8‿'c',8⟩•bit._cast •FBytes 𝕩}⟩ dataPath
|
dataVersion ← 0
|
||||||
|
prevKs‿prevVs ← {a‿b: a≡dataVersion? b; ⟨⟩‿⟨⟩} •file.Exists◶⟨@, {Deserialize ⟨8‿'c',8⟩•bit._cast •FBytes 𝕩}⟩ dataPath
|
||||||
|
|
||||||
IsUpToDate ⇐ { 𝕊:
|
IsUpToDate ⇐ { 𝕊:
|
||||||
i ← ⊑prevKs⊐<𝕩
|
i ← ⊑prevKs⊐<𝕩.cacheKey
|
||||||
i<≠prevKs?
|
i<≠prevKs?
|
||||||
{@:0; ∧´ AtRoot⊸IsFileTheSame´¨𝕩} i⊑prevVs;
|
{@:0; ∧´ AtRoot⊸IsFileTheSame´¨𝕩} i⊑prevVs;
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
newKs‿newVs ← ⟨⟩‿⟨⟩
|
newKs‿newVs ← ⟨⟩‿⟨⟩
|
||||||
Update ⇐ {key𝕊data: newKs∾↩ <key ⋄ newVs∾↩ <data} # data≡@ means failed to build
|
finalNewData ← @
|
||||||
onExitList∾↩ {{ 𝕊:
|
FinalData ⇐ { 𝕊:
|
||||||
|
finalNewData≢@?finalNewData;
|
||||||
jKs ← newKs∾prevKs
|
jKs ← newKs∾prevKs
|
||||||
jVs ← newVs∾prevVs
|
jVs ← newVs∾prevVs
|
||||||
dataPath •FBytes ⟨8,8‿'c'⟩•bit._cast Serialize (<∊jKs) /¨ jKs‿jVs
|
finalNewData ↩ Serialize dataVersion⋈ (<∊jKs) /¨ jKs‿jVs
|
||||||
}⍟{𝕊: 0≠≠newKs}}
|
}
|
||||||
|
Update ⇐ {key𝕊data: !finalNewData≡@ ⋄ newKs∾↩ <key ⋄ newVs∾↩ <data} # data≡@ means failed to build
|
||||||
|
onExitList∾↩ {{𝕊: dataPath •FBytes ⟨8,8‿'c'⟩•bit._cast FinalData@}⍟{𝕊: 0≠≠newKs}}
|
||||||
}
|
}
|
||||||
|
|
||||||
ruleKs‿ruleVs ← ⟨⟩‿⟨⟩
|
ruleKs‿ruleVs ← ⟨⟩‿⟨⟩
|
||||||
AddRule ← { 𝕊 cache‿cacheKey‿dst‿GetCMD‿disp‿customDeps:
|
|
||||||
ruleKs∾↩ <dst
|
|
||||||
ruleVs∾↩ {
|
|
||||||
cache ⇐ cache
|
|
||||||
cacheKey ⇐ cacheKey
|
|
||||||
disp ⇐ disp
|
|
||||||
CMD ⇐ GetCMD
|
|
||||||
ruleDeps ⇐ customDeps
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# dependency resolution & thread management
|
# dependency resolution & thread management
|
||||||
Run ← { 𝕊:
|
Run ← { 𝕊:
|
||||||
@ -370,7 +364,7 @@ Run ← { 𝕊:
|
|||||||
chr ← Require¨ chi
|
chr ← Require¨ chi
|
||||||
rebuild∨↩ ∨´ chr
|
rebuild∨↩ ∨´ chr
|
||||||
# rebuild∨↩ ¬•file.Exists AtRoot 𝕩⊑ruleKs # not really needed unless someone deletes a specific file without deleting the data file
|
# rebuild∨↩ ¬•file.Exists AtRoot 𝕩⊑ruleKs # not really needed unless someone deletes a specific file without deleting the data file
|
||||||
rebuild∨↩ ¬v.cache.IsUpToDate v.cacheKey
|
rebuild∨↩ ¬v.cache.IsUpToDate v
|
||||||
{
|
{
|
||||||
ruleN (+´chr)⊸+⌾(𝕩⊸⊑)↩
|
ruleN (+´chr)⊸+⌾(𝕩⊸⊑)↩
|
||||||
ruleP ∾⟜𝕩¨⌾((chr/chi)⊸⊏)↩
|
ruleP ∾⟜𝕩¨⌾((chr/chi)⊸⊏)↩
|
||||||
@ -471,33 +465,45 @@ Run ← { 𝕊:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AddRule ← { 𝕊 cache‿cacheKey‿dst‿GetCMD‿disp‿deps:
|
||||||
|
ruleKs∾↩ <dst
|
||||||
|
res ← {
|
||||||
|
dst ⇐ dst
|
||||||
|
cache ⇐ cache
|
||||||
|
cacheKey ⇐ cacheKey
|
||||||
|
disp ⇐ disp
|
||||||
|
CMD ⇐ GetCMD
|
||||||
|
ruleDeps ⇐ {𝕩.dst}¨ deps
|
||||||
|
}
|
||||||
|
ruleVs∾↩ res
|
||||||
|
res
|
||||||
|
}
|
||||||
|
|
||||||
MakeCCInv ← { 𝕊 GetArgs‿Init‿cache‿id‿src‿customDeps: # src should be CBQN-base-dir-relative, so that cache doesn't store full paths
|
MakeCCInv ← { 𝕊 GetArgs‿Init‿cache‿id‿src‿customDeps: # src should be CBQN-base-dir-relative, so that cache doesn't store full paths
|
||||||
key ⇐ id
|
dst ← cache.File id∾".o"
|
||||||
dst ⇐ cache.File key∾".o"
|
|
||||||
GetCMD ← { 𝕊:
|
GetCMD ← { 𝕊:
|
||||||
Init @
|
Init @
|
||||||
dep ← AtRoot cache.File id∾".d"
|
dep ← AtRoot cache.File id∾".d"
|
||||||
⟨"sh", rootDir, (GetArgs@)∾⟨"-MT", "o", "-MMD", "-MF", dep, "-o", AtRoot dst, "-c", src⟩, dep⟩
|
⟨"sh", rootDir, (GetArgs@)∾⟨"-MT", "o", "-MMD", "-MF", dep, "-o", AtRoot dst, "-c", src⟩, dep⟩
|
||||||
}
|
}
|
||||||
AddRule ⟨cache, key, dst, GetCMD, •file.Name src, customDeps⟩
|
AddRule ⟨cache, id, dst, GetCMD, •file.Name src, customDeps⟩
|
||||||
}
|
}
|
||||||
|
|
||||||
MakeSingeliInv ← { 𝕊 args‿Init‿cache‿id‿src‿customDeps: # src should be CBQN-base-dir-relative, so that cache doesn't store full paths
|
MakeSingeliInv ← { 𝕊 args‿Init‿cache‿id‿src‿customDeps: # src should be CBQN-base-dir-relative, so that cache doesn't store full paths
|
||||||
key ⇐ id
|
dst ← cache.File id∾".c"
|
||||||
dst ⇐ cache.File key∾".c"
|
|
||||||
GetCMD ← { 𝕊:
|
GetCMD ← { 𝕊:
|
||||||
Init @
|
Init @
|
||||||
dep ← AtRoot cache.File id∾".d"
|
dep ← AtRoot cache.File id∾".d"
|
||||||
⟨"singeli", rootDir, AtRoot dst, AtRoot po.singeliDir, args, AtRoot src, dep⟩
|
⟨"singeli", rootDir, AtRoot dst, AtRoot po.singeliDir, args, AtRoot src, dep⟩
|
||||||
}
|
}
|
||||||
AddRule ⟨cache, key, dst, GetCMD, •file.Name src, customDeps⟩
|
AddRule ⟨cache, id, dst, GetCMD, •file.Name src, customDeps⟩
|
||||||
}
|
}
|
||||||
|
|
||||||
MakeLinkerInv ← { 𝕊 GetArgs‿cache‿name‿srcs:
|
MakeLinkerInv ← { 𝕊 GetArgs‿cache‿name‿srcs:
|
||||||
dst ⇐ cache.File name
|
dst ← cache.File name
|
||||||
GetCMD ← { 𝕊:
|
GetCMD ← { 𝕊:
|
||||||
args ← GetArgs@
|
args ← GetArgs@
|
||||||
⟨"sh", rootDir, ⟨⊑args, "-o", dst⟩∾srcs∾1↓args, @⟩
|
⟨"sh", rootDir, ⟨⊑args, "-o", dst⟩∾({𝕩.dst}¨ srcs)∾1↓args, @⟩
|
||||||
}
|
}
|
||||||
AddRule ⟨cache, name, dst, GetCMD, "link", srcs⟩
|
AddRule ⟨cache, name, dst, GetCMD, "link", srcs⟩
|
||||||
}
|
}
|
||||||
@ -530,7 +536,7 @@ cachedBin‿linkerCache ← {
|
|||||||
replxxCache ← GetCache ⟨"replxx", "REPLXX object file location", po.REPLXXc@⟩
|
replxxCache ← GetCache ⟨"replxx", "REPLXX object file location", po.REPLXXc@⟩
|
||||||
|
|
||||||
replxxSrc ← (po.replxxDir•file.At"src")⊸•file.At¨⟨"ConvertUTF.cpp", "wcwidth.cpp", "conversion.cxx", "escape.cxx", "history.cxx", "prompt.cxx", "replxx.cxx", "replxx_impl.cxx", "terminal.cxx", "util.cxx", "windows.cxx"⟩
|
replxxSrc ← (po.replxxDir•file.At"src")⊸•file.At¨⟨"ConvertUTF.cpp", "wcwidth.cpp", "conversion.cxx", "escape.cxx", "history.cxx", "prompt.cxx", "replxx.cxx", "replxx_impl.cxx", "terminal.cxx", "util.cxx", "windows.cxx"⟩
|
||||||
objs∾↩ {𝕩.dst}¨ (Shorten replxxSrc) {MakeCCInv ⟨po.REPLXXc, ⊢, replxxCache, 𝕨, 𝕩, ⟨⟩⟩}¨ replxxSrc
|
objs∾↩ (Shorten replxxSrc) {MakeCCInv ⟨po.REPLXXc, ⊢, replxxCache, 𝕨, 𝕩, ⟨⟩⟩}¨ replxxSrc
|
||||||
|
|
||||||
replxxCache
|
replxxCache
|
||||||
}
|
}
|
||||||
@ -544,7 +550,7 @@ cachedBin‿linkerCache ← {
|
|||||||
ga ← "src/singeli/src/genArithTables.bqn"
|
ga ← "src/singeli/src/genArithTables.bqn"
|
||||||
gaDefs ← singeliCache.File "arDefs.singeli"
|
gaDefs ← singeliCache.File "arDefs.singeli"
|
||||||
gaTables ← singeliCache.File "arTables.c"
|
gaTables ← singeliCache.File "arTables.c"
|
||||||
AddRule ⟨
|
gaRule ← AddRule ⟨
|
||||||
singeliCache, "genArithTables",
|
singeliCache, "genArithTables",
|
||||||
gaDefs, # am cheating and only using arDefs.singeli as destination; ¯\_(ツ)_/¯
|
gaDefs, # am cheating and only using arDefs.singeli as destination; ¯\_(ツ)_/¯
|
||||||
{𝕊: ⟨"runbqn", rootdir, AtRoot ga, AtRoot¨ gaDefs‿gaTables, ⟨ga⟩⟩},
|
{𝕊: ⟨"runbqn", rootdir, AtRoot ga, AtRoot¨ gaDefs‿gaTables, ⟨ga⟩⟩},
|
||||||
@ -555,31 +561,26 @@ cachedBin‿linkerCache ← {
|
|||||||
po.native? ⟨⟩;
|
po.native? ⟨⟩;
|
||||||
"-a" ⋈ {"x86-64":"X86_64"; "aarch64":"AARCH64"} po.arch
|
"-a" ⋈ {"x86-64":"X86_64"; "aarch64":"AARCH64"} po.arch
|
||||||
}
|
}
|
||||||
singeliObjs ↩ {𝕩.dst}¨ {MakeSingeliInv ⟨singeliArgs, {𝕊:UpdateSubmodule po.singeliDir}, singeliCache, 𝕩, "src/singeli/src/"•file.At 𝕩∾".singeli", (𝕩≡"dyarith")/⟨gaDefs⟩⟩}¨ 1⊑¨singeliMap
|
singeliObjs ↩ {MakeSingeliInv ⟨singeliArgs, {𝕊:UpdateSubmodule po.singeliDir}, singeliCache, 𝕩, "src/singeli/src/"•file.At 𝕩∾".singeli", (𝕩≡"dyarith")/⟨gaRule⟩⟩}¨ 1⊑¨singeliMap
|
||||||
|
|
||||||
singeliCache
|
singeliCache
|
||||||
}
|
}
|
||||||
|
|
||||||
cbqnCache ← {
|
cbqnCache ← {
|
||||||
cbqnCache ← GetCache ⟨"cbqn", "CBQN object file location", ⟨po.CBQNc@, {po.singeli? singeliCache.hash; @}⟩⟩
|
cbqnCache ← GetCache ⟨"cbqn", "CBQN object file location", ⟨po.CBQNc@, {po.singeli? singeliCache.folderHash; @}⟩⟩
|
||||||
ruleDeps ← {
|
ruleDeps ← {
|
||||||
¬po.singeli? ⟨⟩¨ cbqnSrc;
|
¬po.singeli? ⟨⟩¨ cbqnSrc;
|
||||||
((≠cbqnSrc) ∾˜ cbqnSrc⊐⊑¨singeliMap) ⊔ singeliObjs
|
((≠cbqnSrc) ∾˜ cbqnSrc⊐⊑¨singeliMap) ⊔ singeliObjs
|
||||||
}
|
}
|
||||||
|
|
||||||
singeliArgs ← {po.singeli? ⟨"-DSINGELI_DIR="∾•file.Name singeliCache.folder⟩; ⟨⟩}
|
singeliArgs ← {po.singeli? ⟨"-DSINGELI_DIR="∾•file.Name singeliCache.folder⟩; ⟨⟩}
|
||||||
objs∾↩ {𝕩.dst}¨ {a‿b‿c: MakeCCInv ⟨po.CBQNc∾singeliArgs˙, {𝕊:UpdateSubmodule po.bytecodeDir ⋄ UpdateSubmodule po.replxxDir}, cbqnCache, a, b, c⟩}¨ <˘⍉[Shorten cbqnSrc, cbqnSrc, ruleDeps] # updates replxx because needs replxx.h
|
objs∾↩ {a‿b‿c: MakeCCInv ⟨po.CBQNc∾singeliArgs˙, {𝕊:UpdateSubmodule po.bytecodeDir ⋄ UpdateSubmodule po.replxxDir}, cbqnCache, a, b, c⟩}¨ <˘⍉[Shorten cbqnSrc, cbqnSrc, ruleDeps] # updates replxx because needs replxx.h
|
||||||
|
|
||||||
cbqnCache
|
cbqnCache
|
||||||
}
|
}
|
||||||
|
|
||||||
linkerCache ← GetCache ⟨"linker", "linker cached result location", ⟨
|
linkerDeps ← @⊸≢¨⊸/ ⟨cbqnCache, replxxCache, singeliCache⟩
|
||||||
po.Linker@,
|
linkerCache ← GetCache ⟨"linker", "linker cached result location", ⟨po.Linker@, {𝕩.folderHash}¨ linkerDeps⟩⟩
|
||||||
cbqnCache.hash,
|
|
||||||
{po.replxx? replxxCache.hash; @}
|
|
||||||
{po.singeli? singeliCache.hash; @}
|
|
||||||
⟩⟩
|
|
||||||
|
|
||||||
{
|
{
|
||||||
po.versionName≡@? @;
|
po.versionName≡@? @;
|
||||||
srcFile ← linkerCache.File "versionInfo.c"
|
srcFile ← linkerCache.File "versionInfo.c"
|
||||||
@ -592,7 +593,7 @@ cachedBin‿linkerCache ← {
|
|||||||
•file.Exists AtRoot srcFile? src≡•FChars AtRoot srcFile? @; # don't update
|
•file.Exists AtRoot srcFile? src≡•FChars AtRoot srcFile? @; # don't update
|
||||||
(AtRoot srcFile) •FChars src
|
(AtRoot srcFile) •FChars src
|
||||||
}
|
}
|
||||||
objs∾↩ ⋈(MakeCCInv ⟨po.CBQNc, ⊢, linkerCache, "versionInfo", srcFile, ⟨⟩⟩).dst
|
objs∾↩ ⋈ MakeCCInv ⟨po.CBQNc, ⊢, linkerCache, "versionInfo", srcFile, ⟨⟩⟩
|
||||||
}
|
}
|
||||||
|
|
||||||
res ← MakeLinkerInv ⟨po.Linker, linkerCache, {po.emcc? "BQN.js"; "windows"≡po.os? "res.exe"; "res"}, objs⟩
|
res ← MakeLinkerInv ⟨po.Linker, linkerCache, {po.emcc? "BQN.js"; "windows"≡po.os? "res.exe"; "res"}, objs⟩
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user