-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmake.lua
More file actions
96 lines (84 loc) · 2.64 KB
/
xmake.lua
File metadata and controls
96 lines (84 loc) · 2.64 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
set_xmakever("2.9.7")
set_project("compiler")
set_version("0.1.0")
set_allowedplats("windows", "linux")
set_allowedmodes("debug", "release")
set_defaultmode("debug")
option("dev", { default = true })
if has_config("dev") then
if is_mode("debug") and is_plat("linux") then
set_policy("build.sanitizer.address", true)
set_policy("build.sanitizer.leak", true)
set_policy("build.sanitizer.undefined", true)
end
add_defines("COMPILER_IS_DEV")
end
option("link-stdc++exp")
add_links("stdc++exp")
option_end()
if is_plat("windows") then
add_options("link-stdc++exp")
elseif is_plat("linux") then
set_warnings("allextra", "error")
add_requires("ncurses")
end
add_requires("doctest 2.4.11")
add_requires("llvm 18.1.1", { kind = "library" })
if is_plat("windows") then
add_requires("boost", { config = { all = true, runtimes = "MD" } })
elseif is_plat("linux") then
add_requires("boost", { config = { all = true } })
end
add_rules("mode.debug", "mode.release")
set_languages("c++23")
rule("add-llvm")
on_config(function (target)
target:add("packages", "llvm")
if is_plat("windows") then
target:set("runtimes", "MD")
target:add("syslinks", "ntdll", "ws2_32")
target:add("links", "LLVMTargetParser")
elseif is_plat("linux") then
target:add("packages", "ncurses")
end
end)
target("compiler")
set_kind("binary")
add_files("src/*.cpp")
add_includedirs("include")
add_rules("add-llvm")
set_configdir("include/compiler")
add_configfiles("src/config.h.in", { filename = "config.hpp" })
set_rundir("$(projectdir)")
set_prefixdir("compiler")
add_installfiles("std/*|*.cpp", { prefixdir = "include" })
for _, file in ipairs(os.files("std/*.cpp")) do
local name = path.basename(file)
target(name)
set_kind("static")
if is_plat("windows") then
set_toolchains("llvm")
end
add_files("std/" .. name .. ".cpp")
set_targetdir("lib")
set_prefixdir("compiler")
end
before_build(function ()
if not os.exists("bin") then
os.mkdir("$(projectdir)/bin")
end
end)
for _, file in ipairs(os.files("test/*.cpp")) do
local name = path.basename(file)
target("test_" .. name)
set_kind("binary")
set_default(false)
add_packages("doctest", "boost")
add_rules("add-llvm")
add_defines("DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN")
set_rundir("$(projectdir)")
add_includedirs("include")
add_files("test/" .. name .. ".cpp", "src/*.cpp|main.cpp")
add_tests("default")
set_options("dev")
end