Singeli compile commands
This commit is contained in:
parent
0a4925e84f
commit
f3094295dd
3
.gitignore
vendored
3
.gitignore
vendored
@ -42,9 +42,10 @@ cbqn-jit.bqn
|
|||||||
/local/
|
/local/
|
||||||
perf.data*
|
perf.data*
|
||||||
|
|
||||||
# clangd
|
# clangd / compile commands
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
.cache/
|
.cache/
|
||||||
|
.singeli_compile_commands.json
|
||||||
|
|
||||||
# things not used anymore, but still may be present in existing clones
|
# things not used anymore, but still may be present in existing clones
|
||||||
/SingeliClone/
|
/SingeliClone/
|
||||||
|
|||||||
@ -689,10 +689,10 @@ AddRule ← { 𝕊 cache‿cacheKey‿dst‿GetCMD‿disp‿deps:
|
|||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
clangd ← {¬po.clangd? {_add⇐{𝕨𝔽_𝕣𝕩:@} ⋄ Files⇐⊣}; ⟨AtRoot⟩ •Import "clangd.bqn"}
|
clangd ← {¬po.clangd? {_addC⇐{𝕨𝔽_𝕣𝕩:@} ⋄ AddSingeli⇐{𝕊:@} ⋄ SingeliInit⇐⊢ ⋄ CFiles⇐⊣}; ⟨AtRoot⟩ •Import "clangd.bqn"}
|
||||||
|
|
||||||
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
|
||||||
GetArgs clangd._add src
|
GetArgs clangd._addC src
|
||||||
dst ← cache.File id∾".o"
|
dst ← cache.File id∾".o"
|
||||||
GetCMD ← { 𝕊:
|
GetCMD ← { 𝕊:
|
||||||
Init @
|
Init @
|
||||||
@ -703,6 +703,7 @@ MakeCCInv ← { 𝕊 GetArgs‿Init‿cache‿id‿src‿customDeps: # src shoul
|
|||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
args clangd.AddSingeli src
|
||||||
dst ← cache.File id∾".c"
|
dst ← cache.File id∾".c"
|
||||||
GetCMD ← { 𝕊:
|
GetCMD ← { 𝕊:
|
||||||
Init @
|
Init @
|
||||||
@ -733,7 +734,7 @@ cachedBin‿linkerCache ← {
|
|||||||
⟨"src/jit/", "nvm.c"⟩
|
⟨"src/jit/", "nvm.c"⟩
|
||||||
⟨"src/utils/", "ryu.c", "utf.c", "hash.c", "file.c", "mut.c", "each.c", "bits.c"⟩
|
⟨"src/utils/", "ryu.c", "utf.c", "hash.c", "file.c", "mut.c", "each.c", "bits.c"⟩
|
||||||
⟩
|
⟩
|
||||||
cbqnSrc ↩ cbqnSrc clangd.Files "src"
|
cbqnSrc ↩ cbqnSrc clangd.CFiles "src"
|
||||||
singeliMap ← 1↓¨ ({⊑ ({"X86_64":'x'; "AARCH64":'a'; "RV64":'g'; "NONE":'g'} po.arch) ∊ 𝕩}¨ ⊑¨)⊸/ ⟨
|
singeliMap ← 1↓¨ ({⊑ ({"X86_64":'x'; "AARCH64":'a'; "RV64":'g'; "NONE":'g'} po.arch) ∊ 𝕩}¨ ⊑¨)⊸/ ⟨
|
||||||
"xa."‿"src/builtins/arithm.c"‿"monarith", "xa."‿"src/builtins/compare.c"‿"equal",
|
"xa."‿"src/builtins/arithm.c"‿"monarith", "xa."‿"src/builtins/compare.c"‿"equal",
|
||||||
"xa."‿"src/builtins/arithd.c"‿"dyarith", "xa."‿"src/builtins/cmp.c"‿"cmp",
|
"xa."‿"src/builtins/arithd.c"‿"dyarith", "xa."‿"src/builtins/cmp.c"‿"cmp",
|
||||||
@ -781,6 +782,7 @@ cachedBin‿linkerCache ← {
|
|||||||
(⊑"slow-pdep"<⊸∊ po.has) / ⟨"-c", "SLOW_PDEP=1"⟩
|
(⊑"slow-pdep"<⊸∊ po.has) / ⟨"-c", "SLOW_PDEP=1"⟩
|
||||||
{po.native? ⟨⟩; "-a" ⋈ 1↓∾ ','⊸∾¨ po.singeliArch}
|
{po.native? ⟨⟩; "-a" ⋈ 1↓∾ ','⊸∾¨ po.singeliArch}
|
||||||
⟩
|
⟩
|
||||||
|
clangd.SingeliInit ⟨po.singeliDir, po.arch⟩
|
||||||
{𝕊: "Singeli args: "∾•Repr singeliArgs} _verboseLog @
|
{𝕊: "Singeli args: "∾•Repr singeliArgs} _verboseLog @
|
||||||
{𝕊: "Singeli-determined C arch: "∾•Repr po.singeliCFlags; @} _verboseLog @
|
{𝕊: "Singeli-determined C arch: "∾•Repr po.singeliCFlags; @} _verboseLog @
|
||||||
singeliObjs ↩ {MakeSingeliInv ⟨singeliArgs, {𝕊:UpdateSubmodule po.singeliDir}, singeliCache, 𝕩, "src/singeli/src/"•file.At 𝕩∾".singeli", (𝕩≡"dyarith")/⟨gaRule⟩⟩}¨ 1⊑¨singeliMap
|
singeliObjs ↩ {MakeSingeliInv ⟨singeliArgs, {𝕊:UpdateSubmodule po.singeliDir}, singeliCache, 𝕩, "src/singeli/src/"•file.At 𝕩∾".singeli", (𝕩≡"dyarith")/⟨gaRule⟩⟩}¨ 1⊑¨singeliMap
|
||||||
|
|||||||
@ -6,21 +6,39 @@ Esc←{
|
|||||||
𝕩 ↩ i ⊏⟜out⌾((i<≠out)⊸/) 𝕩 # Replace
|
𝕩 ↩ i ⊏⟜out⌾((i<≠out)⊸/) 𝕩 # Replace
|
||||||
∾(i<≠in) /⟜"\"⊸∾¨ 𝕩 # Insert \
|
∾(i<≠in) /⟜"\"⊸∾¨ 𝕩 # Insert \
|
||||||
}
|
}
|
||||||
n←@+10
|
lf←@+10
|
||||||
JStr ← {∾⟨"""",Esc 𝕩,""""⟩}
|
JStr ← {∾⟨"""",Esc 𝕩,""""⟩}
|
||||||
JArr ← {'['∾']'∾˜2↓∾𝕨⊸∾¨ 𝕩}
|
JArr ← {'['∾']'∾˜ (≠𝕨) ↓ ∾ 𝕨⊸∾¨ 𝕩}
|
||||||
JObj ← {∾⟨'{',n,¯2↓∾(JStr¨𝕨) {∾⟨" ",𝕨,": ",𝕩,',',n⟩}¨ 𝕩, n,'}'⟩}
|
JObj ← {∾⟨'{',lf,¯2↓∾(JStr¨𝕨) {∾⟨" ",𝕨,": ",𝕩,',',lf⟩}¨ 𝕩, lf,'}'⟩}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
precompFiles ← ⥊"bytecodeLocal"‿"bytecodeSubmodule" {∾⟨"../build/",𝕨,"/gen/",𝕩⟩}⌜ "compiles"‿"explain"‿"formatter"‿"runtime0"‿"runtime1"‿"runtime1x"
|
precompFiles ← ⥊"bytecodeLocal"‿"bytecodeSubmodule" {∾⟨"../build/",𝕨,"/gen/",𝕩⟩}⌜ "compiles"‿"explain"‿"formatter"‿"runtime0"‿"runtime1"‿"runtime1x"
|
||||||
Files ⇐ {
|
RecursiveFiles ⇐ {
|
||||||
res ← ⟨⟩
|
res ← ⟨⟩
|
||||||
{'d'=•file.Type AtRoot 𝕩? 𝕊¨ 𝕩⊸•file.At¨ •file.List AtRoot 𝕩; res∾↩ <𝕩} 𝕩
|
{'d'=•file.Type AtRoot 𝕩? 𝕊¨ 𝕩⊸•file.At¨ •file.List AtRoot 𝕩; res∾↩ <𝕩} 𝕩
|
||||||
{⊑(<¯2↑𝕩)∊".c"‿".h"}¨⊸/ res
|
res
|
||||||
|
}
|
||||||
|
|
||||||
|
CFiles ⇐ {
|
||||||
|
res ← RecursiveFiles 𝕩
|
||||||
|
res {⊑(<¯2↑𝕩)∊".c"‿".h"}¨⊸/↩
|
||||||
res ∾ 𝕩⊸•file.At¨ precompFiles
|
res ∾ 𝕩⊸•file.At¨ precompFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cObjects ← ⟨⟩
|
||||||
|
_addC ⇐ {cObjects∾↩ <⟨𝕩, (𝔽@)∾<𝕩⟩}
|
||||||
|
|
||||||
|
singeliState ← @
|
||||||
|
singeliObjects ← ⟨⟩
|
||||||
|
AddSingeli ⇐ {
|
||||||
|
singeliObjects∾↩ <𝕨‿𝕩
|
||||||
|
}
|
||||||
|
SingeliInit ⇐ {
|
||||||
|
singeliState ↩ 𝕩
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ModifyCBQNFlags ← {
|
ModifyCBQNFlags ← {
|
||||||
filenames ← 4↓¨ ⊑¨ 𝕩
|
filenames ← 4↓¨ ⊑¨ 𝕩
|
||||||
flagK←⟨⟩
|
flagK←⟨⟩
|
||||||
@ -87,24 +105,35 @@ ModifyCBQNFlags ← {
|
|||||||
𝕩 {n‿f 𝕊 f2: ⟨n, f∾⟨"-Wno-undefined-internal", "-DCLANGD"⟩∾f2⟩}¨ (gfk⊐•file.At¨ filenames)⊏gfv ∾ <⟨⟩
|
𝕩 {n‿f 𝕊 f2: ⟨n, f∾⟨"-Wno-undefined-internal", "-DCLANGD"⟩∾f2⟩}¨ (gfk⊐•file.At¨ filenames)⊏gfv ∾ <⟨⟩
|
||||||
}
|
}
|
||||||
|
|
||||||
objects ← ⟨⟩
|
|
||||||
Finish ⇐ { 𝕊 write:
|
Finish ⇐ { 𝕊 write:
|
||||||
objects ModifyCBQNFlags⌾(({"src/"≡4↑⊑𝕩}¨ objects)⊸/)↩
|
_doWrite ← {
|
||||||
FileObj ← { name‿flags:
|
𝕩 •FChars⍟write 𝕗
|
||||||
"file"‿"directory"‿"arguments" JObj ⟨JStr name, JStr AtRoot "", ", " JArr JStr¨ flags⟩
|
•Out ∾⟨{write? "Wrote "; "Would write "}, 𝕨, " to ", •file.At 𝕩⟩
|
||||||
}
|
}
|
||||||
res ← (","∾n) JArr FileObj¨ objects
|
TLArr ← (","∾lf)⊸JArr
|
||||||
|
|
||||||
{
|
{
|
||||||
•Out {write? "Removing"; "Would remove"} ∾ " old "∾𝕩
|
cObjects ModifyCBQNFlags⌾(({"src/"≡4↑⊑𝕩}¨ cObjects)⊸/)↩
|
||||||
•file.Remove⍟write 𝕩
|
FileObj ← { name‿flags:
|
||||||
}⍟•file.Exists AtRoot "compile_commands.json"
|
"file"‿"directory"‿"arguments" JObj ⟨JStr name, JStr AtRoot "", ", " JArr JStr¨ flags⟩
|
||||||
resPath ← AtRoot "build/compile_commands.json"
|
}
|
||||||
{
|
res ← TLArr FileObj¨ cObjects
|
||||||
write?
|
{
|
||||||
resPath •FChars res
|
•Out {write? "Removing"; "Would remove"} ∾ " old "∾𝕩
|
||||||
•Out "Wrote clangd compile commands to "∾•file.At resPath
|
•file.Remove⍟write 𝕩
|
||||||
;
|
}⍟•file.Exists AtRoot "compile_commands.json"
|
||||||
•Out "Would write clangd compile commands to "∾•file.At resPath
|
|
||||||
|
|
||||||
|
"clangd compile commands" res _doWrite AtRoot "build/compile_commands.json"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_add ⇐ {objects∾↩ <⟨𝕩, (𝔽@)∾<𝕩⟩}
|
{
|
||||||
|
singeliState≡@? @;
|
||||||
|
dir‿arch ← singeliState
|
||||||
|
cmd0 ← ⟨"-a", arch, "-l", "="∾AtRoot dir •file.At "include"⟩
|
||||||
|
res ← TLArr { cmd‿name:
|
||||||
|
"file"‿"arguments" JObj ⟨JStr AtRoot name, ", " JArr JStr¨ cmd0 ∾ cmd⟩
|
||||||
|
}¨ singeliObjects
|
||||||
|
"Singeli compile commands" res _doWrite AtRoot "build/.singeli_compile_commands.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user