generated from iAndyHD3/xmake-gd-mod-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
xmake.lua
118 lines (98 loc) · 3.33 KB
/
xmake.lua
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
add_rules("mode.release")
--equivalent to
--if is_mode("release") then
-- set_symbols("hidden")
-- set_optimize("fastest")
-- set_strip("all")
--end
add_rules("mode.releasedbg")
--equivalent to
--if is_mode("releasedbg") then
-- set_symbols("debug")
-- set_optimize("fastest")
-- set_strip("all")
--end
set_allowedarchs("windows|x86") --allow only windows x86
set_defaultarchs("windows|x86") --set default windows x86
set_allowedmodes("release", "releasedbg") --allow only Release and RelWithDebInfo
set_languages("c++23") --set c++20
--create options with loop and array
options_table = {"cppath", "gdpath", "gdexec"}
for i = 1, #options_table do
option(options_table[i])
set_default("")
set_showmenu(true)
option_end()
end
add_requires("fmt")
includes("**/xmake.lua") -- recursively add files through pattern matching
target("image2gd") --dll name and target name
set_default(true)
set_kind("shared")
add_packages("fmt")
add_deps("cocos-headers")
add_deps("mat-dash")
add_deps("gd.h")
set_rundir("/bin")
add_files("src/*.cpp")
add_syslinks("Comdlg32") --nfd
add_syslinks("Gdi32") --clipboard, windows bitmap
--add minhook manually here since it doesnt seem to work when added with target
add_includedirs(
"libs/minhook/include",
"libs/stb",
"libs/geometrize",
"libs/nfd/include"
)
add_files(
"libs/minhook/src/**.c",
"libs/geometrize/**.cpp",
"libs/nfd/src/**.cpp",
"libs/nfd/src/**.c"
)
--this will run when xmake run gdmod is called
on_run(function (target)
local function isempty(s) return s == nil or s == '' or s == "" end
local function notempty(s) return isempty(s) == false end
--print("cppath: $(cppath) | gdpath: $(gdpath) | gdexec: $(gdexec)")
--copy dll
if notempty("$(cppath)") then
if os.exists("$(cppath)") then
cprint(string.format("${green}%s${clear} -> ${green}%s${clear}", target:targetfile(), "$(cppath)"))
os.cp(target:targetfile(), "$(cppath)")
else
cprint("${red}error:${clear} the copy path (cppath) does not exist, set the paths in cfg.txt and run `xmake f --import=cfg.txt`")
os.exit()
end
else
cprint("${red}error:${clear} the copy path (cppath) is not set, set the paths in cfg.txt and run `xmake f --import=cfg.txt`")
os.exit()
end
--run game
if notempty("$(gdexec") then
if notempty("$(gdpath)") then
if os.isfile("$(gdpath)\\$(gdexec)") then
if os.exists("$(gdpath)") then
os.cd("$(gdpath)")
cprint("${green}$(gdpath)\\$(gdexec)${clear} -> CTRL+C or close the game to exit")
os.run("$(gdexec)")
else
cprint("${red}error:${clear} the geometry dash path (gdpath) does not exist, set the paths in cfg.txt and run `xmake f --import=cfg.txt`")
os.exit()
end
else
cprint("${red}error:${clear} the geometry dash executable path (gdexec) does not exist, set the paths in cfg.txt and run `xmake f --import=cfg.txt`")
os.exit()
end
else
cprint("${red}error:${clear} the geometry dash path (gdpath) is not set, set the paths in cfg.txt and run `xmake f --import=cfg.txt`")
os.exit()
end
else
cprint("${red}error:${clear} the geometry dash executable name (gdexec) is not set, set the paths in cfg.txt and run `xmake f --import=cfg.txt`")
os.exit()
end
end)
target_end() --target_end() is optional
--xmake website (recommended) https://xmake.io
-- xmake f --import=cfg.txt