Skip to content

Commit 28dbe07

Browse files
authored
glslang-nihui: add new package for ncnn (#8774)
* add glslang-nihui * update xmake.lua * design for ncnn, drop unused configs * version format improvement
1 parent e1fa9c8 commit 28dbe07

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

packages/g/glslang-nihui/xmake.lua

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package("glslang-nihui")
2+
set_homepage("https://github.com/nihui/glslang/")
3+
set_description("nihui's fork of KhronosGroup/glslang for C++14 compatibility. This package is designed for Tencent/ncnn.")
4+
set_license("Apache-2.0")
5+
6+
add_urls("https://github.com/nihui/glslang.git")
7+
8+
add_versions("2025.09.16", "8cd77a808d0bffa442ae9462d5e3a8141892ba5a")
9+
add_versions("2025.05.03", "a9ac7d5f307e5db5b8c4fbf904bdba8fca6283bc")
10+
11+
if is_plat("wasm") then
12+
add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
13+
end
14+
15+
add_deps("cmake")
16+
if is_plat("linux", "bsd") then
17+
add_syslinks("pthread")
18+
end
19+
20+
on_load(function (package)
21+
package:add("links", "glslang", "glslang-default-resource-limits")
22+
end)
23+
24+
on_install(function (package)
25+
-- glslang will add a debug lib postfix for win32 platform, disable this to fix compilation issues under windows
26+
io.replace("CMakeLists.txt", 'set(CMAKE_DEBUG_POSTFIX "d")', [[
27+
message(WARNING "Disabled CMake Debug Postfix for xmake package generation")
28+
]], {plain = true})
29+
30+
if package:is_plat("wasm") then
31+
-- wasm-ld doesn't support --no-undefined
32+
io.replace("CMakeLists.txt", [[add_link_options("-Wl,--no-undefined")]], "", {plain = true})
33+
end
34+
35+
local configs = {
36+
"-DGLSLANG_TESTS=OFF",
37+
"-DBUILD_EXTERNAL=OFF",
38+
"-DENABLE_PCH=OFF",
39+
"-DENABLE_GLSLANG_BINARIES=OFF",
40+
"-DENABLE_SPVREMAPPER=OFF",
41+
"-DENABLE_OPT=OFF",
42+
"-DENABLE_HLSL=OFF",
43+
"-DENABLE_EXCEPTIONS=OFF",
44+
"-DENABLE_RTTI=OFF"
45+
}
46+
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
47+
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
48+
49+
import("package.tools.cmake").install(package, configs)
50+
51+
os.cp("glslang/MachineIndependent/**.h", package:installdir("include", "glslang", "MachineIndependent"))
52+
os.cp("glslang/Include/**.h", package:installdir("include", "glslang", "Include"))
53+
end)
54+
55+
on_test(function (package)
56+
assert(package:has_cxxfuncs("ShInitialize", {configs = {languages = "c++11"}, includes = "glslang/Public/ShaderLang.h"}))
57+
end)

0 commit comments

Comments
 (0)