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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
--!The Automatic Cross-platform Build Tool
--
-- XMake is free software; you can redistribute it and/or modify
-- it under the terms of the GNU Lesser General Public License as published by
-- the Free Software Foundation; either version 2.1 of the License, or
-- (at your option) any later version.
--
-- XMake is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public License
-- along with XMake;
-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
--
-- Copyright (C) 2015 - 2016, ruki All rights reserved.
--
-- @author ruki
-- @file deprecated_project.lua
--
-- define module: deprecated_project
local deprecated_project = deprecated_project or {}
-- load modules
local os = require("base/os")
local path = require("base/path")
local utils = require("base/utils")
local table = require("base/table")
local string = require("base/string")
local config = require("project/config")
local platform = require("platform/platform")
local deprecated = require("base/deprecated")
local deprecated_interpreter = require("base/deprecated/interpreter")
-- the current os is belong to the given os?
function deprecated_project._api_is_os(interp, ...)
-- get the current os
local os = platform.os()
if not os then return false end
-- exists this os?
for _, o in ipairs(table.join(...)) do
if o and type(o) == "string" and o == os then
return true
end
end
end
-- the current mode is belong to the given modes?
function deprecated_project._api_is_mode(interp, ...)
-- get the current mode
local mode = config.get("mode")
if not mode then return false end
-- exists this mode?
for _, m in ipairs(table.join(...)) do
if m and type(m) == "string" and m == mode then
return true
end
end
end
-- the current platform is belong to the given platforms?
function deprecated_project._api_is_plat(interp, ...)
-- get the current platform
local plat = config.get("plat")
if not plat then return false end
-- exists this platform? and escape '-'
for _, p in ipairs(table.join(...)) do
if p and type(p) == "string" and plat:find(p:gsub("%-", "%%-")) then
return true
end
end
end
-- the current platform is belong to the given architectures?
function deprecated_project._api_is_arch(interp, ...)
-- get the current architecture
local arch = config.get("arch")
if not arch then return false end
-- exists this architecture? and escape '-'
for _, a in ipairs(table.join(...)) do
if a and type(a) == "string" and arch:find(a:gsub("%-", "%%-")) then
return true
end
end
end
-- the current kind is belong to the given kinds?
function deprecated_project._api_is_kind(interp, ...)
-- get the current kind
local kind = config.get("kind")
if not kind then return false end
-- exists this kind?
for _, k in ipairs(table.join(...)) do
if k and type(k) == "string" and k == kind then
return true
end
end
end
-- enable options?
function deprecated_project._api_is_option(interp, ...)
-- some options are enabled?
for _, o in ipairs(table.join(...)) do
if o and type(o) == "string" and config.get(o) then
return true
end
end
end
-- load all packages from the given directories
function deprecated_project._api_add_pkgdirs(interp, ...)
-- get all directories
local pkgdirs = {}
local dirs = table.join(...)
for _, dir in ipairs(dirs) do
table.insert(pkgdirs, dir .. "/*.pkg")
end
-- add all packages
interp:api_builtin_add_subdirs(pkgdirs)
end
-- load the given packages
function deprecated_project._api_add_pkgs(interp, ...)
-- add all packages
interp:api_builtin_add_subdirs(...)
end
-- the current os is belong to the given os?
function deprecated_project._api_os(interp, ...)
-- make values
local values = ""
for _, v in ipairs(table.join(...)) do
if v and type(v) == "string" then
if #values == 0 then
values = v
else
values = values .. ", " .. v
end
end
end
-- deprecated
deprecated.add("is_os(\"%s\")", "os(\"%s\")", values)
-- done
return deprecated_project._api_is_os(interp, ...)
end
-- the current mode is belong to the given modes?
function deprecated_project._api_modes(interp, ...)
-- make values
local values = ""
for _, v in ipairs(table.join(...)) do
if v and type(v) == "string" then
if #values == 0 then
values = v
else
values = values .. ", " .. v
end
end
end
-- deprecated
deprecated.add("is_mode(\"%s\")", "modes(\"%s\")", values)
-- done
return deprecated_project._api_is_mode(interp, ...)
end
-- the current platform is belong to the given platforms?
function deprecated_project._api_plats(interp, ...)
-- make values
local values = ""
for _, v in ipairs(table.join(...)) do
if v and type(v) == "string" then
if #values == 0 then
values = v
else
values = values .. ", " .. v
end
end
end
-- deprecated
deprecated.add("is_plat(\"%s\")", "plats(\"%s\")", values)
-- done
return deprecated_project._api_is_plat(interp, ...)
end
-- the current platform is belong to the given architectures?
function deprecated_project._api_archs(interp, ...)
-- make values
local values = ""
for _, v in ipairs(table.join(...)) do
if v and type(v) == "string" then
if #values == 0 then
values = v
else
values = values .. ", " .. v
end
end
end
-- deprecated
deprecated.add("is_arch(\"%s\")", "archs(\"%s\")", values)
-- done
return deprecated_project._api_is_arch(interp, ...)
end
-- the current kind is belong to the given kinds?
function deprecated_project._api_kinds(interp, ...)
-- make values
local values = ""
for _, v in ipairs(table.join(...)) do
if v and type(v) == "string" then
if #values == 0 then
values = v
else
values = values .. ", " .. v
end
end
end
-- deprecated
deprecated.add("is_kind(\"%s\")", "kinds(\"%s\")", values)
-- done
return deprecated_project._api_is_kind(interp, ...)
end
-- enable options?
function deprecated_project._api_options(interp, ...)
-- make values
local values = ""
for _, v in ipairs(table.join(...)) do
if v and type(v) == "string" then
if #values == 0 then
values = v
else
values = values .. ", " .. v
end
end
end
-- deprecated
deprecated.add("is_option(\"%s\")", "options(\"%s\")", values)
-- done
return deprecated_project._api_is_option(interp, ...)
end
-- load all packages from the given directories
function deprecated_project._api_add_packagedirs(interp, ...)
-- make values
local values = ""
for _, v in ipairs(table.join(...)) do
if v and type(v) == "string" then
if #values == 0 then
values = v
else
values = values .. ", " .. v
end
end
end
-- deprecated
deprecated.add("add_pkgdirs(\"%s\")", "add_packagedirs(\"%s\")", values)
-- done
return deprecated_project._api_add_pkgdirs(interp, ...)
end
-- load the given packages
function deprecated_project._api_add_packages(interp, ...)
-- make values
local values = ""
for _, v in ipairs(table.join(...)) do
if v and type(v) == "string" then
if #values == 0 then
values = v
else
values = values .. ", " .. v
end
end
end
-- deprecated
deprecated.add("add_pkgs(\"%s\")", "add_packages(\"%s\")", values)
-- done
return deprecated_project._api_add_pkgs(interp, ...)
end
-- register api
function deprecated_project.api_register(interp)
-- register api: set_target() and set_option()
deprecated_interpreter.api_register_set_scope(interp, "target", "option")
deprecated_interpreter.api_register_add_scope(interp, "target", "option")
-- register api: set_runscript() and set_installscript() and set_packagescript()
deprecated_interpreter.api_register_set_script(interp, "target", "runscript", "installscript", "packagescript")
-- register api: os(), kinds(), modes(), plats(), archs(), options()
interp:api_register(nil, "os", deprecated_project._api_os)
interp:api_register(nil, "kinds", deprecated_project._api_kinds)
interp:api_register(nil, "modes", deprecated_project._api_modes)
interp:api_register(nil, "plats", deprecated_project._api_plats)
interp:api_register(nil, "archs", deprecated_project._api_archs)
interp:api_register(nil, "options", deprecated_project._api_options)
-- register api: add_pkgdirs() to root
interp:api_register(nil, "add_pkgdirs", deprecated_project._api_add_packagedirs)
-- register api: add_pkgs() to root
interp:api_register(nil, "add_pkgs", deprecated_project._api_add_packages)
-- register api: set_values() to option
deprecated_interpreter._api_register_set_xxx_xxx(interp, "option", "enable")
deprecated_interpreter._api_register_set_xxx_xxx(interp, "option", "showmenu")
deprecated_interpreter._api_register_set_xxx_xxx(interp, "option", "category")
deprecated_interpreter._api_register_set_xxx_xxx(interp, "option", "warnings")
deprecated_interpreter._api_register_set_xxx_xxx(interp, "option", "optimize")
deprecated_interpreter._api_register_set_xxx_xxx(interp, "option", "languages")
deprecated_interpreter._api_register_set_xxx_xxx(interp, "option", "description")
-- register api: add_values() to option
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "links")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cincludes")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cxxincludes")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cfuncs")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cxxfuncs")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "ctypes")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cxxtypes")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cflags")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cxflags")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "cxxflags")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "mflags")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "mxflags")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "mxxflags")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "ldflags")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "vectorexts")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "defines")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "defines_if_ok")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "defines_h_if_ok")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "undefines")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "undefines_if_ok")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "undefines_h_if_ok")
-- register api: add_pathes() to option
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "linkdirs")
deprecated_interpreter._api_register_add_xxx_xxx(interp, "option", "includedirs")
end
-- return module: deprecated_project
return deprecated_project
|