forked from RealNeGate/Cuik
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.lua
More file actions
82 lines (70 loc) · 2.57 KB
/
build.lua
File metadata and controls
82 lines (70 loc) · 2.57 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
70
71
72
73
74
75
76
77
78
79
80
81
82
config.use_mimalloc = true
if config.use_mimalloc then
-- Call into Cmake for a shared lib
if config.os == "Windows" then
build.command("cd deps/mimalloc && mkdir out")
build.command("cd deps/mimalloc/out && cmake ../ -DMI_BUILD_STATIC=OFF -DMI_BUILD_OBJECT=OFF -DMI_BUILD_TESTS=OFF | msbuild libmimalloc.sln -p:Configuration=Release")
build.command("copy deps\\mimalloc\\out\\Release\\mimalloc.dll bin\\")
build.command("copy deps\\mimalloc\\out\\Release\\mimalloc-redirect.dll bin\\")
else
print("TODO: mimalloc")
os.exit(1)
end
end
-- dofile will return a boolean to tell us if the TB compile made changes
local changes = build.build_lua("tilde-backend")
local files = {
"lib/", "lib/preproc/", "lib/front/", "lib/targets/",
"lib/back/ir_gen.c", "lib/back/linker.c"
}
local exe_extension = ""
local lib_extension = ""
if config.os == "Windows" then
exe_extension = ".exe"
lib_extension = ".lib"
table.insert(files, "lib/back/microsoft_craziness.c")
table.insert(files, "deps/threads_msvc.c")
else
lib_extension = ".a"
end
local options = "-g -Wall -Werror -Wno-unused-function -Wno-unused-variable "
options = options.."-DCUIK_USE_TB "
options = options.."-D_CRT_SECURE_NO_WARNINGS "
options = options.."-msse4.2 -maes "
options = options.."-I lib "
options = options.."-I include "
options = options.."-I deps "
options = options.."-I tilde-backend/include "
if config.opt then
options = options.."-O2 -DNDEBUG "
end
local outputs, libcuik_changes = build.compile("libCuik.cache", files, options)
changes = changes or libcuik_changes
if changes then
build.lib("bin/libcuik"..lib_extension, "", outputs)
end
-- compile the driver now
local driver, driver_changes = build.compile("Cuik.cache", {
"drivers/main_driver.c",
"drivers/threadpool.c",
"drivers/bindgen_c99.c",
"drivers/bindgen_odin.c"
}, options)
changes = changes or driver_changes
if changes then
local ld_flags = "-g bin/libcuik"..lib_extension.." tilde-backend/tildebackend"..lib_extension
if config.os == "Windows" then
if config.use_mimalloc then
ld_flags = ld_flags.." deps/mimalloc/out/Release/mimalloc.lib -Xlinker /include:mi_version "
end
ld_flags = ld_flags.." -Xlinker /incremental:no -lole32 -lAdvapi32 -lOleAut32 -lDbgHelp"
else
-- libc & threads on *nix
ld_flags = ld_flags.." -lm -ldl -lpthread "
end
-- Link everything together
if changes then
build.link("bin/cuik"..exe_extension, ld_flags, driver)
end
end
return changes