Skip to content

Commit

Permalink
vulkan-hpp: update to v1.2.281, fix MSVC bug (#3720)
Browse files Browse the repository at this point in the history
* Add a config providing a workaround to avoid a MSVC bug while compiling vulkan-hpp as modules

* Update vulkan-hpp to v1.2.281

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

---------

Co-authored-by: c8ef <[email protected]>
  • Loading branch information
vspefs and c8ef authored May 6, 2024
1 parent b53e00d commit f3e196f
Showing 1 changed file with 40 additions and 24 deletions.
64 changes: 40 additions & 24 deletions packages/v/vulkan-hpp/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ package("vulkan-hpp")
add_versions("v1.3.268", "d2134fefe22279595aee73752099022222468a60")
add_versions("v1.3.272", "e621db07719c0c1c738ad39ef400737a750bb23a")
add_versions("v1.3.275", "1a24b015830c116632a0723f3ccfd1f06009ce12")
add_versions("v1.3.276", "d4b36b82236e052a5e6e4cea5fe7967d5b565ebc")
add_versions("v1.3.277", "c5c1994f79298543af93d7956b654bdefdfbdd26")
add_versions("v1.3.278", "29723f90a127ff08d9099855378162f04b4ffddd")
add_versions("v1.3.279", "6fb8def27290f8b87d7835457a9c68190aed9a9a")
add_versions("v1.3.280", "e35acfe75215116029298aebf681170559a4fe6a")
add_versions("v1.3.281", "88d508b32f207ba85b37fe22fe3732322d1c248d")

add_configs("modules", {description = "Build with C++20 modules support.", default = false, type = "boolean"})
add_configs("msvc_modules", {description = "If 'modules' enabled, and you wish to use MSVC on the package, enable this to avoid a known bug of MSVC.", default = false, type = "boolean"})

on_load(function (package)
if not package:config("modules") then
Expand All @@ -30,8 +37,8 @@ package("vulkan-hpp")
end
end)


on_install("windows|x86", "windows|x64", "linux", "macosx", "mingw", "android", "iphoneos", function (package)
-- TODO: add android, windows|x86, mingw|i386 target
on_install("windows|x64", "linux", "macosx", "mingw|x86_64", "iphoneos", function (package)
local arch_prev
local plat_prev
if (package:is_plat("mingw") or package:is_cross()) and package.plat_set then
Expand All @@ -56,32 +63,41 @@ package("vulkan-hpp")
os.cp("Vulkan-Headers/include", package:installdir())
os.cp("vulkan/*.hpp", package:installdir(path.join("include", "vulkan")))
else
io.writefile("xmake.lua", [[
target("vulkan-hpp")
set_kind("static")
set_languages("c++20")
add_headerfiles("Vulkan-Headers/include/(**.h)")
add_headerfiles("Vulkan/(**.h)")
add_headerfiles("Vulkan-Headers/include/(**.hpp)")
add_headerfiles("Vulkan/(**.hpp)")
add_includedirs("Vulkan")
add_includedirs("Vulkan-Headers/include")
add_files("Vulkan/vulkan.cppm", {public = true})
]])
if package:config("msvc_modules") then
io.writefile("xmake.lua", [[
target("vulkan-hpp")
set_kind("moduleonly")
set_languages("c++20")
set_toolchains("msvc")
add_cxflags("/EHsc")
add_headerfiles("Vulkan-Headers/include/(**.h)")
add_headerfiles("Vulkan/(**.h)")
add_headerfiles("Vulkan-Headers/include/(**.hpp)")
add_headerfiles("Vulkan/(**.hpp)")
add_includedirs("Vulkan")
add_includedirs("Vulkan-Headers/include")
add_files("Vulkan/vulkan.cppm")
add_defines("VULKAN_HPP_NO_SMART_HANDLE")
]])
else
io.writefile("xmake.lua", [[
target("vulkan-hpp")
set_kind("static")
set_languages("c++20")
add_headerfiles("Vulkan-Headers/include/(**.h)")
add_headerfiles("Vulkan/(**.h)")
add_headerfiles("Vulkan-Headers/include/(**.hpp)")
add_headerfiles("Vulkan/(**.hpp)")
add_includedirs("Vulkan")
add_includedirs("Vulkan-Headers/include")
add_files("Vulkan/vulkan.cppm", {public = true})
]])
end
local configs = {}
import("package.tools.xmake").install(package, configs)
end
end)

on_test(function (package)
assert(package:check_cxxsnippets({test = [[
void test() {
vk::ApplicationInfo ai;
ai.pApplicationName = "Test";
ai.applicationVersion = VK_MAKE_API_VERSION(1,0,0,0);
ai.pEngineName = "Test";
ai.engineVersion = VK_MAKE_API_VERSION(1,0,0,0);
ai.apiVersion = VK_API_VERSION_1_0;
}
]]}, {includes = "vulkan/vulkan.hpp", configs = {languages = "c++14"} }))
assert(package:has_cxxincludes("vulkan/vulkan.hpp", {configs = {languages = "c++14"}}))
end)

0 comments on commit f3e196f

Please sign in to comment.