Repository navigation
Expand file tree
/
Copy pathxmake.lua
More file actions
148 lines (120 loc) · 4.33 KB
/
Copy pathxmake.lua
File metadata and controls
148 lines (120 loc) · 4.33 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
-- stylua: ignore start
add_rules("mode.debug", "mode.release")
-- easy-args
package("easy-args")
set_urls("https://github.com/gouwsxander/easy-args.git")
add_versions("0.0.1", "1b776957e13200a8d0d192dc909c46672baeb065")
on_install(function(package)
os.cp("includes/*.h", package:installdir("include"))
end)
package_end()
add_requires("libsdl3 3.2.16")
add_requires("easy-args 0.0.1")
if is_plat("linux") then
set_toolset("cc", "gcc")
set_toolset("ar", "gcc")
set_toolset("ld", "gcc")
set_toolset("sh", "gcc")
elseif is_plat("macosx") then
set_toolset("cc", "clang")
set_toolset("ar", "clang")
set_toolset("ld", "clang")
set_toolset("sh", "clang")
elseif is_plat("mingw") then
set_toolset("cc", "i686-w64-mingw32-gcc")
set_toolset("ar", "i686-w64-mingw32-gcc")
set_toolset("ld", "i686-w64-mingw32-gcc")
set_toolset("sh", "i686-w64-mingw32-gcc")
end
function set_rules(is_shared)
if is_mode("debug") then
set_symbols("debug")
set_optimize("none")
add_defines("HE_DEBUG")
elseif is_mode("release") then
set_policy("build.optimization.lto", true)
--set_strip(true)
is_shared = false
if not is_shared then
set_symbols("hidden")
end
set_fpmodels("fast")
set_optimize("aggressive")
end
end
target("HateEngineRuntime")
set_languages("c99")
set_warnings("pedantic")
set_kind("binary")
add_files("src/**.c")
add_includedirs("src", "deps")
add_packages("libsdl3", "easy-args")
-- set_rundir("$(projectdir)")
set_rules(false)
--print(config.mode)
set_runargs("--game-lib", "example-Dev")
add_links("m")
add_defines("HE_FS_SDL3", "HE_WS_SDL3")
add_defines("HE_MEM_TRACK", "HE_MEM_TRACK_TRACE")
if is_plat("mingw") then
add_ldflags("-mcrtdll=msvcrt-os", { force = true })
end
--add_ldflags("-Wl,-gc-sections -ffunction-sections")
after_build(function(target)
p = path.join(target:targetdir(), "assets")
if not os.exists(p) then
os.ln(
"$(projectdir)/examples/assets",
path.join(target:targetdir(), "assets"),
{ force = true, symbolic = true }
)
end
-- local os = import("core.base.os")
end)
on_load(function(target)
-- os.exec("python instrumentor.py src build/instrumented_src")
-- print("Hello, World!")
-- local file = io.open("$(projectdir)/src/tesoeueouteou.c", "w")
-- if file then
-- -- Write data to file with native lua interface, does not support formatting, no line breaks, does not support built-in variables
-- file:write("hello xmake\n")
-- -- Write data to file with xmake extended interface, support formatting, no line breaks, no built-in variables
-- file:writef("hello %s\n", "xmake")
-- -- Use xmake extended formatted parameters to write to one line, with line breaks, and support for built-in variables
-- file:print("hello %s and $(buildir)", "xmake")
-- -- Write a line using the xmake extended formatted arguments, no line breaks, and support for built-in variables
-- file:printf("hello %s and $(buildir) \n", "xmake")
-- -- Close the file
-- file:close()
-- end
end)
function declare_exmaple(name, ...)
target("example-" .. name)
set_languages("c99")
set_warnings("pedantic")
set_kind("shared")
add_includedirs("include")
set_rules(true)
set_prefixname("")
if is_plat("mingw") then
add_shflags("-mcrtdll=msvcrt-os", { force = true })
end
add_files(...)
-- Normal run command: "xmake run Dev"
target(name)
set_kind("phony")
set_default(false)
set_rundir("$(projectdir)/build/linux/x86_64/release")
add_deps("HateEngineRuntime")
on_run(function(target)
import("core.project.project")
local runtime = project.target("HateEngineRuntime")
local olddir = os.cd(path.directory(runtime:targetfile()))
os.execv(runtime:targetfile(), {"--game-lib", "example-" .. name})
os.cd(olddir)
end)
end
declare_exmaple("Dev", "examples/dev.c")
declare_exmaple("Signal", "examples/signal.c")
declare_exmaple("RenderServer", "examples/render_server.c")
declare_exmaple("InputEvent", "examples/input_event.c")