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
|
--
-- globals.lua
-- Global tables and variables, replacements and extensions to Lua's global functions.
-- Copyright (c) 2002-2009 Jason Perkins and the Premake project
--
-- A top-level namespace for support functions
premake = { }
-- The list of supported platforms; also update list in cmdline.lua
premake.platforms =
{
Native =
{
cfgsuffix = "",
},
x32 =
{
cfgsuffix = "32",
},
x64 =
{
cfgsuffix = "64",
},
Universal =
{
cfgsuffix = "univ",
},
Universal32 =
{
cfgsuffix = "univ32",
},
Universal64 =
{
cfgsuffix = "univ64",
},
PS3 =
{
cfgsuffix = "ps3",
iscrosscompiler = true,
nosharedlibs = true,
namestyle = "PS3",
},
WiiDev =
{
cfgsuffix = "wii",
iscrosscompiler = true,
namestyle = "PS3",
},
Xbox360 =
{
cfgsuffix = "xbox360",
iscrosscompiler = true,
namestyle = "windows",
},
PowerPC =
{
cfgsuffix = "ppc",
iscrosscompiler = true,
},
ARM =
{
cfgsuffix = "ARM",
iscrosscompiler = true,
},
Orbis =
{
cfgsuffix = "orbis",
iscrosscompiler = true,
namestyle = "Orbis",
},
Durango =
{
cfgsuffix = "durango",
iscrosscompiler = true,
nosharedlibs = true,
namestyle = "windows",
},
TegraAndroid =
{
cfgsuffix = "tegraandroid",
iscrosscompiler = true,
namestyle = "TegraAndroid",
},
NX32 =
{
cfgsuffix = "nx32",
iscrosscompiler = true,
namestyle = "NX",
},
NX64 =
{
cfgsuffix = "nx64",
iscrosscompiler = true,
namestyle = "NX",
},
Emscripten =
{
cfgsuffix = "emscripten",
iscrosscompiler = true,
nosharedlibs = true,
namestyle = "Emscripten",
},
}
--
-- A replacement for Lua's built-in dofile() function, this one sets the
-- current working directory to the script's location, enabling script-relative
-- referencing of other files and resources.
--
local builtin_dofile = dofile
function dofile(fname)
-- remember the current working directory and file; I'll restore it shortly
local oldcwd = os.getcwd()
local oldfile = _SCRIPT
-- if the file doesn't exist, check the search path
if (not os.isfile(fname)) then
local path = os.pathsearch(fname, _OPTIONS["scripts"], os.getenv("PREMAKE_PATH"))
if (path) then
fname = path.."/"..fname
end
end
-- use the absolute path to the script file, to avoid any file name
-- ambiguity if an error should arise
_SCRIPT = path.getabsolute(fname)
-- switch the working directory to the new script location
local newcwd = path.getdirectory(_SCRIPT)
os.chdir(newcwd)
-- run the chunk. How can I catch variable return values?
local a, b, c, d, e, f = builtin_dofile(_SCRIPT)
-- restore the previous working directory when done
_SCRIPT = oldfile
os.chdir(oldcwd)
return a, b, c, d, e, f
end
--
-- "Immediate If" - returns one of the two values depending on the value of expr.
--
function iif(expr, trueval, falseval)
if (expr) then
return trueval
else
return falseval
end
end
--
-- A shortcut for including another build file, often used for projects.
--
function include(fname)
local dir, name = premake.findDefaultScript(fname, false)
if dir ~= nil then
return dofile(dir .. "/" .. name)
end
return nil
end
--
-- A shortcut for printing formatted output.
--
function printf(msg, ...)
local arg={...}
print(string.format(msg, table.unpack(arg)))
end
--
-- An extended type API to identify project object types by reading the
-- "__type" field from the metatable.
--
function typex(t)
local mt = getmetatable(t)
if (mt) then
if (mt.__type) then
return mt.__type
end
end
return type(t)
end
|