-
Notifications
You must be signed in to change notification settings - Fork 2
/
deprecated.lua
236 lines (187 loc) · 6.48 KB
/
deprecated.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
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
---
-- Package management module
-- Deprecated API.
-- Copyright (c) 2014-2016 Blizzard Entertainment
---
local p = premake
local m = p.modules.packagemanager
bnet = bnet or {}
---
-- Deprecate old cfg.bnet.variant context.
---
function bnet.new()
return {
variant = function (cfg)
p.warnOnce("cfg.bnet.variant", "'cfg.bnet.variant' is deprecated, use 'premake.packagemanager.buildVariantFromConfig(cfg)' instead.")
return p.packagemanager.buildVariantFromConfig(cfg)
end
}
end
p.override(p.context, "new", function (base, cfgset, environ)
local ctx = base(cfgset, environ)
ctx.bnet = bnet.new()
return ctx
end)
---
-- Setup some defaults we use here and there.
---
bnet.build_custom_variant = nil
bnet.build_dir = path.join(_MAIN_SCRIPT_DIR, _OPTIONS.to or 'build')
bnet.projects_dir = "%{path.join(bnet.build_dir, 'projects')}"
bnet.bin_dir = path.join(_MAIN_SCRIPT_DIR, "bin/%{cfg.buildcfg}")
bnet.obj_dir = "%{path.join(bnet.build_dir, premake.packagemanager.buildVariantFromConfig(cfg), 'obj')}"
bnet.lib_dir = "%{path.join(bnet.build_dir, premake.packagemanager.buildVariantFromConfig(cfg), 'lib')}"
verbosef("bnet.projects_dir: %s", bnet.projects_dir)
verbosef("bnet.obj_dir : %s", bnet.obj_dir)
verbosef("bnet.lib_dir : %s", bnet.lib_dir)
verbosef("bnet.bin_dir : %s", bnet.bin_dir)
setmetatable(bnet, {
__metatable = false,
__newindex = function(tbl, key, value)
if (key == "build_dir") then
p.warn("'bnet.build_dir' is deprecated, there is no equivalent.")
elseif (key == "projects_dir") then
p.warn("'bnet.projects_dir' is deprecated, use the 'package_location' API instead.")
assert(type(value) == "string", "projects_dir must be a string.")
package_location(value)
elseif (key == "obj_dir") then
p.warn("'bnet.obj_dir' is deprecated, use the 'package_objdir' API instead.")
assert(type(value) == "string", "obj_dir must be a string.")
package_objdir(value)
elseif (key == "lib_dir") then
p.warn("'bnet.lib_dir' is deprecated, use the 'package_libdir' API instead.")
assert(type(value) == "string", "lib_dir must be a string.")
package_libdir(value)
elseif (key == "bin_dir") then
p.warn("'bnet.bin_dir' is deprecated, use the 'package_bindir' API instead.")
assert(type(value) == "string", "bin_dir must be a string.")
package_bindir(value)
else
p.warn("Access to 'bnet' deprecated: " .. key)
end
rawset(tbl, key, value)
end,
})
---
-- Deprecated 'global' functions.
---
function _build_os(ctx)
p.warnOnce("_build_os", "'_build_os(cfg)' is deprecated, use 'premake.packagemanager.translateSystem(cfg.system)'.")
local var = ctx.system or premake.action.current().os or os.get()
if var == 'windows' then
var = "win32"
elseif var == 'macosx' then
var = "darwin"
end
return var
end
function _build_compiler(ctx)
p.warnOnce("_build_compiler", "'_build_compiler(cfg)' is deprecated, use 'premake.packagemanager.translateAction(_ACTION)'.")
local var = _ACTION
if var == "vs2010" then
return "vc100"
elseif var == "vs2012" then
return "vc110"
elseif var == "vs2013" then
return "vc120"
elseif var == "vs2015" then
return "vc140"
elseif var == "vs2017" then
return "vc141"
end
if _OPTIONS['compiler'] then
return _OPTIONS['compiler']
elseif os.get() == 'linux' then
return "gcc44"
elseif os.get() == 'macosx' then
return "clang"
end
return var
end
function _build_arch(ctx)
p.warnOnce("_build_arch", "'_build_arch(cfg)' is deprecated, use 'premake.packagemanager.translateArchitecture(cfg.architecture)'.")
local var = ctx.architecture
if ctx.architecture == 'x86' then
var = "i386"
end
if ctx.system == 'orbis' or ctx.system == 'durango' then
return nil
end
return var
end
function _build_config(ctx)
p.warnOnce("_build_config", "'_build_config(cfg)' is deprecated.")
local var = ctx.buildcfg
if var == "Debug" then
var = "debug"
elseif var == "Release" then
var = "release"
elseif var == "Public" then
var = "public"
end
return var
end
function _build_variant(ctx, dontIncludeArch, dontIncludCompiler, dontIncludeConfig)
p.warnOnce("_build_variant", "'_build_variant(cfg)' is deprecated, use 'premake.packagemanager.buildVariantFromConfig(cfg)'.")
local var = _build_os(ctx)
local compiler = _build_compiler(ctx)
local arch = _build_arch(ctx)
local config = _build_config(ctx)
if not dontIncludeArch and arch and #arch > 0 then
var = var .. "-" .. arch
end
if not dontIncludCompiler and compiler and #compiler > 0 then
var = var .. "-" .. compiler
end
if not dontIncludeConfig and config and #config > 0 then
var = var .. "-" .. config
end
return var
end
---
-- Deprecated 'cache' interface.
---
local m = {}
function m.use_env_var_location()
local folder = os.getenv('PACKAGE_CACHE_PATH')
if folder and os.isdir(folder) then
p.packagemanager.cache_location = folder
return true
end
return false
end
function m.get_folder()
p.warnOnce("cache_get_folder", "'cache.get_folder()' is deprecated, use 'premake.packagemanager.getCacheLocation()' instead.")
return p.packagemanager.getCacheLocation()
end
cache = setmetatable(m, {
__metatable = false,
__index = function(tbl, key)
return rawget(tbl, key)
end,
__newindex = function(tbl, key, value)
if (key == "package_hostname") then
p.warn("'cache.package_hostname' is deprecated, use 'premake.packagemanager.servers = {}' instead.")
assert(type(value) == "string", "package_hostname must be a string.")
p.packagemanager.servers = { value }
rawset(tbl, key, value)
elseif (key == "location_override") then
p.warn("'cache.location_override' is deprecated, use 'premake.packagemanager.cache_location' instead.")
assert(value == nil or type(value) == "string", "location_override must be a string or nil.")
p.packagemanager.cache_location = value
rawset(tbl, key, value)
elseif (key == "servers") then
p.warn("'cache.servers' is deprecated, use 'premake.packagemanager.servers' instead.")
assert(type(value) == "table", "servers must be a table.")
p.packagemanager.servers = value
rawset(tbl, key, value)
elseif (key == "folders") then
p.warn("'cache.folders' is deprecated, use 'premake.packagemanager.folders' instead.")
assert(type(value) == "table", "folders must be a table.")
p.packagemanager.folders = value
rawset(tbl, key, value)
else
error("Access to 'cache' deprecated: " .. key)
end
end,
})