diff --git a/recipe/bld.bat b/recipe/bld.bat new file mode 100644 index 0000000..1567080 --- /dev/null +++ b/recipe/bld.bat @@ -0,0 +1,13 @@ +echo on + +cmake %CMAKE_ARGS% ^ + -G "Ninja" ^ + -DLLVM_DIR=%LIBRARY_PREFIX%\cmake\llvm ^ + -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^ + -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^ + -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=%LIBRARY_PREFIX% ^ + -S . -B ./build +if %ERRORLEVEL% neq 0 exit 1 + +cmake --build ./build +if %ERRORLEVEL% neq 0 exit 1 diff --git a/recipe/install.bat b/recipe/install.bat new file mode 100644 index 0000000..8698147 --- /dev/null +++ b/recipe/install.bat @@ -0,0 +1,10 @@ +echo on + +cmake --install ./build --prefix %LIBRARY_PREFIX% +if %ERRORLEVEL% neq 0 exit 1 + +move %LIBRARY_BIN%\llvm-spirv.exe %LIBRARY_BIN%\llvm-spirv-%MAJOR_VERSION%.exe +if %ERRORLEVEL% neq 0 exit 1 + +mklink /h %LIBRARY_BIN%\llvm-spirv.exe %LIBRARY_BIN%\llvm-spirv-%MAJOR_VERSION%.exe +if %ERRORLEVEL% neq 0 exit 1 diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 06c5982..6f39833 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -8,6 +8,7 @@ {% else %} {% set abi_version = version.split('.')[0] %} {% endif %} +{% set library = "Library/" if win else "" %} package: name: llvm-spirv-split @@ -16,23 +17,25 @@ package: source: url: https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/v{{ version.replace("_", "-") }}.tar.gz sha256: 78a770eff24d5ffe2798479845adec4b909cbf058ddc55830ea00fa7d2c1698a + patches: + - patches/0001-Work-around-a-bug-in-the-llvm-config.patch # [win] build: number: 0 - skip: true # [not unix] requirements: build: - {{ stdlib('c') }} - {{ compiler('cxx') }} - cmake - - make + - ninja # [win] + - make # [not win] - pkg-config host: - llvmdev {{ llvm_version }}.* - llvm {{ llvm_version }}.* - spirv-headers - - spirv-tools + - spirv-tools # [not win] - zlib outputs: @@ -42,6 +45,7 @@ outputs: ignore_run_exports_from: - zlib - spirv-tools + skip: true # [win] files: - lib/libLLVMSPIRVLib.{{ abi_version }}.dylib # [osx] - lib/libLLVMSPIRVLib.so.{{ abi_version }} # [linux] @@ -68,18 +72,22 @@ outputs: - test -f ${PREFIX}/lib/libLLVMSPIRVLib.so.{{ abi_version }} # [linux] - name: libllvmspirv - script: install.sh + script: install.sh # [not win] + script: install.bat # [win] build: run_exports: - {{ pin_subpackage("libllvmspirv" ~ major) }} ignore_run_exports_from: - zlib - - spirv-tools + - spirv-tools # [not win] + script_env: + - MAJOR_VERSION={{ major }} # [win] files: - - lib/libLLVMSPIRVLib.dylib # [osx] - - lib/libLLVMSPIRVLib.so # [linux] - - lib/pkgconfig/LLVMSPIRVLib.pc - - include/LLVMSPIRVLib/ + - lib/libLLVMSPIRVLib.dylib # [osx] + - lib/libLLVMSPIRVLib.so # [linux] + - {{ library }}lib/LLVMSPIRVLib.lib # [win] + - {{ library }}lib/pkgconfig/LLVMSPIRVLib.pc + - {{ library }}include/LLVMSPIRVLib/ requirements: build: - {{ stdlib('c') }} @@ -92,23 +100,28 @@ outputs: - llvm {{ llvm_version }}.* - zlib - spirv-headers - - spirv-tools - - {{ pin_subpackage("libllvmspirv" ~ major, exact=True) }} + - spirv-tools # [not win] + - {{ pin_subpackage("libllvmspirv" ~ major, exact=True) }} # [not win] run: - - {{ pin_subpackage("libllvmspirv" ~ major, exact=True) }} + - {{ pin_subpackage("libllvmspirv" ~ major, exact=True) }} # [not win] run_constrained: - llvmdev {{ llvm_version }}.* test: commands: - - test -f ${PREFIX}/lib/libLLVMSPIRVLib${SHLIB_EXT} + - test -f ${PREFIX}/lib/libLLVMSPIRVLib${SHLIB_EXT} # [not win] + - if not exist "%LIBRARY_LIB%"\\LLVMSPIRVLib.lib exit 1 # [win] - name: llvm-spirv-{{ major }} - script: install.sh + script: install.sh # [not win] + script: install.bat # [win] build: ignore_run_exports_from: - zlib + script_env: + - MAJOR_VERSION={{ major }} # [win] files: - - bin/llvm-spirv-{{ major }} + - bin/llvm-spirv-{{ major }} # [not win] + - {{ library }}bin/llvm-spirv-{{ major }}.exe # [win] requirements: build: - {{ stdlib('c') }} @@ -121,22 +134,28 @@ outputs: - llvm {{ llvm_version }}.* - zlib - spirv-headers - - spirv-tools - - {{ pin_subpackage("libllvmspirv" ~ major, exact=True) }} + - spirv-tools # [not win] + - {{ pin_subpackage("libllvmspirv" ~ major, exact=True) }} # [not win] run: - - {{ pin_subpackage("libllvmspirv" ~ major, exact=True) }} + - {{ pin_subpackage("libllvmspirv" ~ major, exact=True) }} # [not win] test: commands: - - ${PREFIX}/bin/llvm-spirv-{{ major }} -help + - ${PREFIX}/bin/llvm-spirv-{{ major }} -help # [not win] + - '%LIBRARY_BIN%\\llvm-spirv-{{ major }}.exe -help' # [win] + - llvm-spirv-{{ major }} -help - name: llvm-spirv - script: install.sh + script: install.sh # [not win] + script: install.bat # [win] build: ignore_run_exports_from: - zlib - - spirv-tools + - spirv-tools # [not win] + script_env: + - MAJOR_VERSION={{ major }} # [win] files: - - bin/llvm-spirv + - bin/llvm-spirv # [not win] + - {{ library }}bin/llvm-spirv.exe # [win] requirements: build: - {{ stdlib('c') }} @@ -149,13 +168,14 @@ outputs: - llvm {{ llvm_version }}.* - zlib - spirv-headers - - spirv-tools + - spirv-tools # [not win] - {{ pin_subpackage("llvm-spirv-" ~ major, exact=True) }} run: - {{ pin_subpackage("llvm-spirv-" ~ major, exact=True) }} test: commands: - - ${PREFIX}/bin/llvm-spirv -help + - ${PREFIX}/bin/llvm-spirv -help # [not win] + - '%LIBRARY_BIN%\\llvm-spirv.exe -help' # [win] - llvm-spirv -help about: diff --git a/recipe/patches/0001-Work-around-a-bug-in-the-llvm-config.patch b/recipe/patches/0001-Work-around-a-bug-in-the-llvm-config.patch new file mode 100644 index 0000000..77978c8 --- /dev/null +++ b/recipe/patches/0001-Work-around-a-bug-in-the-llvm-config.patch @@ -0,0 +1,26 @@ +From 4e96cd52c7f5c695ecf3da195947874e202df870 Mon Sep 17 00:00:00 2001 +From: Yevhenii Havrylko +Date: Tue, 4 Jun 2024 23:58:29 -0400 +Subject: [PATCH] Work around a bug in the llvm config + +--- + CMakeLists.txt | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 3cb4386..0c0c9ae 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -72,6 +72,9 @@ if(LLVM_SPIRV_BUILD_EXTERNAL) + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + ++ # https://github.com/llvm/llvm-project/issues/83802 ++ include(GNUInstallDirs) ++ + if(LLVM_SPIRV_INCLUDE_TESTS) + set(LLVM_TEST_COMPONENTS + llvm-as +-- +2.40.0.windows.1 +