Skip to content

Commit 3128822

Browse files
authored
Update xmake.lua
1 parent d8439d9 commit 3128822

1 file changed

Lines changed: 29 additions & 9 deletions

File tree

packages/b/bgfx/xmake.lua

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
package("bgfx")
2-
32
set_homepage("https://bkaradzic.github.io/bgfx/")
43
set_description("Cross-platform, graphics API agnostic, “Bring Your Own Engine/Framework” style rendering library")
54
set_license("BSD-2-Clause")
@@ -10,6 +9,8 @@ package("bgfx")
109
add_versions("8674", "f42134876038027667ef7e47c9a612dca1051ef2")
1110
add_versions("8752", "61c770b0f5f57cf10547107974099e604358bf69")
1211
add_versions("9392", "34deeda1094ade66bc48215d3a276e7cce547c0c")
12+
add_patches("<=8752", "patches/cstdint.patch")
13+
add_patches(">=9392", "patches/9392/apple_clang_overloaded.patch")
1314

1415
add_resources("7816", "bx", "https://github.com/bkaradzic/bx.git", "51f25ba638b9cb35eb2ac078f842a4bed0746d56")
1516
add_resources("8203", "bx", "https://github.com/bkaradzic/bx.git", "b9501348c596b68e5e655a8308df5c55f61ecd80")
@@ -25,7 +26,7 @@ package("bgfx")
2526
if is_plat("windows") then
2627
add_syslinks("user32", "gdi32", "psapi")
2728
add_includedirs("include", "include/compat/msvc")
28-
add_cxxflags("/Zc:__cplusplus")
29+
add_cxxflags("/Zc:__cplusplus", {tools = {"msvc", "cl", "clang_cl", "clang-cl"}})
2930
elseif is_plat("macosx") then
3031
add_frameworks("Metal", "QuartzCore", "Cocoa", "IOKit")
3132
elseif is_plat("iphoneos") then
@@ -38,11 +39,11 @@ package("bgfx")
3839
add_deps("genie")
3940

4041
on_load("windows", "macosx", "linux", "iphoneos", function (package)
41-
local suffix = package:debug() and "Debug" or "Release"
42+
local suffix = package:is_debug() and "Debug" or "Release"
4243
for _, lib in ipairs({"bgfx", "bimg", "bx"}) do
4344
package:add("links", lib .. suffix)
4445
end
45-
package:add("defines", "BX_CONFIG_DEBUG=" .. (package:debug() and "1" or "0"))
46+
package:add("defines", "BX_CONFIG_DEBUG=" .. (package:is_debug() and "1" or "0"))
4647
end)
4748

4849
on_install("windows|native", "macosx", "linux", "iphoneos", function (package)
@@ -60,16 +61,20 @@ package("bgfx")
6061
os.trycp(path.join(bxdir, "include", "*"), package:installdir("include"))
6162
os.trycp(path.join(bimgdir, "include", "*"), package:installdir("include"))
6263

63-
local mode = package:debug() and "Debug" or "Release"
64+
local mode = package:is_debug() and "Debug" or "Release"
6465
if package:is_plat("windows") then
6566
import("package.tools.msbuild")
6667
import("core.tool.toolchain")
6768

6869
local msvc = toolchain.load("msvc")
70+
local vs = msvc:config("vs")
71+
if tonumber(vs) >= 2022 then
72+
vs = "2022"
73+
end
6974
if package:has_runtime("MD", "MDd") then
7075
table.insert(args, "--with-dynamic-runtime")
7176
end
72-
table.insert(args, "vs" .. msvc:config("vs"))
77+
table.insert(args, "vs" .. vs)
7378

7479
local envs = msbuild.buildenvs(package)
7580
envs.BX_DIR = bxdir
@@ -80,7 +85,7 @@ package("bgfx")
8085
table.insert(configs, "/p:Configuration=" .. mode)
8186
table.insert(configs, "/p:Platform=" .. (package:is_arch("x64") and "x64" or "Win32"))
8287
table.insert(configs, "bgfx.sln")
83-
os.cd(format(".build/projects/vs%s", msvc:config("vs")))
88+
os.cd(format(".build/projects/vs%s", vs))
8489
msbuild.build(package, configs)
8590

8691
os.trycp("../../win*_vs*/bin/*.lib|*example*", package:installdir("lib"))
@@ -117,7 +122,15 @@ package("bgfx")
117122
local envs = make.buildenvs(package)
118123
envs.BX_DIR = bxdir
119124
envs.BIMG_DIR = bimgdir
125+
126+
if package:version() and package:version():ge("9392") and package:is_plat("iphoneos") then
127+
io.replace("scripts/bgfx.lua", 'configuration { "osx*" }', 'configuration { "ios*" }\n\t\tbuildoptions { "-x objective-c++" }\n\tconfiguration { "osx*" }', {plain = true})
128+
end
120129
os.vrunv(genie, args, {envs = envs})
130+
131+
if package:is_plat("linux") and os.isdir(".build/projects/gmake-linux-gcc") then
132+
configs[2] = ".build/projects/gmake-linux-gcc"
133+
end
121134
make.build(package, configs)
122135

123136
if package:is_plat("macosx", "iphoneos") then
@@ -134,10 +147,17 @@ package("bgfx")
134147
end)
135148

136149
on_test(function (package)
137-
assert(package:check_cxxsnippets({test = [[
150+
local test_new = [[
138151
void test() {
139152
bgfx::Init init;
140153
bgfx::init(init);
141154
}
142-
]]}, {configs = {languages = "c++17"}, includes = "bgfx/bgfx.h"}))
155+
]]
156+
local test_old = [[
157+
void test() {
158+
bgfx::init();
159+
}
160+
]]
161+
assert(package:check_cxxsnippets({test = test_new}, {configs = {languages = "c++17"}, includes = "bgfx/bgfx.h"}) or
162+
package:check_cxxsnippets({test = test_old}, {configs = {languages = "c++17"}, includes = "bgfx/bgfx.h"}))
143163
end)

0 commit comments

Comments
 (0)