-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.luau
115 lines (95 loc) · 2.33 KB
/
compile.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
--!strict
-- There's issues with running this file from windows so idk
local fs = require "@lune/fs"
local process = require "@lune/process"
local stdio = require "@lune/stdio"
local task = require "@lune/task"
local waiter = require "./Modules/Waiter"(task.wait)
local colour = stdio.color
local green = colour "green"
local red = colour "red"
local reset = colour "reset"
local normalCores = {}
local libraryCores = {
"Fusion/init.luau",
"Red/init.luau",
"Load.luau",
}
local otherCores = {}
local plugins = {}
local normalCoresDir = "./luau"
local normalPluginsDir = "./terrain plugins"
local outputDir = "./processed"
for _, core in ipairs(fs.readDir(normalCoresDir)) do
table.insert(
-- normalCores should be ones with numbers
if string.match(core, "%d+%.lua") then normalCores else otherCores,
core
)
end
for _, core in ipairs(fs.readDir(normalPluginsDir)) do
table.insert(plugins, core)
end
local pluginsDir = "./Client deployer" -- not here but.. ya get the idea
local function processCores(
scripts: { string },
startDir: string,
endDir: string,
config: "lines" | "dense",
libraries: boolean?
)
local configFile = `{config}.json5`
local w = waiter(#scripts)
for i, core in ipairs(scripts) do
local newCore = if libraries
then `{10000000 + i}.lua`
else string.gsub(core, "%.luau$", ".lua")
task.spawn(function()
local cmd = process.spawn("darklua", {
"process",
"-c",
configFile,
`./{startDir}/{core}`,
`{endDir}/{newCore}`,
})
print(
if cmd.ok
then `{green}Processed {core}{reset}`
else `{red}Error processing {core}: {cmd.stderr}{reset}`
)
w.finish()
end)
end
w.wait()
end
local args: { { any } } = {
{ libraryCores, "Libraries", outputDir, "dense", true },
{
plugins,
"terrain plugins",
`{pluginsDir}/staging/BuiltInPlugins/terrain`,
"lines",
},
{ normalCores, "luau", outputDir, "dense" },
{ otherCores, "luau", outputDir, "lines" },
}
local w = waiter(#args)
for _, arg in ipairs(args) do
task.spawn(function()
processCores(unpack(arg))
w.finish()
end)
end
if #process.args == 0 then
return
end
w.wait()
local totalBytes = 0
for _, core in ipairs(fs.readDir(outputDir)) do
local file = fs.readFile(`{outputDir}/{core}`)
if not string.match(core, "%d+%.lua") then
continue
end
totalBytes += #file
end
print(`Total: {totalBytes / 1000} kb`)