From a1212c93cabaa9c5c36c1ffdb4bddd59fdf31e43 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Fri, 10 May 2024 22:16:48 +0200 Subject: [PATCH] [shader-slang] Update, fix (#38602) Fix osx. Closes https://github.com/microsoft/vcpkg/issues/38595. Enable install for static library linkage triplets. (osx and linux CI!) Fixes #29445. Enable arm64 linux and windows. Install all binaries and headers from upstream's package. Install non-DLL shared objects to `lib`. Update. Simplify. Facilitate future updates. --- ports/shader-slang/portfile.cmake | 216 ++++++++++++++++++------------ ports/shader-slang/vcpkg.json | 4 +- scripts/ci.baseline.txt | 1 + versions/baseline.json | 2 +- versions/s-/shader-slang.json | 5 + 5 files changed, 137 insertions(+), 91 deletions(-) diff --git a/ports/shader-slang/portfile.cmake b/ports/shader-slang/portfile.cmake index 8297087b87..6bc5b4fbb8 100644 --- a/ports/shader-slang/portfile.cmake +++ b/ports/shader-slang/portfile.cmake @@ -1,70 +1,75 @@ vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY) -if (VCPKG_TARGET_IS_WINDOWS) - set(SLANG_EXE_SUFFIX ".exe") - set(SLANG_LIB_PREFIX "") - set(SLANG_LIB_SUFFIX ".lib") - set(SLANG_DYNLIB_SUFFIX ".dll") - if (VCPKG_TARGET_ARCHITECTURE MATCHES "x64") - vcpkg_download_distfile( - ARCHIVE - URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-win64.zip" - FILENAME "slang-${VERSION}-win64.zip" - SHA512 3d6153d9cd8234d68d91273b97cfd66167e55bf3c526490603c79797aea4f5af839cbfdce29532da8c0e77cb9e6451a5823d40b98162fb53fffcbc5d18b0f841 - ) - set(SLANG_BIN_PATH "bin/windows-x64/release") - elseif (VCPKG_TARGET_ARCHITECTURE MATCHES "x86") - vcpkg_download_distfile( - ARCHIVE - URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-win32.zip" - FILENAME "slang-${VERSION}-win32.zip" - SHA512 43992831be8f7fc954794482e947a20e421587cb999eebdd7ffb21c3fc477a660ae19c0e0a10df5331329ac46e7fdd6017fc416b6667127182ae6091b6431e6b - ) - set(SLANG_BIN_PATH "bin/windows-x86/release") - else() - message(FATAL_ERROR "Unsupported platform. Please implement me!") - endif() -elseif (VCPKG_TARGET_IS_OSX) - set(SLANG_EXE_SUFFIX "") - set(SLANG_LIB_PREFIX "lib") - set(SLANG_LIB_SUFFIX ".a") - set(SLANG_DYNLIB_SUFFIX ".dylib") - if (VCPKG_TARGET_ARCHITECTURE MATCHES "x64") - vcpkg_download_distfile( - ARCHIVE - URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-macos-x64.zip" - FILENAME "slang-${VERSION}-macos-x64.zip" - SHA512 dc3b3f18c8e80cfc12960e76978dc1acb18df6de0704c5a889713128491827e26c169a2965d598b4904647384da2eeceb63a391b62925573da5d77a060bdb890 - ) - set(SLANG_BIN_PATH "bin/macos-x64/release") - elseif (VCPKG_TARGET_ARCHITECTURE MATCHES "arm64") - vcpkg_download_distfile( - ARCHIVE - URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-macos-aarch64.zip" - FILENAME "slang-${VERSION}-macos-aarch64.zip" - SHA512 db613040ea31fa2ff8a60fec96a16704e0241774332333a704530bee309f5037d50570fc590348f22d3bc7f018a5bd3c9a10aae800a4f30f0f5e273552690863 - ) - set(SLANG_BIN_PATH "bin/macos-aarch64/release") - else() - message(FATAL_ERROR "Unsupported platform. Please implement me!") - endif() +set(key NOTFOUND) +if(VCPKG_TARGET_IS_WINDOWS) + set(key "windows-${VCPKG_TARGET_ARCHITECTURE}") +elseif(VCPKG_TARGET_IS_OSX) + set(key "macosx-${VCPKG_TARGET_ARCHITECTURE}") elseif(VCPKG_TARGET_IS_LINUX) - set(SLANG_EXE_SUFFIX "") - set(SLANG_LIB_PREFIX "lib") - set(SLANG_LIB_SUFFIX ".a") - set(SLANG_DYNLIB_SUFFIX ".so") - if (VCPKG_TARGET_ARCHITECTURE MATCHES "x64") - vcpkg_download_distfile( - ARCHIVE - URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-linux-x86_64.tar.gz" - FILENAME "slang-${VERSION}-linux-x86_64.tar.gz" - SHA512 817e3c5ae9fa249c54b1f411877f4742a019aa27b63bfb06b726b721cd86973b4ebe481bf62192bb7380d092c57cbd8e2abc932a7dbacd06811b6afb856c428d - ) - set(SLANG_BIN_PATH "bin/linux-x64/release") - else() - message(FATAL_ERROR "Unsupported platform. Please implement me!") - endif() -else() + set(key "linux-${VCPKG_TARGET_ARCHITECTURE}") +endif() +string(REPLACE "arm64" "aarch64" key "${key}") + +set(ARCHIVE NOTFOUND) +# For convenient updates, use +# vcpkg install shader-slang --cmake-args=-DVCPKG_SHADER_SLANG_UPDATE=1 +if(key STREQUAL "windows-x86" OR VCPKG_SHADER_SLANG_UPDATE) + vcpkg_download_distfile( + ARCHIVE + URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-win32.zip" + FILENAME "slang-${VERSION}-win32.zip" + SHA512 b8fa6aed2fc4c7adb8c1810cfa5e655b317aebc4636e8d80e718aef25abf58bc9dc5c7c58dc9d0a375d61bed8000daa75e14d8bc11c1a7c4cd33350d698c8dd6 + ) +endif() +if(key STREQUAL "windows-x64" OR VCPKG_SHADER_SLANG_UPDATE) + vcpkg_download_distfile( + ARCHIVE + URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-win64.zip" + FILENAME "slang-${VERSION}-win64.zip" + SHA512 24d39f1f54230b7badc1e0e3b54b29a0fddbcf29c2370d2085870556529f8ee4d25d249b9dad9bead61079803061f6a7d7b126e136fcb8afe2a0ef61808f34ad + ) +endif() +if(key STREQUAL "windows-aarch64" OR VCPKG_SHADER_SLANG_UPDATE) + vcpkg_download_distfile( + ARCHIVE + URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-win-arm64.zip" + FILENAME "slang-${VERSION}-win-arm64.zip" + SHA512 0971394479f4da56b6340c1bc9b415ac1de001607ba5af0d5e3e3e95ad9a4e2fd6185603bb95fdc98e152d0a6012a5af144ba812c3af0ec1d1eb50837caad3dd + ) +endif() +if(key STREQUAL "macosx-x64" OR VCPKG_SHADER_SLANG_UPDATE) + vcpkg_download_distfile( + ARCHIVE + URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-macos-x64.zip" + FILENAME "slang-${VERSION}-macos-x64.zip" + SHA512 e546c4c3e68880f75678c061457369f2c075bdd428080c4af7fae6145be8359dff182902d412dad6c0ce3903004ca9613d791a04a209e6e16960e036585efdae + ) +endif() +if(key STREQUAL "macosx-aarch64" OR VCPKG_SHADER_SLANG_UPDATE) + vcpkg_download_distfile( + ARCHIVE + URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-macos-aarch64.zip" + FILENAME "slang-${VERSION}-macos-aarch64.zip" + SHA512 df287ec31d366d88196ce5e1a9d3fa0d0c6973ff948c8ab4e51a04d3f5af5b84a8703925a6a5b721335f2cbfcb0fb0e70eac5d084f72565fe65730ae54a758fa + ) +endif() +if(key STREQUAL "linux-x64" OR VCPKG_SHADER_SLANG_UPDATE) + vcpkg_download_distfile( + ARCHIVE + URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-linux-x86_64.zip" + FILENAME "slang-${VERSION}-linux-x86_64.zip" + SHA512 6a2360936e8c3967ebbf6a1ea8143c6e2ddf188c3057f3ecafac28550f96ba83f7269a9ef5dadc76833c78954dca298b901f63f94cbf595fb68d1138fa361f62 + ) +endif() +if(key STREQUAL "linux-aarch64" OR VCPKG_SHADER_SLANG_UPDATE) + vcpkg_download_distfile( + ARCHIVE + URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-linux-aarch64.zip" + FILENAME "slang-${VERSION}-linux-aarch64.zip" + SHA512 315a822d32093bbe133f399eb648301a3b0f3319aabe526371b8044b691e16aa826d9c81af59f1967e9d98e94d55fb5e4704cafb831fb518442755a4574d5498 + ) +endif() +if(NOT ARCHIVE) message(FATAL_ERROR "Unsupported platform. Please implement me!") endif() @@ -74,32 +79,67 @@ vcpkg_extract_source_archive( NO_REMOVE_ONE_LEVEL ) -file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/${SLANG_LIB_PREFIX}slang${SLANG_DYNLIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/bin") -file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/${SLANG_LIB_PREFIX}slang${SLANG_DYNLIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin") -file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/${SLANG_LIB_PREFIX}slang-llvm${SLANG_DYNLIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/bin") -file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/${SLANG_LIB_PREFIX}slang-llvm${SLANG_DYNLIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin") -file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/${SLANG_LIB_PREFIX}slang-glslang${SLANG_DYNLIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/bin") -file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/${SLANG_LIB_PREFIX}slang-glslang${SLANG_DYNLIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin") -file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/slangc${SLANG_EXE_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}") - -if (VCPKG_TARGET_IS_WINDOWS) - file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/${SLANG_LIB_PREFIX}slang${SLANG_LIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/lib") - file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/${SLANG_LIB_PREFIX}slang${SLANG_LIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib") - file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/gfx${SLANG_LIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/lib") - file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/gfx${SLANG_LIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib") - file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/gfx${SLANG_DYNLIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/bin") - file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/gfx${SLANG_DYNLIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin") +# https://github.com/shader-slang/slang/issues/4117 +if(NOT EXISTS "${BINDIST_PATH}/LICENSE" OR VCPKG_SHADER_SLANG_UPDATE) + vcpkg_download_distfile( + LICENSE_ARCHIVE + URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-source.zip" + FILENAME "slang-${VERSION}-source.zip" + SHA512 4c0888de421e070e8458b94e420df972c5b4fb5f3d3dc3c124b8f33f548aa47cd81d7c92c33786b492373b926263167f9ef63f8fe203e064f1f0795b38cf1570 + ) + vcpkg_extract_source_archive( + SOURCE_PATH + ARCHIVE "${LICENSE_ARCHIVE}" + NO_REMOVE_ONE_LEVEL + ) + file(COPY "${SOURCE_PATH}/LICENSE" DESTINATION "${BINDIST_PATH}") endif() -file(GLOB HEADERS "${BINDIST_PATH}/*.h") -file(INSTALL ${HEADERS} DESTINATION "${CURRENT_PACKAGES_DIR}/include") +if(VCPKG_SHADER_SLANG_UPDATE) + message(STATUS "All downloads are up-to-date.") + message(FATAL_ERROR "Stopping due to VCPKG_SHADER_SLANG_UPDATE being enabled.") +endif() -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO shader-slang/slang - REF "v${VERSION}" - SHA512 f7da1cd60418c9b0a4f302841154ac5b48f84b897f81359cbc52950dd5a2a0339a95b8cc13ad13d518a089aff3071bf52f60bcf86d29b07866c4e1c948f5ccfd - HEAD_REF master +set(SLANG_BIN_PATH "bin/${key}/release") +file(GLOB libs + "${BINDIST_PATH}/${SLANG_BIN_PATH}/*.lib" + "${BINDIST_PATH}/${SLANG_BIN_PATH}/*.dylib" + "${BINDIST_PATH}/${SLANG_BIN_PATH}/*.so" ) +file(INSTALL ${libs} DESTINATION "${CURRENT_PACKAGES_DIR}/lib") -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") +if(VCPKG_TARGET_IS_WINDOWS) + file(GLOB dlls "${BINDIST_PATH}/${SLANG_BIN_PATH}/*.dll") + file(INSTALL ${dlls} DESTINATION "${CURRENT_PACKAGES_DIR}/bin") +endif() + +if(NOT VCPKG_BUILD_TYPE) + file(INSTALL "${CURRENT_PACKAGES_DIR}/lib" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib") + if(VCPKG_TARGET_IS_WINDOWS) + file(INSTALL "${CURRENT_PACKAGES_DIR}/bin" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin") + endif() +endif() + +vcpkg_copy_tools(TOOL_NAMES slangc slangd SEARCH_DIR "${BINDIST_PATH}/${SLANG_BIN_PATH}") + +file(GLOB headers "${BINDIST_PATH}/*.h" "${BINDIST_PATH}/prelude") +file(INSTALL ${headers} DESTINATION "${CURRENT_PACKAGES_DIR}/include") + +vcpkg_install_copyright( + FILE_LIST "${BINDIST_PATH}/LICENSE" + COMMENT #[[ from README ]] [[ +The Slang code itself is under the MIT license. + +Builds of the core Slang tools depend on the following projects, either automatically or optionally, which may have their own licenses: + +* [`glslang`](https://github.com/KhronosGroup/glslang) (BSD) +* [`lz4`](https://github.com/lz4/lz4) (BSD) +* [`miniz`](https://github.com/richgel999/miniz) (MIT) +* [`spirv-headers`](https://github.com/KhronosGroup/SPIRV-Headers) (Modified MIT) +* [`spirv-tools`](https://github.com/KhronosGroup/SPIRV-Tools) (Apache 2.0) +* [`ankerl::unordered_dense::{map, set}`](https://github.com/martinus/unordered_dense) (MIT) + +Slang releases may include [slang-llvm](https://github.com/shader-slang/slang-llvm) which includes [LLVM](https://github.com/llvm/llvm-project) under the license: + +* [`llvm`](https://llvm.org/docs/DeveloperPolicy.html#new-llvm-project-license-framework) (Apache 2.0 License with LLVM exceptions) +]]) diff --git a/ports/shader-slang/vcpkg.json b/ports/shader-slang/vcpkg.json index c3d1adf58f..c1199aef1b 100644 --- a/ports/shader-slang/vcpkg.json +++ b/ports/shader-slang/vcpkg.json @@ -1,8 +1,8 @@ { "name": "shader-slang", - "version": "2024.1.7", + "version": "2024.1.12", "description": "Slang is a shading language that makes it easier to build and maintain large shader codebases in a modular and extensible fashion, while also maintaining the highest possible performance on modern GPUs and graphics APIs. Slang is based on years of collaboration between researchers at NVIDIA, Carnegie Mellon University, and Stanford.", "homepage": "https://github.com/shader-slang/slang", "license": "MIT", - "supports": "((x86 & windows) | (x64 & (windows | linux | osx)) | (arm64 & (linux | osx))) & !uwp & !static" + "supports": "((x86 & windows) | (x64 & (linux | osx | windows)) | (arm64 & (linux | osx | windows))) & !uwp" } diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index d792c31a1d..6e96f546e6 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -1035,6 +1035,7 @@ septag-sx:x64-android=fail sfml:arm-neon-android=fail sfml:arm64-android=fail sfml:x64-android=fail +shader-slang:x64-windows-static=fail shogun:arm64-windows = skip shogun:arm64-uwp = skip shogun:x64-osx = skip diff --git a/versions/baseline.json b/versions/baseline.json index 9e675e6539..2c0c62a094 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -8057,7 +8057,7 @@ "port-version": 0 }, "shader-slang": { - "baseline": "2024.1.7", + "baseline": "2024.1.12", "port-version": 0 }, "shaderc": { diff --git a/versions/s-/shader-slang.json b/versions/s-/shader-slang.json index 548f17f5b1..31946b1517 100644 --- a/versions/s-/shader-slang.json +++ b/versions/s-/shader-slang.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "5e7e8064e105e443d90fc10fb9dc05916107f489", + "version": "2024.1.12", + "port-version": 0 + }, { "git-tree": "c2c440cb10bb3987dbdf8b4332db8d34b8fc6cfc", "version": "2024.1.7",