-
Notifications
You must be signed in to change notification settings - Fork 88
/
LUAPLUS.jamrules
298 lines (232 loc) · 7.45 KB
/
LUAPLUS.jamrules
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
if ! $(LUA_VERSION) {
local dirs = [ Glob $(LUAPLUS)/Src/LuaPlus : */ : 1 ] ;
dirs = $(dirs:P) ;
dirs = $(dirs:B) ;
# Choose the latest version.
dirs = [ FReverse [ ListSort $(dirs) : 0 ] ] ;
# if $(dirs[2]) {
# Echo LUA_VERSION needs to be passed in from the command-line. ;
# Echo ;
# Echo " jam LUA_VERSION=lua53-luaplus" ;
# Echo ;
# Echo "Available versions:" $(dirs) ;
# Exit ;
# }
LUA_VERSION = $(dirs[1]) ;
}
LUA_VERSION ?= lua51-luaplus ;
###############################################################################
# Set these if the user didn't use jam --workspace.
C.CompileOptions outputastree ;
if [ Glob $(CWD) : LUAPLUS.jamrules ] {
ALL_LOCATE_TARGET ?= $(LUAPLUS)/.build/obj.$(LUA_VERSION).$(C.COMPILER).$(PLATFORM).$(CONFIG) ;
}
LUAPLUS_OUTPUT_DIRECTORY ?= $(LUAPLUS)/.build/bin.$(LUA_VERSION).$(C.COMPILER).$(PLATFORM) ;
DEPCACHE.standard ?= $(ALL_LOCATE_TARGET)/.depcache ;
DEPCACHE ?= standard ;
LUA_SOURCE_DIRECTORY_NAME = $(LUA_VERSION) ;
LUAPLUS_INCLUDE_DIRECTORIES = $(LUAPLUS)/Src $(LUAPLUS)/Src/LuaPlus/$(LUA_SOURCE_DIRECTORY_NAME)/src ;
NotFile download ;
rule LuaPlusDefines TARGET
{
if $(OS) in LINUX FREEBSD
{
C.Defines $(TARGET) : LUA_USE_LINUX ;
}
}
rule LuaPlusFixUpTarget TARGET
{
LuaPlusDefines $(TARGET) ;
if $(CONFIG) = debug {
C.OutputPostfix $(TARGET) : .debug ;
} else {
C.OutputPostfix $(TARGET) : ;
}
# If C.OutputPath * was used, then use its location.
#local outputPath = $(LOCATE:Z=$(C.ACTIVE_TOOLCHAIN_*)) ;
#C.OutputPath $(TARGET) : $(outputPath:E=$(LUAPLUS_OUTPUT_DIRECTORY)) ;
C.OutputPath $(TARGET) : $(LUAPLUS_OUTPUT_DIRECTORY) ;
}
###############################################################################
if $(OS) = NT {
if $(LUA_VERSION) in lua51-luaplus lua52-luaplus lua53-luaplus {
LUA_CDIR = $(LUAPLUS_OUTPUT_DIRECTORY)/modules ;
} else {
LUA_CDIR = $(LUAPLUS_OUTPUT_DIRECTORY) ;
}
LUA_LDIR = $(LUAPLUS_OUTPUT_DIRECTORY)/lua ;
} else {
if $(LUA_VERSION) in lua51-luaplus {
LUA_CDIR = $(LUAPLUS_OUTPUT_DIRECTORY)/lib/lua/5.1 ;
LUA_LDIR = $(LUAPLUS_OUTPUT_DIRECTORY)/share/lua/5.1 ;
} else if $(LUA_VERSION) in lua52-luaplus {
LUA_CDIR = $(LUAPLUS_OUTPUT_DIRECTORY)/lib/lua/5.2 ;
LUA_LDIR = $(LUAPLUS_OUTPUT_DIRECTORY)/share/lua/5.2 ;
} else if $(LUA_VERSION) in lua53-luaplus {
LUA_CDIR = $(LUAPLUS_OUTPUT_DIRECTORY)/lib/lua/5.3 ;
LUA_LDIR = $(LUAPLUS_OUTPUT_DIRECTORY)/share/lua/5.3 ;
} else {
LUA_CDIR = $(LUAPLUS_OUTPUT_DIRECTORY) ;
LUA_LDIR = $(LUAPLUS_OUTPUT_DIRECTORY) ;
}
}
rule LuaPlus.CModule TARGET : OUTPUT_NAME : SOURCES : MODULES_SUBDIR {
SubInclude LUAPLUS Src LuaPlus : LuaPlusSharedLib ;
TARGET = [ ActiveTarget $(TARGET) ] ;
Depends all : $(TARGET) ;
LuaPlusDefines $(TARGET) ;
C.IncludeDirectories $(TARGET) : $(LUAPLUS_INCLUDE_DIRECTORIES) ;
if ! $(OS) in MACOSX LINUX FREEBSD {
C.LinkLibraries $(TARGET) : $(LUA_VERSION) ;
}
OUTPUT_NAME ?= $(TARGET) ;
local MODULES_SUBDIR = $(OUTPUT_NAME[1]:D) ;
OUTPUT_NAME = $(OUTPUT_NAME[1]:D=) $(OUTPUT_NAME[2]) ;
if $(MSVCNT) {
local EXPORT_NAME = $(OUTPUT_NAME[2]:E=$(OUTPUT_NAME[1])) ;
local exportName = [ Subst $(EXPORT_NAME) : %. : _ ] ;
local exportPath = [ Subst $(MODULES_SUBDIR:E="") : / : _ ] ;
if $(exportPath) != "" {
exportPath = $(exportPath)_ ;
}
C.LinkFlags $(TARGET) : /EXPORT:luaopen_$(exportPath)$(exportName) ;
}
C.OutputName $(TARGET) : $(OUTPUT_NAME[1]) ;
if $(CONFIG) = debug {
C.OutputPostfix $(TARGET) : .debug ;
} else {
C.OutputPostfix $(TARGET) : ;
}
C.OutputPath $(TARGET) : $(LUA_CDIR)/$(MODULES_SUBDIR:E=) ;
C.Library $(TARGET) : $(SOURCES) : module ;
ProjectGroup LuaPlus : Modules : $(TARGET) ;
Workspace LuaPlus : $(TARGET) ;
}
rule Lua.CModule TARGET : OUTPUT_NAME : SOURCES : MODULES_SUBDIR {
SubInclude LUAPLUS Src Lua51Proxy : Lua51Proxy ;
TARGET = [ ActiveTarget $(TARGET) ] ;
Depends all : $(TARGET) ;
LuaPlusDefines $(TARGET) ;
C.IncludeDirectories $(TARGET) : $(LUAPLUS_INCLUDE_DIRECTORIES) ;
if ! $(OS) in MACOSX LINUX FREEBSD {
C.LinkLibraries $(TARGET) : $(LUA_VERSION) ;
}
OUTPUT_NAME ?= $(TARGET) ;
local MODULES_SUBDIR = $(OUTPUT_NAME[1]:D) ;
OUTPUT_NAME = $(OUTPUT_NAME[1]:D=) $(OUTPUT_NAME[2]) ;
if $(MSVCNT) {
local EXPORT_NAME = $(OUTPUT_NAME[2]:E=$(OUTPUT_NAME[1])) ;
local exportName = [ Subst $(EXPORT_NAME) : %. : _ ] ;
local exportPath = [ Subst $(MODULES_SUBDIR:E="") : / : _ ] ;
if $(exportPath) != "" {
exportPath = $(exportPath)_ ;
}
C.LinkFlags $(TARGET) : /EXPORT:luaopen_$(exportPath)$(exportName) ;
}
C.OutputName $(TARGET) : $(OUTPUT_NAME[1]) ;
if $(CONFIG) = debug {
C.OutputPostfix $(TARGET) : .debug ;
} else {
C.OutputPostfix $(TARGET) : ;
}
C.OutputPath $(TARGET) : $(LUA_CDIR)/$(MODULES_SUBDIR:E=) ;
C.Library $(TARGET) : $(SOURCES) : module ;
ProjectGroup LuaPlus : Modules : $(TARGET) ;
Workspace LuaPlus : $(TARGET) ;
}
rule Lua.Module TARGET : OUTPUT_NAME : SOURCES {
TARGET = [ ActiveTarget $(TARGET) ] ;
OUTPUT_NAME ?= $(TARGET) ;
local MODULES_SUBDIR = $(OUTPUT_NAME[1]:D) ;
OUTPUT_NAME = $(OUTPUT_NAME[1]:D=) ;
Depends all : $(TARGET) ;
NotFile $(TARGET) ;
Depends clean : clean:$(TARGET) ;
NotFile clean:$(TARGET) ;
Always clean:$(TARGET) ;
Project $(TARGET) : $(SOURCES) ;
ProjectGroup LuaPlus : Modules : $(TARGET) ;
Workspace LuaPlus : $(TARGET) ;
}
rule Lua.Use TARGET : OPTIONS : OUTPUT_DIRECTORY {
if build in $(OPTIONS) {
if shared in $(OPTIONS) {
SubInclude LUAPLUS Src LuaPlus : LuaPlusSharedLib ;
} else {
SubInclude LUAPLUS Src LuaPlus : LuaPlusStaticLib ;
}
}
TARGET = [ ActiveTarget $(TARGET) ] ;
LuaPlusDefines $(TARGET) ;
if shared in $(OPTIONS) {
C.Defines $(TARGET) : LUA_BUILD_AS_DLL ;
}
C.IncludeDirectories $(TARGET) : $(LUAPLUS_INCLUDE_DIRECTORIES) ;
if prebuilt in $(OPTIONS) {
if defaultdirectory in $(OPTIONS) {
OUTPUT_DIRECTORY ?= $(LUAPLUS_OUTPUT_DIRECTORY) ;
}
C.LinkDirectories $(TARGET) : $(OUTPUT_DIRECTORY) ;
if shared in $(OPTIONS) {
# Get rid of the -luaplus in the LUA_VERSION, because the name
# on disk will just be lua53, not lua53-luaplus.
local strippedName = [ Subst $(LUA_VERSION) : -luaplus : "" ] ;
if $(C.CONFIG) = debug {
strippedName = $(strippedName)_debug ;
}
C.LinkPrebuiltLibraries $(TARGET) : $(strippedName) ;
} else {
if $(C.CONFIG) = debug {
C.LinkPrebuiltLibraries $(TARGET) : $(LUA_VERSION)-static.debug ;
} else {
C.LinkPrebuiltLibraries $(TARGET) : $(LUA_VERSION)-static ;
}
}
} else if build in $(OPTIONS) {
if defaultdirectory in $(OPTIONS) {
OUTPUT_DIRECTORY ?= $(LUAPLUS_OUTPUT_DIRECTORY) ;
}
C.LinkDirectories $(TARGET) : $(OUTPUT_DIRECTORY) ;
if shared in $(OPTIONS) {
C.LinkLibraries $(TARGET) : $(LUA_VERSION) ;
} else {
C.LinkLibraries $(TARGET) : $(LUA_VERSION)-static ;
}
}
}
if ! $(TARGETINFO_LOCATE)
{
rule Lua.ToBinary PARENTS : TARGETS : SOURCES
{
Depends $(TARGETS) : $(SOURCES) ;
Needs $(TARGETS) : $(LUAC_EXE) ;
Clean clean:$(PARENTS) : $(TARGETS) ;
_LuaToBinary $(TARGETS) : $(SOURCES) ;
}
actions _LuaToBinary
{
$(LUAC_EXE:TC) -o $(1:C) $(2:C)
}
rule Lua.Bin2C PARENTS : TARGETS : SOURCES
{
Depends $(TARGETS) : $(SOURCES) ;
Needs $(TARGETS) : $(LUA_EXE) ;
Clean clean:$(PARENTS) : $(TARGETS) ;
BIN2C on $(TARGETS) = $(LUAPLUS)/Tools/bin2c.lua ;
_LuaBin2C $(TARGETS) : $(SOURCES) ;
}
actions _LuaBin2C
{
$(LUA_EXE:TC) $(BIN2C:C) $(2:C) > $(1:C)
}
}
else
{
rule LuaToBinary
{
}
rule Bin2C
{
}
}
Project !BuildWorkspace : $(LUAPLUS)/LUAPLUS.jamrules ;