uCBQN/build/src/runner.bqn

69 lines
2.6 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
}
_runImport_ { runArgs Process _𝕣_ dir runFile: # Process returns {deps‿o‿e⇐}, with e⇐@ for no error
t0 •MonoTime@
o@ e@ deps@
{𝕊:
depsoe Process runArgs •Import runFile
}{𝕊: e•CurrentError@} @
t1 •MonoTime@
{
e@? 0, e;
Good dir,t0,t1,o,"",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"dirdstsingeliDirargssrc:
prefix "si_" (`'.')/ •file.Name src
argsFinal args"-oe", "bqn", "-os", "none", "-o" dst "-n" prefix src
Process { 𝕊 res:
deps src< SimplifyPath¨ res.deplog
o (@+10)¨ res.show
e {: @; 𝕩} res.errout
}
argsFinal Process _runImport_ dir singeliDir •file.At "singeli"
;
"runbqn"dirfileargsdeps:
args {depsdeps, o"", e@} _runImport_ dir file
;
"dry"args:
dir 1args
Good dir, 1, 2, "", "",
;
0"unknown command"
}