-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathmakefile.lua
More file actions
342 lines (320 loc) · 9.67 KB
/
Copy pathmakefile.lua
File metadata and controls
342 lines (320 loc) · 9.67 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
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
#!/usr/bin/lua
xpcall( function() dofile( "config.lua") end, function() end )
VALKYRIE_ROOT = VALKYRIE_ROOT or os.getenv("FPCVALKYRIE_ROOT") or "../fpcvalkyrie/"
dofile (VALKYRIE_ROOT.."scripts/lua_make.lua")
local function load_module_paths()
local manifest_path = "bin/modules.local.lua"
local file = io.open(manifest_path, "r")
if not file then return {} end
file:close()
local environment = {}
local chunk = assert(loadfile(manifest_path))
setfenv(chunk, environment)
chunk()
assert(type(environment.module_paths) == "table", "Malformed module_paths")
local module_paths = {}
for module_id,module_path in pairs(environment.module_paths) do
if type(module_id) == "string"
and not module_id:match("^%s*$") then
if type(module_path) ~= "string"
or module_path:match("^%s*$") then
error("Malformed module_paths entry "..module_id)
end
module_paths[module_id] = os.path_normalize(
module_path:match("^%s*(.-)%s*$")
)
end
end
return module_paths
end
local module_paths = load_module_paths()
local function module_source_path(module_id)
return module_paths[module_id]
or ("data"..os.path_sep..module_id)
end
local function module_root_path(module_id)
local path = module_source_path(module_id)
if os.path_is_absolute(path) then return path end
return os.path_join(os.pwd(), "bin", path)
end
local function run_drlwad(build_file, raise_errors)
os.execute_in_dir("drlwad", "bin", { build_file }, raise_errors)
end
local function jhc_build_root()
if module_paths.jhc then
return os.path_join(module_root_path("jhc"), "..")
end
return os.path_join(os.pwd(), "..", "jhc")
end
local function jhc_build_file(name)
return os.path_join(jhc_build_root(), name)
end
local function jhc_source_file(name)
return os.path_join(jhc_build_root(), "jhc", name)
end
local function prepare_steam_content(app_build)
local app_vdfs = {
main = "app_build_3126530.vdf",
demo = os.path_join("demo", "app_build_3256910.vdf"),
}
local app_vdf = assert(app_vdfs[app_build],
"Unknown JHC Steam application build: "..tostring(app_build))
local content_path = make.publish("steam", "jhc")
local setup_path = os.path_join(content_path, "data", "jhc", "setup")
local demo_setup_path = os.path_join(
content_path, "data", "jhc", "setup", "demo"
)
os.mkdir({ setup_path, demo_setup_path })
for _,vdf in ipairs({
"app_build_3126530.vdf",
"depot_build_3126531.vdf",
"depot_build_3126532.vdf",
"depot_build_3126533.vdf",
}) do
os.copy_file(
os.path_join(module_root_path("jhc"), "setup", vdf),
setup_path
)
end
for _,vdf in ipairs({
"app_build_3256910.vdf",
"depot_build_3256911.vdf",
"depot_build_3256912.vdf",
"depot_build_3256913.vdf",
}) do
os.copy_file(
os.path_join(module_root_path("jhc"), "setup", "demo", vdf),
demo_setup_path
)
end
return content_path, os.path_join(
os.pwd(), content_path, "data", "jhc", "setup", app_vdf
)
end
local BUILT = false
function set_demo(path, value)
local new_value = value and "true" or "false"
local f = assert(io.open(path, "r"))
local content = f:read("*a")
f:close()
local new_content, n = content:gsub(
'core%.declare%s*%(%s*"DEMO"%s*,%s*%a+%s*%)',
'core.declare( "DEMO", ' .. new_value .. ' )'
)
if n == 0 then
error("No matching DEMO declaration found in " .. path)
end
f = assert(io.open(path, "w"))
f:write(new_content)
f:close()
end
local function with_demo(path, action)
set_demo(path, true)
local success, message = xpcall(action, debug.traceback)
local restored, restore_message = pcall(set_demo, path, false)
if not restored then
if success then message = "" else message = tostring(message).."\n" end
error(message.."Failed to restore DEMO=false: "..tostring(restore_message), 0)
end
if not success then error(message, 0) end
end
makefile = {
name = "drl",
fpc_params = {
"-Fu"..VALKYRIE_ROOT.."src",
"-Fu"..VALKYRIE_ROOT.."libs",
},
fpc_os_params = {
WINDOWS = {},
LINUX = {
"-TLINUX",
},
MACOSX = {
"-dOSX_APP_BUNDLE",
"-Fl/usr/local/lib",
"-k-macos_version_min -k11.0",
},
},
pre_build = function()
make.readluaversion( "bin/data/core/main.lua", "VERSION_ENGINE" )
end,
post_build = function()
end,
source_files = { "drl.pas", "drlwad.pas" },
publish = {
lq = {
exec = { "drl" },
files = { "config.lua", "font.dat" },
os = {
WINDOWS = { "fmod64.dll", "lua5.1.dll", "SDL3.dll", "SDL3_image.dll", "drl_console.bat" },
LINUX = { "unix_notes.txt", "drl_gnome-terminal", "drl_konsole", "drl_xterm", dos2unix = true, },
MACOSX = { "unix_notes.txt" },
},
subdirs = {
["data/drllq/sound"] = "*.wav",
["data/drllq/music"] = "*.mid",
["data/drllq"] = "*.lua",
},
other = { "manual.txt", "version.txt", "version_api.txt", "drl.wad", "core.wad" },
},
hq = {
exec = { "drl" },
files = { "config.lua", "font.dat" },
os = {
WINDOWS = { "fmod64.dll", "lua5.1.dll", "SDL3.dll", "SDL3_image.dll", "drl_console.bat" },
LINUX = { "unix_notes.txt", "drl_gnome-terminal", "drl_konsole", "drl_xterm", dos2unix = true, },
MACOSX = { "unix_notes.txt" },
},
subdirs = {
["data/drlhq/sound"] = "*.wav",
["data/drlhq/music"] = "*.mp3",
["data/drlhq"] = "*.lua",
},
other = { "manual.txt", "version.txt", "version_api.txt", "drl.wad", "core.wad" },
},
jhc = {
exec = { "drl" },
files = { "config.lua", "font.dat" },
os = {
WINDOWS = { "steam_api64.dll", "fmod64.dll", "lua5.1.dll", "SDL3.dll", "SDL3_image.dll", "drl_console.bat" },
LINUX = { "libsteam_api.so", "libfmod.so", "libSDL3.so.0.4.2", "libSDL3_image.so.0.4.0", "run_jhc.sh" },
MACOSX = { "unix_notes.txt" },
},
other = { "jhc.wad", "core.wad", "version.txt" },
}
},
commands = {
jhc_demo_test = function()
run_drlwad(jhc_build_file("build.lua"))
make.publish( "deploy", "jhc" )
local content_path, app_vdf_path =
prepare_steam_content("demo")
make.steam(content_path, app_vdf_path)
end,
jhc_demo = function()
local main_path = jhc_source_file("main.lua")
with_demo(main_path, function()
run_drlwad(jhc_build_file("demo.build.lua"), true)
end)
make.publish( "deploy", "jhc" )
local content_path, app_vdf_path =
prepare_steam_content("demo")
make.steam(content_path, app_vdf_path)
end,
jhc = function()
run_drlwad(jhc_build_file("build.lua"))
make.publish( "deploy", "jhc" )
local content_path, app_vdf_path =
prepare_steam_content("main")
make.steam(content_path, app_vdf_path)
end,
jhc_build = function()
run_drlwad(jhc_build_file("build.lua"))
make.publish( "deploy", "jhc" )
end,
jhc_demo_build = function()
local main_path = jhc_source_file("main.lua")
with_demo(main_path, function()
run_drlwad(jhc_build_file("demo.build.lua"), true)
end)
make.publish( "deploy-demo", "jhc" )
end,
jhc_push = function()
local content_path, app_vdf_path =
prepare_steam_content("main")
make.steam(content_path, app_vdf_path)
end,
jhc_demo_push = function()
local content_path, app_vdf_path =
prepare_steam_content("demo")
make.steam(content_path, app_vdf_path)
end,
lq = function()
if not BUILT then
run_drlwad("..")
BUILT = true
end
make.package( make.publish( (OS_VER_PREFIX or "")..make.version_name().."-lq", "lq" ), PUBLISH_DIR )
end,
hq = function()
if not BUILT then
run_drlwad("..")
BUILT = true
end
make.package( make.publish( (OS_VER_PREFIX or "")..make.version_name(), "hq" ), PUBLISH_DIR )
end,
drl_mod = function()
run_drlwad(os.path_join("..", "drlhq.build.lua"))
os.mkdir( "bin/deploy/drl" )
os.copy( "bin/drl.wad", "bin/deploy/drl/drl.wad" )
os.execute_in_dir( "drl", "bin", { "--publish=drl", "--god" } )
end,
install = function() makefile.commands.installhq() end,
installhq = function()
if not BUILT then
run_drlwad("..")
BUILT = true
end
if OS == "WINDOWS" then
make.generate_iss( "drl.iss", "hq", PUBLISH_DIR )
elseif OS == "MACOSX" then
make.generate_bundle( "hq", PUBLISH_DIR )
end
end,
installlq = function()
if not BUILT then
run_drlwad("..")
BUILT = true
end
if OS == "WINDOWS" then
make.generate_iss( "drl.iss", "lq", PUBLISH_DIR )
elseif OS == "MACOSX" then
make.generate_bundle( "lq", PUBLISH_DIR )
end
end,
all = function()
makefile.commands.lq()
makefile.commands.hq()
makefile.commands.install()
end,
alllq = function()
makefile.commands.lq()
makefile.commands.installlq()
end,
},
install = {
guid = "E78C63C9-9849-45FA-8315-2AE38A293E2E",
name = "DRL",
publisher = "ChaosForge",
license = "install\\install_license.txt",
info_after = "install\\install_after.txt",
iss_icon = "src\\icon.ico",
iss_image = "install\\install.bmp",
iss_simage = "install\\install_small.bmp",
iss_url = "http://www.chaosforge.org/",
iss_nocomp = { "wad", "mp3" },
iss_eicons = {
{ name = "DRL", exe = "drl" },
{ name = "DRL (console mode)", exe = "drl", parameters = "--console" },
{ name = "DRL Manual", file = "manual.txt" },
{ name = "ChaosForge Website", url = "http://www.chaosforge.org/" },
{ name = "DRL Website", url = "https://drl.chaosforge.org/" },
{ name = "DRL Forum", url = "http://forum.chaosforge.org/" },
},
dmg_size = 128000,
app_icon = "bin/iconfile.icns",
app_bg = "background.png",
app_fworks = {
"Frameworks/SDL.framework",
"Frameworks/SDL_image.framework",
"Frameworks/SDL_mixer.framework",
},
app_exefix = function( file )
os.execute("install_name_tool -change @rpath/SDL.framework/Versions/A/SDL @executable_path/../Frameworks/SDL.framework/Versions/A/SDL "..file )
end,
}
}
make.compile()
for i = 1, #arg do
make.command( arg[i] )
end