forked from mirror/tinycc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtinycc.lua
117 lines (89 loc) · 2.67 KB
/
tinycc.lua
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
path_cwd = os.getcwd();
tcc_files = {
"i386-asm.h",
"i386-asm.c",
"i386-gen.h",
"i386-tok.h",
"tcc.h",
"tcc.c",
"libtcc.h",
"libtcc.c",
"tccasm.c",
"tccelf.c",
"tccgen.c",
"tccpe.c",
"tccpp.c",
"tccrun.c",
"tcctok.h",
"x86_64-asm.h",
"x86_64-gen.c",
"x86_64-link.c"
}
tcc_defines = {
"_CRT_SECURE_NO_WARNINGS",
"_CRT_NONSTDC_NO_WARNINGS",
"TCC_TARGET_PE",
"TCC_TARGET_X86_64",
"TCC_LIBTCC1=\"libtcc1-64.a\"",
"TCC_VERSION=\"0.9.27\"",
"ONE_SOURCE=0"
}
tcc_a_files = {
"lib/libtcc1.c",
"lib/alloca86_64.S",
"lib/alloca86_64-bt.S",
"win32/lib/crt1.c",
"win32/lib/crt1w.c",
"win32/lib/wincrt1.c",
"win32/lib/wincrt1w.c",
"win32/lib/dllcrt1.c",
"win32/lib/dllmain.c",
"win32/lib/chkstk.S"
}
project "tcc"
kind "ConsoleApp"
language "C"
files { tcc_files }
defines { tcc_defines }
project "libtcc"
kind "SharedLib"
language "C"
files { tcc_files }
defines {
tcc_defines,
"LIBTCC_AS_DLL"
}
project "libtcc1_64_a"
kind "Utility"
dependson {
"tcc",
"libtcc"
}
files { tcc_a_files }
tcc_exe = "%{cfg.buildtarget.directory}/tcc.exe"
prebuildcommands {
"{COPY} " .. path_cwd .. "/include %{cfg.buildtarget.directory}/include",
"{COPY} " .. path_cwd .. "/win32/include %{cfg.buildtarget.directory}/include",
"{MKDIR} %{cfg.buildtarget.directory}/obj",
"{MKDIR} %{cfg.buildtarget.directory}/lib"
}
filter { "files:**.*" }
buildmessage "Compiling with tcc: %{file.relpath}"
buildcommands {
"%{cfg.buildtarget.directory}/tcc.exe -m64 -c %{file.relpath} -o %{cfg.buildtarget.directory}/obj/%{file.basename}.o",
}
buildoutputs {
"%{cfg.buildtarget.directory}/obj/%{file.basename}.o"
}
filter {}
objs = {}
for _, file in ipairs(tcc_a_files) do
local obj_file = "%{cfg.buildtarget.directory}/obj/" .. path.getbasename(file) .. ".o"
table.insert(objs, obj_file)
end
postbuildcommands {
"%{cfg.buildtarget.directory}/tcc.exe -m64 -ar %{cfg.buildtarget.directory}/lib/libtcc1-64.a " .. table.concat(objs, " ")
}
buildoutputs {
"%{cfg.buildtarget.directory}/lib/libtcc1-64.a"
}