-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKnitfile
More file actions
69 lines (50 loc) · 1.77 KB
/
Knitfile
File metadata and controls
69 lines (50 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
-- vim: set ft=lua:
local knit = require("knit")
local fix_steps = {"wasm-to-c-fix", "c-to-elf-fix", "link-elfs-fix", "map", "compile"}
tools = {
wasm2c="build/src/sys-driver/wasm-to-c-sys",
cc="build/src/sys-driver/c-to-elf-sys",
ld="build/src/sys-driver/link-elfs-sys",
serialize="build/src/serialize/serialize",
}
local configure_flags = ""
if cli.cmake_build_type then
configure_flags = configure_flags .. "-DCMAKE_BUILD_TYPE=" .. cli.cmake_build_type
end
local llvm_include="build/llvm-project/llvm/lib/clang/19/include/"
rules = b{}
for _, step in pairs(fix_steps) do
local functions = {}
for i=0,255 do
table.insert(functions, "function" .. i .. ".c")
end
wasm = "fix-build/src/fix-driver/" .. step .. ".wasm"
out = "tmp/" .. step
c_files = knit.prefix(functions, out .. "/")
o_files = knit.extrepl(c_files, ".c", ".o")
rules = rules + b{
$ $c_files $out/function-impl.h $out/function.h: $wasm $(tools.wasm2c)[I]
$(tools.wasm2c) $input $out
$ $out/%.o: $out/%.c $out/function-impl.h $out/function.h $(tools.cc)[I]
$(tools.cc) $input $llvm_include $output
$ $out.o: $o_files $(tools.ld)[I]
$(tools.ld) $output $input
}
end
local obj = knit.prefix(knit.suffix(fix_steps, ".o"), "tmp/")
return b{
$ all:V: .fix/refs/compile-encode
$ build/CMakeCache.txt:
cmake -B build -S . $configure_flags -G Ninja
$ build:VB: build/CMakeCache.txt
cmake --build build -j $$(nproc)
$ build/%:B: build
$ fix-build/CMakeCache.txt:
cmake -B fix-build -DBUILD_SYS_DRIVER=OFF -S . $configure_flags -G Ninja
$ fix-build:VB: fix-build/CMakeCache.txt
cmake --build fix-build -j $$(nproc)
$ fix-build/%:B: fix-build
$ .fix/%: $obj $(tools.serialize)
rm -rf .fix
$(tools.serialize) ./ $llvm_include
} + rules