uCBQN/build/src/runner.bqn
2024-06-04 15:51:55 +03:00

65 lines
2.4 KiB
BQN
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

chdir @•FFI"i32""chdir"">*u8:c8"
Split {𝕩˜(-˜+`׬)𝕩=𝕨}
SimplifyPath {
1'/'¨ {(××) ` +` ¬- ".."¨𝕩}/ "."¨/ '/'Split𝕩
}
Good { 𝕊 dirt0t1oedeps:
1, oe, t1-t0, deps ¨ (•file.Modified dir•file.At)¨ deps
}
_runSingeli_ { runArgs GetDeps _𝕣_ dir runFile:
t0 •MonoTime@
e@ deps@
{𝕊:
runArgs •Import runFile
deps GetDeps@
}{𝕊: e•CurrentError@} @
t1 •MonoTime@
{
e@? 0, e;
Good dir,t0,t1,"","",deps
}
}
{
"sh"dircmddepf:
t0 •MonoTime@
Chdir @˜ •ToUTF8 dir
coe •SH{𝕊: 'e',"","Failed to spawn '", cmd, "': ", •CurrentError@, {"c++"cmd? "; install a C++ compiler as 'c++', or add an argument of CXX=c++-compiler"; ""}} cmd
t1 •MonoTime@
{
0: @depf?
Good dir,t0,t1,o,e,;
0:
deps •FLines depf
deps {𝕩/˜1»`'\'=¯1¨𝕩} # remove all but the initial rule
deps {𝕩˜1+𝕩':'} # remove rule name
deps ¯1¨(¯1) # remove trailing backslashes
deps ({𝕩/˜¬`𝕩=' '})2¨ # trim whitespace from both sides
deps (' 'Split¨) # split each on spaces
deps {¬´"/build/obj2/"𝕩}¨/ # remove autogenerated dependencies, those are handled manually
deps SimplifyPath¨ # remove "."s & ".."s
deps {dir<𝕩? dir(dir)𝕩? (dir)𝕩; 𝕩}¨ # relativize
Good dir,t0,t1,o,e,deps;
# c≠0:
0, oe
} c
;
"staticlib"dstcmd:
•file.Remove•file.Exists dst
𝕊 cmd
;
"singeli"dirdstsingeliDirargssrcdep:
prefix "si_" (`'.')/ •file.Name src
argsFinal args"-d" dep "-o" dst "-n" prefix src
argsFinal {𝕊: src< SimplifyPath¨ singeliDir•file.At¨ •FLines dep}_runSingeli_ dir singeliDir •file.At "singeli"
;
"runbqn"dirfileargsdeps:
args deps _runSingeli_ dir file
;
"dry"args:
dir 1args
Good dir, 1, 2, "", "",
;
0"unknown command"
}