-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathxmake.lua
More file actions
219 lines (189 loc) · 6.36 KB
/
xmake.lua
File metadata and controls
219 lines (189 loc) · 6.36 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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
set_version ("17.11.29")
-- mode
set_allowedmodes("releasedbg", "release", "debug", "profile")
add_rules("mode.releasedbg", "mode.release", "mode.debug", "mode.profile")
-- plat
set_allowedplats("linux", "macosx", "windows", "wasm")
-- proj
set_project("Goldfish Scheme")
-- repo
add_repositories("goldfish-repo xmake")
option("tbox")
set_description("Use tbox installed via apt")
set_default(false)
set_values(false, true)
option_end()
option("repl")
set_description("Enable REPL (isocline) support")
set_default(false) -- repl-anchor
set_values(false, true)
option_end()
option("system-deps")
set_description("Use system dependences")
set_default(false)
set_values(false, true)
option_end()
local system = has_config("system-deps")
option("pin-deps")
set_description("Pin dependences version")
set_default(true)
set_values(false, true)
option_end()
option("http")
set_description("Enable http")
set_default(true)
set_values(false, true)
option_end()
option("gmp")
set_description("Enable GMP support for S7")
set_default(false)
set_values(false, true)
option_end()
if has_config("http") then
add_requires("cpr")
end
if has_config("gmp") then
add_requires("gmp")
end
-- S7 is now included as source files in src/ directory
local TBOX_VERSION = "1.7.7"
if has_config("tbox") then
add_requires("apt::libtbox-dev", {alias="tbox"})
else
tbox_configs = {hash=true, ["force-utf8"]=true}
if has_config("pin-deps") then
add_requires("tbox " .. TBOX_VERSION, {system=system, configs=tbox_configs})
else
add_requires("tbox", {system=system, configs=tbox_configs})
end
end
if is_plat("wasm") then
if has_config("pin-deps") then
add_requires("emscripten 3.1.55")
else
add_requires("emscripten")
end
set_toolchains("emcc@emscripten")
end
local IC_VERSION = "v1.0.9"
if has_config("pin-deps") then
add_requires("isocline " .. IC_VERSION, {system=system})
else
add_requires("isocline", {system=system})
end
-- local header only dependency, no need to (un)pin version
add_requires("argh v1.3.2")
local NLOHMANN_JSON_VERSION = "v3.11.3"
add_requires("nlohmann_json")
local JSON_SCHEMA_VALIDATOR_VERSION = "2.4.0"
add_requires("json_schema_validator")
target ("goldfish") do
set_languages("c++17")
set_targetdir("$(projectdir)/bin/")
if is_plat("linux") then
add_syslinks("stdc++")
end
if is_plat("wasm") then
-- preload goldfish stdlib in `bin/goldfish.data`
add_ldflags("--preload-file goldfish@/goldfish")
end
add_files ("src/goldfish.cpp")
add_files ("src/s7.c", {languages = "c11"})
add_files ("src/s7_scheme_complex.c", {languages = "c11"})
add_files ("src/s7_scheme_char.c", {languages = "c11"})
add_files ("src/s7_liii_bitwise.c", {languages = "c11"})
add_files ("src/s7_liii_string.c", {languages = "c11"})
add_files ("src/s7_liii_hash_table.c", {languages = "c11"})
add_files ("src/s7_scheme_inexact.c", {languages = "c11"})
add_files ("src/s7_scheme_base.c", {languages = "c11"})
add_packages("tbox")
add_packages("argh")
add_packages("nlohmann_json")
add_packages("json_schema_validator")
add_packages("cpr")
-- S7 configuration from original 3rdparty/s7/xmake.lua
add_defines("WITH_SYSTEM_EXTRAS=0")
if not is_plat("wasm") then
add_defines("HAVE_OVERFLOW_CHECKS=0")
end
add_defines("WITH_WARNINGS")
add_defines("WITH_R7RS=1")
if is_mode("debug") then
add_defines("S7_DEBUGGING")
end
add_options("gmp")
if has_config("gmp") then
add_defines("WITH_GMP")
add_packages("gmp")
end
-- Windows-specific configuration from original 3rdparty/s7/xmake.lua
if is_plat("windows") then
set_optimize("faster")
add_cxxflags("/fp:precise")
end
-- only enable REPL if repl option is enabled
if has_config("repl") then
add_packages("isocline")
add_defines("GOLDFISH_WITH_REPL")
end
add_installfiles("$(projectdir)/goldfish/(scheme/*.scm)", {prefixdir = "share/goldfish"})
add_installfiles("$(projectdir)/goldfish/(srfi/*.scm)", {prefixdir = "share/goldfish"})
add_installfiles("$(projectdir)/goldfish/(liii/*.scm)", {prefixdir = "share/goldfish"})
add_installfiles("$(projectdir)/goldfish/(guenchi/*.scm)", {prefixdir = "share/goldfish"})
end
if is_plat("wasm") then
target("goldfish_repl_wasm")
set_kind("binary")
set_languages("c++17")
set_targetdir("$(projectdir)/repl/")
add_files("src/goldfish_repl.cpp")
add_packages("tbox", "argh", "nlohmann_json", "json_schema_validator")
add_defines("GOLDFISH_ENABLE_REPL")
-- S7 configuration from original 3rdparty/s7/xmake.lua
add_defines("WITH_SYSTEM_EXTRAS=0")
-- WASM platform doesn't have HAVE_OVERFLOW_CHECKS=0
add_defines("WITH_WARNINGS")
add_defines("WITH_R7RS=1")
if is_mode("debug") then
add_defines("S7_DEBUGGING")
end
add_options("gmp")
if has_config("gmp") then
add_defines("WITH_GMP")
add_packages("gmp")
end
add_ldflags("--preload-file goldfish@/goldfish")
-- 导出 REPL 相关函数
add_ldflags("-sEXPORTED_FUNCTIONS=['_eval_string','_get_out','_get_err','_malloc','_free']", {force = true})
add_ldflags("-sEXPORTED_RUNTIME_METHODS=['UTF8ToString','allocateUTF8']", {force = true})
add_ldflags("-sINITIAL_MEMORY=134217728", {force = true})
add_ldflags("-sALLOW_MEMORY_GROWTH=1", {force = true})
add_ldflags("-sASSERTIONS=1", {force = true})
-- 生成 js glue code
set_extension(".js")
end
includes("@builtin/xpack")
xpack ("goldfish")
if is_plat("windows") then
set_formats("zip")
else
set_formats("deb", "rpm", "srpm")
end
set_author("Da Shen <da@liii.pro>")
set_license("Apache-2.0")
set_title("Goldfish Scheme")
set_description("A Python-like Scheme Interpreter")
set_homepage("https://gitee.com/LiiiLabs/goldfish")
add_targets ("goldfish")
add_sourcefiles("(xmake/**)")
add_sourcefiles("xmake.lua")
add_sourcefiles("(src/**)")
add_sourcefiles("(goldfish/**)")
add_sourcefiles("(3rdparty/**)")
on_load(function (package)
if package:with_source() then
package:set("basename", "goldfish-$(plat)-src-v$(version)")
else
package:set("basename", "goldfish-$(plat)-$(arch)-v$(version)")
end
end)