Repository navigation
Expand file tree
/
Copy pathxmake.lua
More file actions
240 lines (215 loc) · 7.39 KB
/
Copy pathxmake.lua
File metadata and controls
240 lines (215 loc) · 7.39 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
set_project("USB_Base")
add_rules("mode.release", "mode.debug")
set_languages("c++20")
add_requireconfs("lvgl", {
configs = {
cmake_args = {
"-DLV_USE_DRAW_SW_ASM=OFF", -- Fixes the "lv_blend_helium" error
"-DLV_USE_DRAW_VG_LITE=OFF",
"-DLV_USE_DRAW_PXP=OFF"
}
}
})
if is_mode("debug") then
add_defines("DEBUG", "_DEBUG")
set_symbols("debug")
set_optimize("none")
end
if is_mode("release") then
set_symbols("hidden")
set_strip ("all")
set_optimize("fastest")
add_cxflags("-O3", "-DNDEBUG")
if not is_plat("android") and is_arch("x86_64") then
add_cxflags("-msse4.2", "-mpclmul", {force = true})
end
end
-- Put outputs in a predictable place
set_targetdir("bin/$(plat)/$(mode)")
add_requires("libsdl3")
add_requires("rtmidi")
---- ---- Root-scope requirements (OK here; NOT inside target) ----
---- Linux uses system packages via pkg-config;
if is_plat("android") then
add_requires("libsdl3", {configs = {shared = false}})
end
--
set_languages("c++20")
target("lvgl_lib")
set_kind("static")
set_languages("c99") -- FORCE C language for these files
-- Adjust path to match your folder structure: 'external/lvgl'
add_files("external/lvgl/src/**.c")
-- Exclude ASM files to fix the previous "helium" crash
remove_files("external/lvgl/src/**.S")
add_includedirs("external/lvgl")
add_includedirs(".") -- To find lv_conf.h
add_defines("LV_CONF_INCLUDE_SIMPLE")
set_languages("c++20")
target("USB_Base")
if is_plat("android") then
set_kind("shared")
else
set_kind("binary")
end
add_deps("lvgl_lib")
--
add_includedirs(".")
add_includedirs("external/lvgl")
add_defines("LV_CONF_INCLUDE_SIMPLE")
add_defines("LV_COLOR_DEPTH=32")
add_packages("libsdl3")
add_packages("rtmidi")
-- Your sources
add_includedirs("source", {public = true})
--
-- -- Define groups (patterns are relative to rootdir)
add_filegroups("Source Files", { rootdir = "source", files = {"**.cpp"}, group = "Source Files" })
add_filegroups("Header Files", { rootdir = "source", files = {"**.h", "**.hpp"}, group = "Header Files" })
--
-- -- Add those groups to the target
add_files("source/**.cpp", { group = "Source Files" })
add_headerfiles("source/**.h", "source/**.hpp", { group = "Header Files" })
-- -- -------------------- Linux --------------------
-- if is_plat("linux") then
--
-- add_defines("FMT_HEADER_ONLY")
--
-- -- pthread/dl and (optionally) the LLD linker
-- add_syslinks("pthread", "dl")
-- add_ldflags("-fuse-ld=lld", {tools = {"cc", "cxx", "ld"}, force = false})
--
-- -- use system packages via pkg-config (declared at root)
-- if has_package("pkgconfig::sdl3") then
-- add_packages("pkgconfig::sdl3")
-- else
-- print(false, "libsdl3-dev not found (pkg-config sdl3). Install it.")
-- end
-- if has_package("pkgconfig::vulkan") then
-- add_packages("pkgconfig::vulkan")
-- else
-- print(false, "libvulkan-dev not found (pkg-config vulkan). Install it.")
-- end
-- if has_package("pkgconfig::shaderc") then
-- add_packages("pkgconfig::shaderc") -- optional
-- end
--
-- -- loader looks next to the binary for .so files you place there
-- add_rpathdirs("$ORIGIN")
--
-- -- After build, copy runtime content beside the binary
-- after_build(function (t)
-- local out = t:targetdir()
--
-- -- copy your data folders (creates out/assets and out/shaders)
-- os.trycp(path.join(os.projectdir(), "assets"), out)
-- os.trycp(path.join(os.projectdir(), "shaders"), out)
--
-- end)
-- end
--
-- -- ========= Android (NDK agnostic) =========
-- if is_plat("android") then
-- -- We already set_kind("shared") above
-- -- Vulkan rule added links/defines/syslinks
-- set_basename("main")
--
-- add_links("vulkan")
--
-- -- Prefer xrepo sdl3 if available; else fall back to vendored per-ABI .so
-- local use_xrepo = has_config("use_xrepo_sdl3") and has_package("libsdl3")
-- if use_xrepo then
-- add_packages("libsdl3")
-- add_packages("shaderc")
-- else
-- print(false, "libsdl3 not found (pkg-config sdl3). Install it.")
-- end
--
-- --local proj = os.projectdir()
-- --local androidDir = path.join(proj,"android-app")
-- --local appDir = path.join(androidDir,"app")
--
-- --os.cp(path.join(os.projectdir(),"shaders"), path.join(os.projectdir(),out))
--
-- -- Copy assets/shaders next to libmain.so (useful for manual pushing/tests)
-- after_build(function (t)
-- local out = t:targetdir()
-- os.trycp(path.join(os.projectdir(), "assets"), out)
-- os.trycp(path.join(os.projectdir(), "shaders"), out)
-- end)
-- end
--
-- -- -------------------- Windows (MSVC, vendored SDL) --------------------
if is_plat("windows") then
set_toolchains("msvc")
add_cxflags("/MP")
add_ldflags("/DEBUG")
--
-- -- Vulkan via LunarG SDK (headers + import lib)
-- local vksdk = os.getenv("VULKAN_SDK")
-- if vksdk and #vksdk > 0 then
-- add_includedirs(path.join(vksdk, "Include"), {public = true})
-- add_includedirs(path.join(vksdk, "Include/shaderc"))
-- add_linkdirs(path.join(vksdk, "Lib"))
-- add_links("vulkan-1")
-- else
-- raise("VULKAN_SDK not set. Install LunarG Vulkan SDK.")
-- end
--
-- -- SDL3 from your repo: external/SDL
--local sdl = path.join(os.projectdir(), "external", "SDL")
--add_includedirs(path.join(sdl, "include"), {public = true})
-- --
--sub = ""
--do
-- arch = (get_config("arch") or ""):lower()
-- if arch == "x64" or arch == "x86_64" then
-- sub = "x64"
-- print("platform : x64")
-- elseif arch == "arm64" then
-- sub = "arm64"
-- print("platform : arm64")
-- else
-- sub = "x86"
-- print("platform : x86")
-- end
--
-- add_linkdirs(path.join(sdl, "lib", sub))
-- add_links("SDL3") -- dynamic; ship SDL3.dll
--
--end
-- --
-- -- -- Optional: shaderc from Vulkan SDK if present
-- -- if vksdk and os.isfile(path.join(vksdk, "Lib", "shaderc_shared.lib")) then
-- -- add_linkdirs(path.join(vksdk, "Lib"))
-- -- add_links("shaderc_shared")
-- -- end
-- --
---- After build, drop DLLs beside the .exe
--after_build(function (t)
-- local out = t:targetdir()
-- arch = (get_config("arch") or ""):lower()
-- if arch == "x64" or arch == "x86_64" then
-- sub = "x64"
-- print("platform : x64")
-- elseif arch == "arm64" then
-- sub = "arm64"
-- print("platform : arm64")
-- else
-- sub = "x86"
-- print("platform : x86")
-- end
-- os.cp(path.join(sdl, "lib", sub, "SDL3.dll"), path.join(os.projectdir(),out))
-- -- os.cp(path.join(os.projectdir(),"assets"), path.join(os.projectdir(),out))
-- -- os.cp(path.join(os.projectdir(),"shaders"), path.join(os.projectdir(),out))
--end)
end
--
-- -- Output name
if is_plat("windows") then
set_filename("usb_base.exe")
-- elseif is_plat("linux") then
-- set_filename("usb_base.exe") -- ELF on Linux, no extension
-- elseif is_plat("android") then
-- set_filename("libmain.so")
end