diff --git a/recipes/nvjpeg2k/bld.bat b/recipes/nvjpeg2k/bld.bat new file mode 100644 index 0000000000000..a6c10d48a1a5c --- /dev/null +++ b/recipes/nvjpeg2k/bld.bat @@ -0,0 +1,17 @@ + +:: Relocate CUDA major specific libraries to single prefix layout + +for /f "tokens=1 delims=." %%a in ("%cuda_compiler_version%") do ( + set "CUDA_MAJOR=%%a" + break +) + +move lib lib.backup +move lib.backup\%CUDA_MAJOR% lib +del lib.backup + +if not exist %PREFIX% mkdir %PREFIX% + +move lib\*.lib %LIBRARY_LIB% +move lib\*.dll %LIBRARY_BIN% +move include\* %LIBRARY_INC% diff --git a/recipes/nvjpeg2k/build.sh b/recipes/nvjpeg2k/build.sh new file mode 100644 index 0000000000000..4c0a2ee6faf51 --- /dev/null +++ b/recipes/nvjpeg2k/build.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Relocate CUDA major specific libraries to single prefix layout +export CUDA_MAJOR=${cuda_compiler_version%%.*} +mv -v lib lib.backup +mv -v lib.backup/${CUDA_MAJOR} lib +rm -rv lib.backup + +# Install to conda style directories +[[ -d lib64 ]] && mv lib64 lib +mkdir -p ${PREFIX}/lib +[[ -d pkg-config ]] && mv pkg-config ${PREFIX}/lib/pkgconfig +[[ -d "$PREFIX/lib/pkgconfig" ]] && sed -E -i "s|cudaroot=.+|cudaroot=$PREFIX|g" $PREFIX/lib/pkgconfig/nvjpeg*.pc + +[[ ${target_platform} == "linux-64" ]] && targetsDir="targets/x86_64-linux" +[[ ${target_platform} == "linux-ppc64le" ]] && targetsDir="targets/ppc64le-linux" +[[ ${target_platform} == "linux-aarch64" ]] && targetsDir="targets/sbsa-linux" +# [[ ${target_platform} == "linux-aarch64" ]] && targetsDir="targets/aarch64-linux" + +for i in `ls`; do + [[ $i == "build_env_setup.sh" ]] && continue + [[ $i == "conda_build.sh" ]] && continue + [[ $i == "metadata_conda_debug.yaml" ]] && continue + if [[ $i == "lib" ]] || [[ $i == "include" ]]; then + # Headers and libraries are installed to targetsDir + mkdir -p ${PREFIX}/${targetsDir} + mkdir -p ${PREFIX}/$i + cp -rv $i ${PREFIX}/${targetsDir} + if [[ $i == "lib" ]]; then + for j in "$i"/*.so*; do + # Shared libraries are symlinked in $PREFIX/lib + ln -s ${PREFIX}/${targetsDir}/$j ${PREFIX}/$j + + if [[ $j =~ \.so\. ]]; then + patchelf --set-rpath '$ORIGIN' --force-rpath ${PREFIX}/${targetsDir}/$j + fi + done + fi + else + # Put all other files in targetsDir + mkdir -p ${PREFIX}/${targetsDir}/${PKG_NAME} + cp -rv $i ${PREFIX}/${targetsDir}/${PKG_NAME} + fi +done diff --git a/recipes/nvjpeg2k/conda_build_config.yaml b/recipes/nvjpeg2k/conda_build_config.yaml new file mode 100644 index 0000000000000..9c06e62c3e14a --- /dev/null +++ b/recipes/nvjpeg2k/conda_build_config.yaml @@ -0,0 +1,4 @@ +arm_variant_type: # [aarch64] + - sbsa # [aarch64] + - tegra # [false] + diff --git a/recipes/nvjpeg2k/meta.yaml b/recipes/nvjpeg2k/meta.yaml new file mode 100644 index 0000000000000..8f0318939f114 --- /dev/null +++ b/recipes/nvjpeg2k/meta.yaml @@ -0,0 +1,135 @@ +{% set name = "libnvjpeg2k" %} +{% set version = "0.8.0.38" %} +{% set platform = "linux-x86_64" %} # [linux64] +{% set platform = "linux-ppc64le" %} # [ppc64le] +{% set platform = "linux-sbsa" %} # [aarch64 and arm_variant_type == "sbsa"] +{% set platform = "linux-aarch64" %} # [aarch64 and arm_variant_type == "tegra"] +{% set platform = "windows-x86_64" %} # [win] +{% set target_name = "x86_64-linux" %} # [linux64] +{% set target_name = "ppc64le-linux" %} # [ppc64le] +{% set target_name = "sbsa-linux" %} # [aarch64 and arm_variant_type == "sbsa"] +{% set target_name = "aarch64-linux" %} # [aarch64 and arm_variant_type == "tegra"] +{% set target_name = "x64" %} # [win] +{% set extension = "tar.xz" %} # [not win] +{% set extension = "zip" %} # [win] +{% set cuda_compiler_version = cuda_compiler_version | default("None") %} + +package: + name: libnvjpeg2k-split + version: {{ version }} + +source: + url: https://developer.download.nvidia.com/compute/nvjpeg2000/redist/libnvjpeg_2k/{{ platform }}/libnvjpeg_2k-{{ platform }}-{{ version }}-archive.{{ extension }} + sha256: f0b4f0ab9e19579c547e96ce189c6a93731f662898751a88d62e3caa59472367 # [linux64] + sha256: 03a568305989b25be6def7d860b2519577ebef1538c703de0ad086fa2314a1e0 # [aarch64 and arm_variant_type == "sbsa"] + sha256: dac4f1d0c088c22155067b781142dc27ec1d3ced68b99d2180fcd1fcf02fe19e # [aarch64 and arm_variant_type == "tegra"] + sha256: feabb2f4108805b251f44b0561b194a24041d01207b272a3aa42a664e938e5d4 # [win] + +build: + number: 0 + skip: true # [osx or ppc64le] + skip: true # [cuda_compiler_version in (None, "None")] + +requirements: + build: + - patchelf <0.18.0 # [linux] + +outputs: + + - name: libnvjpeg2k{{ version.split(".")[0] }} + build: + run_exports: + - {{ pin_subpackage("libnvjpeg2k" ~ version.split(".")[0]) }} + files: + - lib/libnvjpeg2k.so.* # [linux] + - targets/{{ target_name }}/lib/libnvjpeg2k.so.* # [linux] + - Library\bin\nvjpeg2k*.dll # [win] + requirements: + build: + - {{ compiler("c") }} + - {{ compiler("cuda") }} + - {{ compiler("cxx") }} + - {{ stdlib("c") }} + - arm-variant * {{ arm_variant_type }} # [aarch64] + host: + - cuda-version {{ cuda_compiler_version }} + run_constrained: + - arm-variant * {{ arm_variant_type }} # [aarch64] + test: + requires: + - patchelf # [linux] + files: + - test-rpath.sh + commands: + - test -L $PREFIX/lib/libnvjpeg2k.so.{{ version.split(".")[0] }} # [linux] + - test -L $PREFIX/lib/libnvjpeg2k.so.{{ version }} # [linux] + - test -L $PREFIX/targets/{{ target_name }}/lib/libnvjpeg2k.so.{{ version.split(".")[0] }} # [linux] + - test -f $PREFIX/targets/{{ target_name }}/lib/libnvjpeg2k.so.{{ version }} # [linux] + # - bash test-rpath.sh # [linux] + - if not exist %LIBRARY_BIN%\nvjpeg2k_{{ version.split(".")[0] }}.dll exit 1 # [win] + + - name: libnvjpeg2k-dev + build: + run_exports: + - {{ pin_subpackage("libnvjpeg2k" ~ version.split(".")[0]) }} + files: + - lib/libnvjpeg2k.so # [linux] + # - lib/pkgconfig/nvjpeg*.pc # [linux] + - targets/{{ target_name }}/lib/libnvjpeg2k.so # [linux] + # - targets/{{ target_name }}/lib/stubs/libnvjpeg2k.so # [linux] + - targets/{{ target_name }}/include/nvjpeg* # [linux] + - Library\include # [win] + - Library\lib\nvjpeg.lib # [win] + requirements: + build: + - arm-variant * {{ arm_variant_type }} # [aarch64] + host: + - cuda-version {{ cuda_compiler_version }} + - {{ pin_subpackage("libnvjpeg2k" ~ version.split(".")[0], exact=True) }} + run: + - {{ pin_subpackage("libnvjpeg2k" ~ version.split(".")[0], exact=True) }} + run_constrained: + - arm-variant * {{ arm_variant_type }} # [aarch64] + test: + commands: + - test -L $PREFIX/lib/libnvjpeg2k.so # [linux] + # - test -f $PREFIX/lib/pkgconfig/nvjpeg*.pc # [linux] + - test -f $PREFIX/targets/{{ target_name }}/include/nvjpeg2k_version.h # [linux] + - test -f $PREFIX/targets/{{ target_name }}/include/nvjpeg2k.h # [linux] + - test -L $PREFIX/targets/{{ target_name }}/lib/libnvjpeg2k.so # [linux] + # - test -f $PREFIX/targets/{{ target_name }}/lib/stubs/libnvjpeg2k.so # [linux] + - if not exist %LIBRARY_INC%\nvjpeg2k_version.h exit 1 # [win] + - if not exist %LIBRARY_INC%\nvjpeg2k.h exit 1 # [win] + - if not exist %LIBRARY_LIB%\nvjpeg2k.lib exit 1 # [win] + + - name: libnvjpeg2k-static + build: + skip: True # [not linux] + files: + - targets/{{ target_name }}/lib/libnvjpeg2k_static.a # [linux] + requirements: + build: + - arm-variant * {{ arm_variant_type }} # [aarch64] + host: + - cuda-version {{ cuda_compiler_version }} + run: + - {{ pin_subpackage("libnvjpeg2k-dev", exact=True) }} + run_constrained: + - arm-variant * {{ arm_variant_type }} # [aarch64] + test: + commands: + - test -f $PREFIX/targets/{{ target_name }}/lib/libnvjpeg2k_static.a # [linux] + +about: + home: https://docs.nvidia.com/cuda/nvjpeg2000/ + license_file: LICENSE + license: LicenseRef-NVIDIA-End-User-License-Agreement + license_url: https://docs.nvidia.com/cuda/eula/index.html + summary: nvJPEG2000 native runtime libraries + description: | + nvJPEG2000 native runtime libraries + doc_url: https://docs.nvidia.com/cuda/nvjpeg2000/ + +extra: + recipe-maintainers: + - conda-forge/cuda diff --git a/recipes/nvjpeg2k/test-rpath.sh b/recipes/nvjpeg2k/test-rpath.sh new file mode 100644 index 0000000000000..16ad3a71a373b --- /dev/null +++ b/recipes/nvjpeg2k/test-rpath.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +[[ ${target_platform} == "linux-64" ]] && targetsDir="targets/x86_64-linux" +[[ ${target_platform} == "linux-ppc64le" ]] && targetsDir="targets/ppc64le-linux" +[[ ${target_platform} == "linux-aarch64" ]] && targetsDir="targets/sbsa-linux" + +errors="" + +for lib in `find ${PREFIX}/${targetsDir}/lib -type f`; do + [[ $lib =~ \.so ]] || continue + + rpath=$(patchelf --print-rpath $lib) + echo "$lib rpath: $rpath" + if [[ $rpath != "\$ORIGIN" ]]; then + errors+="$lib\n" + elif [[ $(objdump -x ${lib} | grep "PATH") == *"RUNPATH"* ]]; then + errors+="$lib\n" + fi +done + +if [[ $errors ]]; then + echo "The following libraries were found with an unexpected RPATH:" + echo -e "$errors" + + exit 1 +else + exit 0 +fi