-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathxmake.lua
157 lines (133 loc) · 5.09 KB
/
xmake.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
set_xmakever("2.9.7")
set_project("clice")
set_allowedplats("windows", "linux")
set_allowedmodes("debug", "release")
option("enable_test", {default = true})
option("dev", {default = true})
if has_config("dev") then
set_policy("compatibility.version", "3.0")
if is_plat("windows") then
set_runtimes("MD")
if is_mode("debug") then
print("Clice does not support build in debug mode with pre-compiled llvm binary on windows.\n"
.."See https://github.com/clice-project/clice/issues/42 for more information.")
os.raise()
end
elseif is_plat("linux") and is_mode("debug") then
set_policy("build.sanitizer.address", true)
end
if has_config("enable_test") then
add_requires("gtest[main]")
end
end
add_requires("llvm", "libuv", "toml++")
add_rules("mode.release", "mode.debug")
set_languages("c++23")
add_rules("clice_build_config")
target("clice-core")
set_kind("$(kind)")
add_files("src/**.cpp|Driver/*.cpp")
add_includedirs("include", {public = true})
add_packages("libuv", "toml++", {public = true})
if is_mode("debug") then
add_packages("llvm", {
public = true,
links = {
"LLVMSupport",
"LLVMFrontendOpenMP",
"clangAST",
"clangASTMatchers",
"clangBasic",
"clangDependencyScanning",
"clangDriver",
"clangFormat",
"clangFrontend",
"clangIndex",
"clangLex",
"clangSema",
"clangSerialization",
"clangTooling",
"clangToolingCore",
"clangToolingInclusions",
"clangToolingInclusionsStdlib",
"clangToolingSyntax",
}})
elseif is_mode("release") then
add_packages("llvm", {public = true})
add_ldflags("-Wl,--gc-sections")
end
target("clice")
set_kind("binary")
add_files("src/Driver/clice.cc")
add_deps("clice-core")
on_config(function (target)
target:add("rpathdirs", path.join(target:dep("clice-core"):pkg("llvm"):installdir(), "lib"))
end)
target("integration_tests")
set_default(false)
set_kind("binary")
add_files("src/Driver/integration_tests.cc")
add_deps("clice-core")
-- TODO
-- add_tests("integration_tests")
target("unit_tests")
set_default(false)
set_kind("binary")
add_files("src/Driver/unit_tests.cc", "unittests/**.cpp")
add_includedirs(".", {public = true})
add_deps("clice-core")
add_packages("gtest")
add_tests("default")
on_config(function (target)
target:add("rpathdirs", path.join(target:dep("clice-core"):pkg("llvm"):installdir(), "lib"))
target:set("runargs",
"--test-dir=" .. path.absolute("tests"),
"--resource-dir=" .. path.join(target:dep("clice-core"):pkg("llvm"):installdir(), "lib/clang/20")
)
end)
rule("clice_build_config")
on_load(function (target)
target:add("cxflags", "-fno-rtti", {tools = {"clang", "gcc"}})
target:add("cxflags", "/GR-", {tools = {"clang_cl", "cl"}})
target:set("exceptions", "no-cxx")
if target:is_plat("windows") then
target:add("ldflags", "-fuse-ld=lld-link")
elseif target:is_plat("linux") then
-- gnu ld need to fix link order
target:add("ldflags", "-fuse-ld=lld")
end
end)
package("llvm")
if is_plat("windows") then
if is_mode("release") then
add_urls("https://github.com/clice-project/llvm-binary/releases/download/$(version)/x64-windows-msvc-release.7z")
add_versions("20.0.0", "4ef335845ebb52f8237bda3bcc7246b06085fdf5edc5cc6cf7f3a7c9ef655c09")
else
end
elseif is_plat("linux") then
if is_mode("debug") then
add_urls("https://github.com/clice-project/llvm-binary/releases/download/$(version)/x86_64-linux-gnu-debug.tar.xz")
add_versions("20.0.0", "7dc045424a9667f20845dec058d211476b84300ebcfc8c3a3aabf41bff37cfd9")
elseif is_mode("release") then
add_urls("https://github.com/clice-project/llvm-binary/releases/download/$(version)/x86_64-linux-gnu-release.tar.xz")
add_versions("20.0.0", "30ba7357eb40000f1d13d92242f7d87c3ff623e62205a41d10334d605739af89")
end
end
if is_plat("windows") then
add_configs("runtimes", {description = "Set compiler runtimes.", default = "MD", readonly = true})
elseif is_plat("linux") then
if is_mode("debug") then
add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true})
end
end
if is_plat("windows", "mingw") then
add_syslinks("version", "ntdll")
end
on_install(function (package)
if not package:config("shared") then
package:add("defines", "CLANG_BUILD_STATIC")
end
os.mv("bin", package:installdir())
os.mv("lib", package:installdir())
os.mv("include", package:installdir())
end)