-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxmake.lua
117 lines (100 loc) · 4.39 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
-- We should use `get_config("ue4ssRoot")` instead of `os.projectdir()` or `$(projectdir)`.
-- This is because os.projectdir() will return a higher parent dir
-- when UE4SS is sub-moduled/`include("UE4SS")` in another xmake project.
set_config("ue4ssRoot", os.scriptdir())
-- All non-binary outputs are written to the Intermediates dir.
set_config("buildir", "Intermediates")
-- Any lua modules in this directory can be imported in the script scope by using
-- /modules/my_module.lua import("my_module")
-- /modules/rules/my_module.lua import("rules.my_module")
add_moduledirs("tools/xmakescripts/modules")
-- Load the build_rules file into the global scope.
includes("tools/xmakescripts/rules/build_rules.lua")
-- Generate the mode rules.
local modes = generate_compilation_modes()
-- Enter the existing ue4ss.base rule scope in order to add all xxx__xxx__xxx modes
-- to the ue4ss.base rule.
rule("ue4ss.base")
for _, mode in ipairs(modes) do
-- add_rules() expects the format `mode.Game__Shipping__Win64`
add_deps("mode."..mode)
end
rule_end()
-- Add the ue4ss.core rule to all targets within the UE4SS repository.
add_rules("ue4ss.core")
-- Restrict the compilation modes/configs.
-- These restrictions are inherited upstream and downstream.
-- Any project that `includes("UE4SS")` will inherit these global restrictions.
set_allowedplats("windows", "linux")
set_allowedarchs("x64", "x86_64", "x86_64-unknown-linux-gnu", "arm64")
set_allowedmodes(modes)
option("zig")
set_showmenu(true)
set_description("Use the Zig compiler.")
set_default(false)
option_end()
toolchain("zigcross")
if is_host("windows") then
set_toolset("cc", os.scriptdir() .. "/tools/zig/zig-cc.bat")
set_toolset("cxx", os.scriptdir() .. "/tools/zig/zig-c++.bat")
set_toolset("ld", os.scriptdir() .. "/tools/zig/zig-c++.bat")
set_toolset("sh", os.scriptdir() .. "/tools/zig/zig-c++.bat")
set_toolset("ar", os.scriptdir() .. "/tools/zig/zig-ar.bat")
else
set_toolset("cc", os.scriptdir() .. "/tools/zig/zig-cc")
set_toolset("cxx", os.scriptdir() .. "/tools/zig/zig-c++")
set_toolset("ld", os.scriptdir() .. "/tools/zig/zig-c++")
set_toolset("sh", os.scriptdir() .. "/tools/zig/zig-c++")
set_toolset("ar", os.scriptdir() .. "/tools/zig/zig-ar")
end
add_cxflags("-fexperimental-library")
add_cxflags("-fno-delete-null-pointer-checks")
add_cxflags("-gdwarf")
add_cxflags("-fno-sanitize=undefined") -- can also use O2 to avoid this, but I'd prefer getting clear binary for now
add_cxflags("-stdlib=libc++")
-- add_cxflags("-fcommon")
-- add_cxflags("-Wno-deprecated-declarations")
-- add_cxflags("-fms-extensions")
-- add_cxflags("-fno-exceptions")
-- add_cxflags("-std=c++20")
add_shflags("-z", "lazy")
toolchain_end()
toolchain("gcc-aarch64-linux-gnu")
add_cxflags("-fexperimental-library")
add_cxflags("-fno-delete-null-pointer-checks")
add_cxflags("-gdwarf")
add_cxflags("-fno-sanitize=undefined") -- can also use O2 to avoid this, but I'd prefer getting clear binary for now
add_cxflags("-fcommon")
add_cxflags("-Wno-deprecated-declarations")
add_shflags("-z", "lazy")
toolchain_end()
-- Override the `xmake install` behavior for all targets.
-- Targets can re-override the on_install() function to implement custom installation behavior.
on_install(function(target) end)
includes("deps")
includes("UE4SS")
-- includes("UVTD")
-- TODO: Remove this before the next release. It only exists to maintain backwards compat
-- warnings for older mod templates.
set_config("scriptsRoot", path.join(os.scriptdir(), "tools/xmakescripts"))
-- Global initialization for UE4SS, run it in the topmost xmake.lua file.
function ue4ss_init()
if is_plat("linux") then
if has_config("zig") then
-- add_requires("zigcc", {system = false})
-- set_toolchains("zigcross@zigcc", "rust")
set_toolchains("zigcross", "rust")
if is_host("windows") then
set_arch("x86_64-unknown-linux-gnu")
add_rcflags("-C", "linker=" .. os.scriptdir() .. "/tools/zig/zig-cc.bat", {force = true})
end
else
set_toolchains("clang", "rust")
end
set_defaultmode("Game__Shipping__Linux")
end
if is_plat("windows") then
set_defaultmode("Game__Shipping__Win64")
end
end
ue4ss_init()