-
-
Notifications
You must be signed in to change notification settings - Fork 49
/
xmake.lua
141 lines (112 loc) · 3.19 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
-- project
set_project("ltui")
-- version
set_version("1.1", {build = "%Y%m%d%H%M"})
-- set xmake min version
set_xmakever("2.2.5")
-- set warning all as error
set_warnings("all", "error")
-- set language: c99, c++11
set_languages("c99", "cxx11")
-- disable some compiler errors
add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing", "-Wno-error=nullability-completeness")
-- add defines
add_defines("_GNU_SOURCE=1", "_FILE_OFFSET_BITS=64", "_LARGEFILE_SOURCE")
-- set the symbols visibility: hidden
set_symbols("hidden")
-- strip all symbols
set_strip("all")
-- fomit the frame pointer
add_cxflags("-fomit-frame-pointer")
-- for the windows platform (msvc)
if is_plat("windows") then
add_cxflags("-MT")
add_defines("_CRT_SECURE_NO_WARNINGS")
add_shflags("-nodefaultlib:msvcrt.lib")
add_links("kernel32", "user32", "gdi32", "advapi32")
end
-- option: luajit
option("luajit")
set_default(false)
set_showmenu(true)
set_category("option")
set_description("Enable the luajit runtime engine.")
option_end()
-- add requires
if has_config("luajit") then
add_requires("luajit")
else
add_requires("lua")
end
if not is_plat("windows") then
add_requires("ncurses", {configs = {cflags = "-fPIC"}})
end
-- add target
target("test")
-- only for test
set_kind("phony")
-- default: disable
set_default(false)
-- we need build ltui first
add_deps("ltui")
-- add packages to bind path environments
if has_config("luajit") then
add_packages("luajit")
else
add_packages("lua")
end
-- run tests
on_run(function (target)
-- imports
import("core.base.option")
import("lib.detect.find_tool")
-- do run
local lua = has_config("luajit") and find_tool("luajit") or find_tool("lua")
if lua then
os.cd(os.projectdir())
local testname = table.wrap(option.get("arguments"))[1] or "mconfdialog"
os.execv(lua.program, {path.join("tests", testname .. ".lua")})
else
raise("%s not found!", has_config("luajit") and "luajit" or "lua")
end
end)
-- add target
target("ltui")
-- make as a shared library
set_kind("shared")
-- set target directory
set_targetdir("$(buildir)")
-- set languages
set_languages("c89")
-- add lua and do not link it on linux and macos
local lualinks = nil
if is_plat("macosx", "linux", "bsd") then
lualinks = {}
end
if has_config("luajit") then
add_defines("LUAJIT")
add_packages("luajit", {links = lualinks})
else
add_packages("lua", {links = lualinks})
end
-- add curses
if is_plat("windows") then
add_defines("PDCURSES")
add_includedirs("src/core/pdcurses")
else
add_packages("ncurses")
end
-- dynamic lookup liblua symbols
if is_plat("macosx") then
add_shflags("-undefined dynamic_lookup")
elseif is_plat("linux", "bsd") then
add_shflags("-undefined suppress")
end
if is_plat("mingw") then
set_filename("ltui.dll")
end
-- add projects
includes("src/core/curses")
if is_plat("windows") then
includes("src/core/pdcurses")
end