Repository navigation
Expand file tree
/
Copy pathxmake.lua
More file actions
240 lines (220 loc) · 10.2 KB
/
Copy pathxmake.lua
File metadata and controls
240 lines (220 loc) · 10.2 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
add_rules("mode.debug", "mode.release")
option("levimc_repo")
set_default("https://github.com/LiteLDev/xmake-repo.git")
set_showmenu(true)
set_description("Set the levimc-repo path or url")
option_end()
option("debug_symbols")
set_default(true)
set_showmenu(true)
set_description("Generate full PDB symbols for local crash diagnosis (keeps Release optimization)")
option_end()
option("target_type")
set_default("client")
set_showmenu(true)
set_values("server", "client")
option_end()
-- Optional local override; the default reviewed runtime input is versioned with the tools.
option("oreui_hbui")
set_showmenu(true)
set_description("Optional installed game data/gui/dist/hbui override")
option_end()
rule("lholo.oreui.package")
-- The native packer must run first: it owns DLL and native manifest output.
add_deps("@levibuildscript/modpacker")
before_build(function (target)
import("tools.oreui.package").prepare()
end)
after_build(function (target)
local package_dir = path.join(os.projectdir(), "bin", target:name())
os.mkdir(package_dir)
os.cp(path.join(os.projectdir(), "LICENSE"), path.join(package_dir, "LICENSE"))
import("tools.oreui.package").assemble()
end)
rule_end()
add_repositories("levimc-repo " .. (get_config("levimc_repo") or "https://github.com/LiteLDev/xmake-repo.git"))
add_requires("levilamina 26.60.0", {configs = {target_type = get_config("target_type") or "client"}})
add_requires("levibuildscript")
add_requires("imgui v1.91.9", {configs = {shared = false, win32 = true, dx11 = true, no_demo_windows = true}})
add_requires("minhook", {configs = {shared = false}})
add_requires("zlib")
if not has_config("vs_runtime") then
set_runtimes("MD")
end
-- LeviLamina 26.60 is built with clang-cl (LLVM 22); the generated Minecraft
-- headers rely on the clang frontend, so the mod must use the same toolchain.
set_toolchains("clang-cl")
-- The JSON files are the only translation sources. xmake scans this directory
-- on every project load and writes transient resource/registry files under
-- build/; adding a new locale JSON therefore registers it on the next build
-- without a Python script or a checked-in generated file.
rule("lholo.i18n.resources")
on_load(function(target)
local language_files = os.files("src/i18n/lang/*.json")
if #language_files == 0 then
raise("no language JSON files found in src/i18n/lang")
end
table.sort(language_files)
local has_default_language = false
local manifest_dir = path.join(os.projectdir(), "build", "generated", "i18n")
local manifest = path.join(manifest_dir, "Languages.rc")
local registry = path.join(manifest_dir, "LanguageRegistry.generated.h")
local lines = {
"// GENERATED by xmake.lua; do not edit.",
"#pragma code_page(65001)",
""
}
local registry_lines = {
"// GENERATED by xmake.lua; do not edit.",
"#pragma once",
"",
"#include <array>",
"#include <string_view>",
"",
"namespace lholo::i18n::generated {",
"",
"struct LanguageResource {",
" std::string_view code;",
" wchar_t const* resourceName;",
"};",
"",
"inline constexpr std::array<LanguageResource, " .. #language_files .. "> kLanguageResources{{"
}
local identifiers = {}
for _, language_file in ipairs(language_files) do
local language_code = path.basename(language_file)
if not language_code:match("^[%a][%w]*_[%a][%w]*$") then
raise("invalid language filename (expected xx_YY.json): " .. language_file)
end
if language_code == "zh_CN" then
has_default_language = true
end
local resource_code = language_code:upper():gsub("[^%w]", "_")
local identifier = "LHOLO_LANG_" .. resource_code
if identifiers[identifier] then
raise("language resource ID collision: " .. identifier)
end
identifiers[identifier] = true
local absolute_path = path.unix(path.absolute(language_file))
table.insert(lines, identifier .. " RCDATA \"" .. absolute_path .. "\"")
-- rc.exe embeds the JSON bytes, but xmake only sees Languages.rc as
-- its input. Change the manifest when a translation file changes.
table.insert(lines, "// " .. language_code .. " " .. hash.md5(language_file))
table.insert(
registry_lines,
" {\"" .. language_code .. "\", L\"" .. identifier .. "\"},"
)
end
if not has_default_language then
raise("default language file is missing: src/i18n/lang/zh_CN.json")
end
table.insert(lines, "")
table.insert(registry_lines, "}};")
table.insert(registry_lines, "")
table.insert(registry_lines, "} // namespace lholo::i18n::generated")
local content = table.concat(lines, "\n")
local escaped_manifest = path.unix(path.absolute(manifest)):gsub("'", "''")
local escaped_registry = path.unix(path.absolute(registry)):gsub("'", "''")
local registry_content = table.concat(registry_lines, "\n")
local powershell = "$manifest = '" .. escaped_manifest .. "'\n"
.. "$registry = '" .. escaped_registry .. "'\n"
.. "$content = @'\n" .. content .. "\n'@\n"
.. "$registryContent = @'\n" .. registry_content .. "\n'@\n"
.. "$directory = Split-Path -Parent $manifest\n"
.. "New-Item -ItemType Directory -Force -Path $directory | Out-Null\n"
.. "if (!(Test-Path -LiteralPath $manifest) -or [System.IO.File]::ReadAllText($manifest) -cne $content) { [System.IO.File]::WriteAllText($manifest, $content, [System.Text.UTF8Encoding]::new($false)) }\n"
.. "if (!(Test-Path -LiteralPath $registry) -or [System.IO.File]::ReadAllText($registry) -cne $registryContent) { [System.IO.File]::WriteAllText($registry, $registryContent, [System.Text.UTF8Encoding]::new($false)) }\n"
os.vrunv("powershell", {"-NoProfile", "-NonInteractive", "-Command", powershell})
target:add("files", manifest)
end)
rule_end()
target("LHolo")
if has_config("debug_symbols") then
set_symbols("debug")
set_strip("none")
-- /DEBUG otherwise changes the linker's release optimization defaults.
add_shflags("/DEBUG:FULL", "/OPT:REF", "/OPT:ICF", {force = true})
end
add_rules("lholo.i18n.resources")
add_rules("@levibuildscript/linkrule")
add_rules("@levibuildscript/modpacker", {modVersion = "26.60.0"})
add_rules("lholo.oreui.package")
add_shflags("/DELAYLOAD:bedrock_runtime.dll", {force = true})
add_cxflags(
"/utf-8",
"/W4",
"/w44265",
"/w44289",
"/w44296",
"/w45263",
"/w44738",
"/w45204"
)
add_cxflags(
"/EHs",
"-Wno-microsoft-cast",
"-Wno-invalid-offsetof",
"-Wno-c++2b-extensions",
"-Wno-microsoft-include",
"-Wno-overloaded-virtual",
"-Wno-ignored-qualifiers",
"-Wno-missing-field-initializers",
"-Wno-potentially-evaluated-expression",
"-Wno-pragma-system-header-outside-header",
{tools = {"clang_cl"}}
)
add_defines("NOMINMAX", "UNICODE")
add_syslinks("user32", "ole32", "shell32", "d3d11", "d3d12", "dxgi", "delayimp")
add_packages("levilamina", "imgui", "minhook", "zlib")
set_kind("shared")
set_languages("c++20")
add_files("src/**.cpp")
add_includedirs("src")
target("LHoloLogicTests")
add_rules("lholo.i18n.resources")
set_kind("binary")
set_languages("c++20")
set_default(false)
add_includedirs("src")
add_files("src/i18n/**.cpp")
add_files("src/input/ViewMoveBasis.cpp", "src/input/MaterialHudPageRequest.cpp")
add_files("src/projection/core/ProjectionLayoutRules.cpp")
add_files("src/projection/mesh/ProjectionTransparentMeshData.cpp")
add_files("src/projection/correction/StairShapeComparison.cpp")
add_files("src/projection/runtime/ProjectionProgress.cpp")
add_files("src/place/PlacementState.cpp")
add_files("src/settings/SettingsStore.cpp")
add_files("src/structure/StructureSession.cpp")
add_files("src/structure/StructureReadQueue.cpp")
add_files("src/structure/StructureTransform.cpp", "src/structure/TaskComposer.cpp", "src/tasks/**.cpp")
add_files("src/structure/IndependentTaskFiles.cpp", "src/structure/TaskProjectionView.cpp")
add_files("src/structure/StructureUiState.cpp")
add_files("src/structure/java_to_bedrock/JavaTextComponent.cpp")
add_files("src/ui/HotkeyFormat.cpp")
add_files("src/ui/MaterialFormat.cpp", "src/ui/hud/HudContent.cpp", "src/ui/hud/editor/HudEditor.cpp")
add_files("src/oreui/CaptureProtocol.cpp", "src/structure/capture/CaptureActions.cpp")
add_files("src/oreui/TransformProtocol.cpp", "src/structure/TransformActions.cpp")
add_files("src/oreui/TaskProtocol.cpp")
add_files("src/oreui/PreviewProtocol.cpp")
add_files("src/oreui/StructureWriteProtocol.cpp")
add_files("src/app/TaskActions.cpp")
add_files("src/app/StructureWriteActions.cpp")
add_files("src/structure/StructurePaths.cpp")
add_files("src/oreui/RenderSettingsProtocol.cpp", "src/app/RenderSettingsActions.cpp")
add_files("src/oreui/SettingsProtocol.cpp", "src/app/SettingsActions.cpp", "src/input/HotkeyCapture.cpp")
add_files("src/ui/FileDialog.cpp", "src/ui/StructureFilePicker.cpp")
add_files("tests/logic/**.cpp")
add_cxflags("/utf-8")
add_syslinks("user32", "ole32", "shell32")
add_packages("levilamina", "zlib")
target("LHoloStructureBenchmark")
set_kind("binary")
set_languages("c++20")
set_default(false)
add_includedirs("src")
add_files("tests/bench/StructureMemoryBenchmark.cpp")
add_files("src/structure/StructureTransform.cpp", "src/structure/TaskProjectionView.cpp", "src/structure/IndependentTaskFiles.cpp")
add_packages("zlib")
add_cxflags("/utf-8")
add_defines("NOMINMAX")
add_syslinks("psapi")