-
Notifications
You must be signed in to change notification settings - Fork 1
/
make.luau
100 lines (74 loc) · 2.59 KB
/
make.luau
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
-- MIT License | Copyright (c) 2023-2024 Latte Softworks <https://latte.to>
local fs = require("@lune/fs")
local process = require("@lune/process")
local LuneUtils = require("lib/libraries/LuneUtils")
local Log = LuneUtils.Log
local StringUtils = LuneUtils.StringUtils
local CommandUtils = LuneUtils.CommandUtils
local Run = LuneUtils.Run
local Version = require("lib/data/Version")
local CodegenHeader = [[
--!nolint
--!nocheck
--!native
--!optimize 2
--[[
Wax - A Fast Runtime-Based Lua 5.1x+/Luau Project Bundler, Using Roblox Models and Module-Require Semantics
MIT License | Copyright (c) 2023-2024 Latte Softworks <https://latte.to>
Wax Version: ]] .. Version .. [=[
]]
------------------------------------------------------------------------------------------------------
]=]
local BuildFlags = {
["build-standalone-wine"] = false
}
for _, BuildFlag in process.args do
if BuildFlags[BuildFlag] ~= nil then
BuildFlags[BuildFlag] = true
end
end
local CodegenHeaderExtraLines = StringUtils.LineCount(CodegenHeader) - 1
CommandUtils.CheckCommands({"lune", "rojo", "darklua"})
local function WriteFile(path: string, contents: string)
Log.Info(`Writing to "{path}"..`)
fs.writeFile(path, contents)
end
local function WriteDir(path: string)
Log.Info(`Creating directory at "{path}"..`)
fs.writeDir(path)
end
local function RemoveDir(path: string)
Log.Info(`Removing directory at "{path}"..`)
fs.removeDir(path)
end
-- Start build process
--[[
if fs.isDir("build") then
Log.Info("Removing old `build` directory..")
fs.removeDir("build")
end
]]
if not fs.isDir("build") then
WriteDir("build")
end
local function HandleRun(...)
local Result = Run(...)
if not Result.ok then
RemoveDir("build")
process.exit(1)
end
end
HandleRun("lune", {"run", "wax", "bundle", "output=build/wax.dbg.luau", `extra-offset-lines={CodegenHeaderExtraLines}`, "ci-mode=true"})
HandleRun("lune", {"run", "wax", "bundle", "output=build/wax.luau", "minify=true", "ci-mode=true"})
Log.Info("(Adding CodegenHeader)")
WriteFile("build/wax.dbg.luau", CodegenHeader .. fs.readFile("build/wax.dbg.luau"))
WriteFile("build/wax.luau", CodegenHeader .. fs.readFile("build/wax.luau"))
Log.Info("Building standalone Wax binary")
HandleRun("lune", {"build", "build/wax.luau"})
-- For cross-compilation to Windows from Unix
if BuildFlags["build-standalone-wine"] then
Log.Info("Cross-building standalone Wax binary for Windows (via Wine on Unix)")
HandleRun("wine", {"lune", "build", "build/wax.luau"})
end
print()
Log.Info(`++++++++ Finished build target ++++++++`)