mirror of
https://github.com/Nexoniarz/Finch.git
synced 2026-11-03 16:54:25 +00:00
The compiler carries its runtime and std inside itself; host module for the system it runs on
src/embedded.fch (made by tools/pack.fch, checked by tests/run.sh) holds runtime/finch_rt.c and std/; when they aren't beside the binary they're written to the cache folder once. All the sh/cmd specifics of the driver (quoting, temp dir, mkdir, rm, mv, null device, path separator, cache dir, binary stdio) moved into host.fch / host_windows.fch. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015f73FesGZGYPkmDvUcj6QX
This commit is contained in:
parent
a0c54a1252
commit
837ad45177
12 changed files with 354 additions and 59 deletions
|
|
@ -8,6 +8,7 @@
|
|||
//
|
||||
// C structs by value appear in types as the named type `module "C"`.
|
||||
import ast
|
||||
import host
|
||||
import "clang-c/Index.h"
|
||||
link "clang"
|
||||
|
||||
|
|
@ -101,8 +102,11 @@ fn fixed(ast.Type elem, int count) -> ast.Type {
|
|||
// Ask the system C compiler where it looks for headers, so we find the same stdio.h it would.
|
||||
fn systemIncludeArgs(str cc) -> []str {
|
||||
[]str dirs
|
||||
tmp := "/tmp/finch_cc_dirs.txt"
|
||||
shell(cc + " -E -v -x c /dev/null 2> '" + tmp + "' > /dev/null")
|
||||
tmp := host.tempDir() + "/finch_cc_dirs_" + str(host.pid()) + ".txt"
|
||||
empty := host.tempDir() + "/finch_empty_" + str(host.pid()) + ".c"
|
||||
write_file(empty, "")
|
||||
host.run(cc + " -E -v -x c " + host.quote(empty) + " 2> " + host.quote(tmp) + " > " + host.nullDevice())
|
||||
host.remove(empty)
|
||||
if !file_exists(tmp) {
|
||||
return dirs
|
||||
}
|
||||
|
|
@ -126,7 +130,7 @@ fn systemIncludeArgs(str cc) -> []str {
|
|||
dirs.push("-isystem" + l)
|
||||
}
|
||||
}
|
||||
shell("rm -f '" + tmp + "'")
|
||||
host.remove(tmp)
|
||||
return dirs
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue