-
Notifications
You must be signed in to change notification settings - Fork 8
/
xmake.lua
131 lines (116 loc) · 3.85 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
119
120
121
122
123
124
125
126
127
128
129
130
131
-- Project setup
set_project("altv-js-module")
set_languages("cxx20")
add_rules("mode.debug")
add_rules("mode.release")
if is_os("windows") then
add_toolchains("msvc")
-- add_cxxflags("/MP")
elseif is_os("linux") then
add_toolchains("gcc")
end
-- Options
option("static-client")
set_description("Build client as static library")
set_default(false)
set_showmenu(true)
option("sdk-path")
set_description("Path to the C++ SDK to use")
set_default("deps/cpp-sdk")
set_showmenu(true)
option("auto-update-deps")
set_description("Automatically update dependencies")
set_default(true)
set_showmenu(true)
option("module-version")
set_description("Module version")
set_default("internal")
set_showmenu(true)
-- Rules
rule("generate-bindings")
on_load(function(target)
local out = os.iorun("node tools/generate-bindings.js ..")
if out ~= "" and is_mode("debug") then
print(out)
end
target:add("files", "build/BindingsMap.cpp")
end)
rule("update-deps")
on_load(function(target)
if not has_config("auto-update-deps") then return end
import("core.project.config")
os.iorun("node tools/update-deps.js " .. target:name() .. " " .. tostring(config.get("mode")))
end)
-- Targets
target("cpp-sdk")
set_kind("headeronly")
add_headerfiles("$(sdk-path)/**.h")
on_config(function(target)
local oldDir = os.cd("$(sdk-path)")
local out, err = os.iorun("git rev-parse --short HEAD")
if err ~= "" then
raise("Failed to get cpp-sdk git commit hash: " .. err)
return
end
io.writefile("version/version.h", "#define ALT_SDK_VERSION \"" .. string.trim(out) .. "\"")
os.cd(oldDir)
end)
target("shared")
set_kind("headeronly")
add_headerfiles("shared/src/**.h")
add_deps("cpp-sdk")
target("server")
set_basename("js-module-v2")
set_kind("shared")
add_files("server/src/**.cpp", "shared/src/**.cpp")
add_headerfiles("server/src/**.h")
add_includedirs(
"server/src", "server/deps", "server/deps/nodejs/include", "server/deps/nodejs/deps/uv/include", "server/deps/nodejs/deps/v8/include",
"shared/src",
"deps", "deps/cpp-sdk",
"build"
)
add_deps("shared")
add_rules("generate-bindings", "update-deps")
add_defines("ALT_SERVER_API", "NODE_WANT_INTERNALS=1", "HAVE_OPENSSL=1", "HAVE_INSPECTOR=1")
add_defines("MODULE_VERSION=\"$(module-version)\"")
if is_os("linux") then
add_links("node")
add_linkdirs("$(scriptdir)/server/deps/nodejs/lib")
else
if is_mode("debug") then add_linkdirs("server/deps/nodejs/lib/Debug")
else add_linkdirs("server/deps/nodejs/lib/Release") end
add_links("libnode")
add_links("dbghelp", "winmm", "shlwapi", "advapi32")
end
set_runtimes("MD")
set_symbols("debug")
target("client")
set_basename("js-client-v2")
if has_config("static-client") then
set_kind("static")
else
set_kind("shared")
add_defines("ALTV_JSV2_SHARED")
end
add_files("client/src/**.cpp", "shared/src/**.cpp")
add_headerfiles("client/src/**.h")
add_includedirs(
"client/src", "client/deps", "client/deps/v8/include",
"shared/src",
"deps", "deps/cpp-sdk",
"build"
)
add_deps("shared")
add_rules("generate-bindings", "update-deps")
add_defines("ALT_CLIENT_API", "V8_COMPRESS_POINTERS=1", "V8_31BIT_SMIS_ON_64BIT_ARCH=1", "V8_IMMINENT_DEPRECATION_WARNINGS=1")
add_defines("MODULE_VERSION=\"$(module-version)\"")
if is_mode("debug") then
add_linkdirs("client/deps/v8/lib/Debug")
else
add_linkdirs("client/deps/v8/lib/Release")
end
add_links("dbghelp", "winmm", "shlwapi", "advapi32")
add_links("v8_monolith")
set_runtimes("MD")
set_symbols("debug")