-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.lua
More file actions
137 lines (119 loc) · 2.84 KB
/
Copy pathutils.lua
File metadata and controls
137 lines (119 loc) · 2.84 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
function mobile()
return is_plat("iphoneos", "harmony", "android", "visionos")
end
function apple()
return is_plat("iphoneos", "macosx", "visionos")
end
function vulkandyn()
return is_plat("linux", "bsd", "android", "mingw")
end
function is_arch_alias(arch)
local matchmap = {
["x86"] = function()
return is_arch("x86", "i386")
end,
["x86_64"] = function()
return is_arch("x86_64", "x64", "amd64")
end,
["aarch64"] = function()
return is_arch("arm64-v8a", "arm64")
end,
["arm"] = function()
return is_arch("armeabi", "armv7k", "armeabi-v7a", "arm", "armv7s", "armv7")
end,
["loongarch"] = function()
return is_arch("loong64", "loongarch64")
end,
["mips64"] = function()
return is_arch("mips64", "mips64el", "mip64")
end,
["mips"] = function()
return is_arch("mips", "mipsel")
end,
}
if matchmap[arch] then
return matchmap[arch]()
else
return is_arch(arch)
end
end
function is_plat_alias(plat)
if plat == "unix" then
return not is_plat("windows", "mingw")
end
if plat == "windows" then
return is_plat("windows", "mingw")
end
if plat == "desktop" then
return not mobile()
end
if plat == "ios" then
return is_plat("iphoneos")
end
return is_plat(plat)
end
PLATFORMS = {
"unix",
"windows",
"linux",
"bsd",
"macos",
"android",
"ios",
"harmony",
"desktop",
}
ARCHITECTURES = {
"x86",
"x86_64",
"aarch64",
"arm",
"loongarch",
"mips",
"mips64",
"ppc",
"ppc64",
"riscv",
"riscv64",
}
-- platform-dependent & arch-dependent source config
-- platform: plat-$(platform_name)
-- arch: arch-$(arch_name)
function addExtFiles(config)
if config == nil then
return
end
function addExtFilesSub(type, name)
if is_plat_alias(name) and config[type .. "-" .. name] then
add_files(type .. "/" .. name .. "**.cpp")
print("Added subdirectory " .. type .. "/" .. name)
end
end
for _, plat in ipairs(PLATFORMS) do
addExtFilesSub("plat", plat)
end
function addExtFilesSub2(type, name, ismsvc)
if is_arch_alias(name) and config[type .. "-" .. name] then
if is_plat("windows", "mingw") and ismsvc then
print("Added subdirectory assembly (msvc)")
add_files(type .. "/" .. name .. "/msvc_**.asm")
else
print("Added subdirectory assembly (unix)")
add_files(type .. "/" .. name .. "/unix_**.S")
end
add_files(type .. "/" .. name .. "/**.cpp")
print("Added subdirectory " .. type .. "/" .. name)
end
end
for _, arch in ipairs(ARCHITECTURES) do
addExtFilesSub2("arch", arch, arch == "x86" or arch == "x86_64" or arch == "aarch64")
end
for _, plat in ipairs(PLATFORMS) do
for _, arch in ipairs(ARCHITECTURES) do
if is_arch_alias(arch) and is_plat_alias(plat) and config["platarch-" .. plat .. "-" .. arch] then
add_files("platarch/" .. plat .. "-" .. arch .. "/**.cpp")
print("Added subdirectory platarch-" .. plat .. "-" .. arch)
end
end
end
end