From f749b06ae7387a0da8776672e5acc2d6329c9c92 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Sat, 30 Jul 2022 10:49:21 +0200 Subject: [PATCH 01/11] remove fake variable --- recipe/meta.yaml | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 06fe228..3184745 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -1,12 +1,11 @@ -{% set name = "zstd" %} {% set version = "1.5.2" %} package: - name: {{ name|lower }}-split + name: zstd-split version: {{ version }} source: - url: https://github.com/facebook/{{ name }}/archive/v{{ version }}.tar.gz + url: https://github.com/facebook/zstd/archive/v{{ version }}.tar.gz sha256: f7de13462f7a82c29ab865820149e778cbfe01087b3a55b5332707abf9db4a6e patches: - windows-cmake-pkg-config.patch # [win] @@ -44,21 +43,21 @@ outputs: commands: - zstd -be -i5 - - test -f ${PREFIX}/include/{{ name }}.h # [unix] - - test ! -f ${PREFIX}/lib/lib{{ name }}.a # [unix] - - test -f ${PREFIX}/lib/lib{{ name }}.so # [linux] - - test -f ${PREFIX}/lib/lib{{ name }}.dylib # [osx] + - test -f ${PREFIX}/include/zstd.h # [unix] + - test ! -f ${PREFIX}/lib/libzstd.a # [unix] + - test -f ${PREFIX}/lib/libzstd.so # [linux] + - test -f ${PREFIX}/lib/libzstd.dylib # [osx] - - if not exist %LIBRARY_INC%\{{ name }}.h exit 1 # [win] - - if not exist %LIBRARY_BIN%\lib{{ name }}.dll exit 1 # [win] - - if not exist %LIBRARY_LIB%\lib{{ name }}.lib exit 1 # [win] - - if exist %LIBRARY_LIB%\lib{{ name }}_static.lib exit 1 # [win] + - if not exist %LIBRARY_INC%\zstd.h exit 1 # [win] + - if not exist %LIBRARY_BIN%\libzstd.dll exit 1 # [win] + - if not exist %LIBRARY_LIB%\libzstd.lib exit 1 # [win] + - if exist %LIBRARY_LIB%\libzstd_static.lib exit 1 # [win] - export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig # [unix] - set "PKG_CONFIG_PATH=%LIBRARY_LIB%\pkgconfig" # [win] - - test -f ${PREFIX}/lib/pkgconfig/lib{{ name }}.pc # [unix] - - if not exist %LIBRARY_LIB%\pkgconfig\lib{{ name }}.pc exit 1 # [win] - - pkg-config --cflags lib{{ name }} + - test -f ${PREFIX}/lib/pkgconfig/libzstd.pc # [unix] + - if not exist %LIBRARY_LIB%\pkgconfig\libzstd.pc exit 1 # [win] + - pkg-config --cflags libzstd - name: zstd-static script: install.sh # [unix] @@ -78,7 +77,7 @@ outputs: - {{ pin_subpackage('zstd', exact=True) }} test: commands: - - test -f ${PREFIX}/lib/lib{{ name }}.a # [unix] + - test -f ${PREFIX}/lib/libzstd.a # [unix] about: home: http://www.zstd.net From 87e308f1c78f45fd1ad4351fae1fcd1b3f36bce4 Mon Sep 17 00:00:00 2001 From: Mark Harfouche Date: Sat, 30 Jul 2022 11:38:35 +0100 Subject: [PATCH 02/11] try to specify static links at compile time --- recipe/install.sh | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/recipe/install.sh b/recipe/install.sh index a7d53fb..2fa36b5 100644 --- a/recipe/install.sh +++ b/recipe/install.sh @@ -21,25 +21,22 @@ if [[ ${HOST} =~ .*linux.* ]]; then _CMAKE_EXTRA_CONFIG+=(-DRT_LIBRARIES=${LIBRT}) fi -pushd build/cmake +if [[ "$PKG_NAME" == *static ]]; then + ZSTD_BUILD_STATIC=ON +else + ZSTD_BUILD_STATIC=OFF +fi +pushd build/cmake FULL_AR=`which ${AR}` cmake -GNinja \ -DCMAKE_INSTALL_PREFIX="${PREFIX}" \ -DCMAKE_INSTALL_LIBDIR="lib" \ -DCMAKE_PREFIX_PATH="${PREFIX}" \ -DCMAKE_AR=${FULL_AR} \ - -DZSTD_BUILD_STATIC=ON \ + -DZSTD_BUILD_STATIC=${ZSTD_BUILD_STATIC} \ -DZSTD_PROGRAMS_LINK_SHARED=ON \ "${_CMAKE_EXTRA_CONFIG[@]}" ninja install popd - -if [[ "$PKG_NAME" == *static ]] -then - # relying on conda to dedup package - echo "Keeping all files, conda will dedupe" -else - rm -rf ${PREFIX}/lib/*.a -fi From cf3b62a204327eadf099820518a64df556968c67 Mon Sep 17 00:00:00 2001 From: Mark Harfouche Date: Sat, 30 Jul 2022 17:12:00 +0100 Subject: [PATCH 03/11] output cmake files for inspectjon --- recipe/meta.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 3184745..efd0628 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -11,7 +11,7 @@ source: - windows-cmake-pkg-config.patch # [win] build: - number: 2 + number: 3 outputs: - name: zstd @@ -58,6 +58,8 @@ outputs: - test -f ${PREFIX}/lib/pkgconfig/libzstd.pc # [unix] - if not exist %LIBRARY_LIB%\pkgconfig\libzstd.pc exit 1 # [win] - pkg-config --cflags libzstd + - cat ${PREFIX}/lib/cmake/zstd/zstdTargets.cmake # [unix] + - cat ${PREFIX}/lib/cmake/zstd/zstdConfig.cmake # [unix] - name: zstd-static script: install.sh # [unix] @@ -78,6 +80,8 @@ outputs: test: commands: - test -f ${PREFIX}/lib/libzstd.a # [unix] + - cat ${PREFIX}/lib/cmake/zstd/zstdTargets.cmake # [unix] + - cat ${PREFIX}/lib/cmake/zstd/zstdConfig.cmake # [unix] about: home: http://www.zstd.net From f3cc8dc3ef97cad2a3568d27702aa74920cc4374 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Sun, 31 Jul 2022 22:26:38 +0200 Subject: [PATCH 04/11] uncouple outputs --- recipe/install.sh | 3 +++ recipe/meta.yaml | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/recipe/install.sh b/recipe/install.sh index 2fa36b5..b93691b 100644 --- a/recipe/install.sh +++ b/recipe/install.sh @@ -23,8 +23,10 @@ fi if [[ "$PKG_NAME" == *static ]]; then ZSTD_BUILD_STATIC=ON + ZSTD_BUILD_SHARED=OFF else ZSTD_BUILD_STATIC=OFF + ZSTD_BUILD_SHARED=ON fi pushd build/cmake @@ -35,6 +37,7 @@ pushd build/cmake -DCMAKE_PREFIX_PATH="${PREFIX}" \ -DCMAKE_AR=${FULL_AR} \ -DZSTD_BUILD_STATIC=${ZSTD_BUILD_STATIC} \ + -DZSTD_BUILD_SHARED=${ZSTD_BUILD_SHARED} \ -DZSTD_PROGRAMS_LINK_SHARED=ON \ "${_CMAKE_EXTRA_CONFIG[@]}" diff --git a/recipe/meta.yaml b/recipe/meta.yaml index efd0628..f856cf1 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -73,10 +73,6 @@ outputs: - ninja - make # [unix] - cmake-no-system - host: - - {{ pin_subpackage('zstd', exact=True) }} - run: - - {{ pin_subpackage('zstd', exact=True) }} test: commands: - test -f ${PREFIX}/lib/libzstd.a # [unix] From 8d075f51adb90094ad67cdc9c29cbe8b1ddfd762 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Sun, 31 Jul 2022 22:34:59 +0200 Subject: [PATCH 05/11] sort & complete tests --- recipe/meta.yaml | 51 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index f856cf1..5f8c6a9 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -39,25 +39,32 @@ outputs: test: requires: - pkg-config - commands: - - zstd -be -i5 - - - test -f ${PREFIX}/include/zstd.h # [unix] - - test ! -f ${PREFIX}/lib/libzstd.a # [unix] - - test -f ${PREFIX}/lib/libzstd.so # [linux] - - test -f ${PREFIX}/lib/libzstd.dylib # [osx] - - - if not exist %LIBRARY_INC%\zstd.h exit 1 # [win] + # shared libraries + - test -f ${PREFIX}/lib/libzstd.so # [linux] + - test -f ${PREFIX}/lib/libzstd.dylib # [osx] - if not exist %LIBRARY_BIN%\libzstd.dll exit 1 # [win] - if not exist %LIBRARY_LIB%\libzstd.lib exit 1 # [win] + + # absence of static libraries + - test ! -f ${PREFIX}/lib/libzstd.a # [unix] - if exist %LIBRARY_LIB%\libzstd_static.lib exit 1 # [win] - - export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig # [unix] - - set "PKG_CONFIG_PATH=%LIBRARY_LIB%\pkgconfig" # [win] + # headers + - test -f ${PREFIX}/include/zstd.h # [unix] + - if not exist %LIBRARY_INC%\zstd.h exit 1 # [win] + + # CLI + - zstd -be -i5 + + # pkgconfig - test -f ${PREFIX}/lib/pkgconfig/libzstd.pc # [unix] - if not exist %LIBRARY_LIB%\pkgconfig\libzstd.pc exit 1 # [win] + - export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig # [unix] + - set "PKG_CONFIG_PATH=%LIBRARY_LIB%\pkgconfig" # [win] - pkg-config --cflags libzstd + + # cmake - cat ${PREFIX}/lib/cmake/zstd/zstdTargets.cmake # [unix] - cat ${PREFIX}/lib/cmake/zstd/zstdConfig.cmake # [unix] @@ -74,8 +81,28 @@ outputs: - make # [unix] - cmake-no-system test: + requires: + - pkg-config commands: - - test -f ${PREFIX}/lib/libzstd.a # [unix] + # absence of share libraries + - test ! -f ${PREFIX}/lib/libzstd.so # [linux] + - test ! -f ${PREFIX}/lib/libzstd.dylib # [osx] + + # static libraries + - test -f ${PREFIX}/lib/libzstd.a + + # headers + - test -f ${PREFIX}/include/zstd.h + + # CLI + - zstd -be -i5 + + # pkgconfig + - test -f ${PREFIX}/lib/pkgconfig/libzstd.pc + - export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig + - pkg-config --cflags libzstd + + # cmake - cat ${PREFIX}/lib/cmake/zstd/zstdTargets.cmake # [unix] - cat ${PREFIX}/lib/cmake/zstd/zstdConfig.cmake # [unix] From 49e3cbc6158cfb90039b5b989a4916719c430753 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Sun, 31 Jul 2022 22:58:43 +0200 Subject: [PATCH 06/11] cannot build CLI without shared libs --- recipe/install.sh | 3 ++- recipe/meta.yaml | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/recipe/install.sh b/recipe/install.sh index b93691b..b8b6cf2 100644 --- a/recipe/install.sh +++ b/recipe/install.sh @@ -23,7 +23,8 @@ fi if [[ "$PKG_NAME" == *static ]]; then ZSTD_BUILD_STATIC=ON - ZSTD_BUILD_SHARED=OFF + # cannot build CLI without shared lib + ZSTD_BUILD_SHARED=ON else ZSTD_BUILD_STATIC=OFF ZSTD_BUILD_SHARED=ON diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 5f8c6a9..5079a3b 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -80,13 +80,17 @@ outputs: - ninja - make # [unix] - cmake-no-system + run_constrained: + # do not co-install with shared-only lib; + # zstd-static contains the shared libs already anyway + - zstd <0.0a0 test: requires: - pkg-config commands: - # absence of share libraries - - test ! -f ${PREFIX}/lib/libzstd.so # [linux] - - test ! -f ${PREFIX}/lib/libzstd.dylib # [osx] + # shared libraries + - test -f ${PREFIX}/lib/libzstd.so # [linux] + - test -f ${PREFIX}/lib/libzstd.dylib # [osx] # static libraries - test -f ${PREFIX}/lib/libzstd.a From 4011ff898dfd120908b0e96e9af533f152c2a426 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Sun, 31 Jul 2022 22:44:48 +0200 Subject: [PATCH 07/11] run cmake --find-package as test --- recipe/meta.yaml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 5079a3b..65846a3 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -38,6 +38,7 @@ outputs: - lz4-c test: requires: + - cmake - pkg-config commands: # shared libraries @@ -65,8 +66,9 @@ outputs: - pkg-config --cflags libzstd # cmake - - cat ${PREFIX}/lib/cmake/zstd/zstdTargets.cmake # [unix] - - cat ${PREFIX}/lib/cmake/zstd/zstdConfig.cmake # [unix] + - cmake --find-package -DNAME=zstd -DLANGUAGE=C -DMODE=EXIST -DCOMPILER_ID=GNU # [linux] + - cmake --find-package -DNAME=zstd -DLANGUAGE=C -DMODE=EXIST -DCOMPILER_ID=Clang # [osx] + - cmake --find-package -DNAME=zstd -DLANGUAGE=C -DMODE=EXIST -DCOMPILER_ID=MSVC # [win] - name: zstd-static script: install.sh # [unix] @@ -86,6 +88,7 @@ outputs: - zstd <0.0a0 test: requires: + - cmake - pkg-config commands: # shared libraries @@ -107,8 +110,8 @@ outputs: - pkg-config --cflags libzstd # cmake - - cat ${PREFIX}/lib/cmake/zstd/zstdTargets.cmake # [unix] - - cat ${PREFIX}/lib/cmake/zstd/zstdConfig.cmake # [unix] + - cmake --find-package -DNAME=zstd -DLANGUAGE=C -DMODE=EXIST -DCOMPILER_ID=GNU # [linux] + - cmake --find-package -DNAME=zstd -DLANGUAGE=C -DMODE=EXIST -DCOMPILER_ID=Clang # [osx] about: home: http://www.zstd.net From f6fa361ecd27d9895bbc0ce0b60e0a1c70ffffc0 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Mon, 1 Aug 2022 01:17:57 +0200 Subject: [PATCH 08/11] clean up bld.bat --- recipe/install.bat | 16 ++++++++-------- recipe/meta.yaml | 3 +++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/recipe/install.bat b/recipe/install.bat index 7b96d32..c10cce7 100644 --- a/recipe/install.bat +++ b/recipe/install.bat @@ -1,4 +1,5 @@ @echo on + pushd "%SRC_DIR%"\build\cmake cmake -GNinja ^ -DCMAKE_BUILD_TYPE=Release ^ @@ -6,14 +7,13 @@ cmake -GNinja ^ -DCMAKE_INSTALL_LIBDIR="lib" ^ -DCMAKE_PREFIX_PATH="%LIBRARY_PREFIX%" ^ -DZSTD_BUILD_SHARED=ON -if errorlevel 1 exit 1 +if %ERRORLEVEL% neq 0 exit 1 + cmake --build . --target install -if errorlevel 1 exit 1 -dir -dir lib -copy lib\zstd.dll %PREFIX%\Library\bin\zstd.dll -if errorlevel 1 exit 1 +if %ERRORLEVEL% neq 0 exit 1 + +:: duplicate DLL (+ importlib) to also have files with "lib" prefix copy %PREFIX%\Library\bin\zstd.dll %PREFIX%\Library\bin\libzstd.dll -if errorlevel 1 exit 1 +if %ERRORLEVEL% neq 0 exit 1 copy %PREFIX%\Library\lib\zstd.lib %PREFIX%\Library\lib\libzstd.lib -if errorlevel 1 exit 1 +if %ERRORLEVEL% neq 0 exit 1 diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 65846a3..fcdcb33 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -44,6 +44,9 @@ outputs: # shared libraries - test -f ${PREFIX}/lib/libzstd.so # [linux] - test -f ${PREFIX}/lib/libzstd.dylib # [osx] + - if not exist %LIBRARY_BIN%\zstd.dll exit 1 # [win] + - if not exist %LIBRARY_LIB%\zstd.lib exit 1 # [win] + # duplicated for packages depending on lib-prefixed files - if not exist %LIBRARY_BIN%\libzstd.dll exit 1 # [win] - if not exist %LIBRARY_LIB%\libzstd.lib exit 1 # [win] From 246a0b264d77a861b9aa314bd179953c21bef398 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Mon, 1 Aug 2022 10:42:24 +0200 Subject: [PATCH 09/11] don't build static lib on windows --- recipe/install.bat | 4 +++- recipe/meta.yaml | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/recipe/install.bat b/recipe/install.bat index c10cce7..6a91c86 100644 --- a/recipe/install.bat +++ b/recipe/install.bat @@ -6,7 +6,9 @@ cmake -GNinja ^ -DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" ^ -DCMAKE_INSTALL_LIBDIR="lib" ^ -DCMAKE_PREFIX_PATH="%LIBRARY_PREFIX%" ^ - -DZSTD_BUILD_SHARED=ON + -DZSTD_BUILD_SHARED=ON ^ + -DZSTD_BUILD_STATIC=OFF ^ + . if %ERRORLEVEL% neq 0 exit 1 cmake --build . --target install diff --git a/recipe/meta.yaml b/recipe/meta.yaml index fcdcb33..a95068b 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -52,6 +52,7 @@ outputs: # absence of static libraries - test ! -f ${PREFIX}/lib/libzstd.a # [unix] + - if exist %LIBRARY_LIB%\zstd_static.lib exit 1 # [win] - if exist %LIBRARY_LIB%\libzstd_static.lib exit 1 # [win] # headers From 7c294af756e6097f3a5567ebfc07fd5df16f22f5 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Mon, 1 Aug 2022 10:48:07 +0200 Subject: [PATCH 10/11] disable cmake test on windows for now --- recipe/meta.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index a95068b..12f748d 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -72,7 +72,9 @@ outputs: # cmake - cmake --find-package -DNAME=zstd -DLANGUAGE=C -DMODE=EXIST -DCOMPILER_ID=GNU # [linux] - cmake --find-package -DNAME=zstd -DLANGUAGE=C -DMODE=EXIST -DCOMPILER_ID=Clang # [osx] - - cmake --find-package -DNAME=zstd -DLANGUAGE=C -DMODE=EXIST -DCOMPILER_ID=MSVC # [win] + # disabled because compiler detection fails, see + # https://discourse.cmake.org/t/questions-about-find-package-cli-msvc/6194 + # - cmake --find-package -DNAME=zstd -DLANGUAGE=C -DMODE=EXIST -DCOMPILER_ID=MSVC # [win] - name: zstd-static script: install.sh # [unix] From 22966cd41352f0f96396039f75198fe04d56db56 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Mon, 1 Aug 2022 11:09:23 +0200 Subject: [PATCH 11/11] link CLI against shared builds on windows https://github.com/facebook/zstd/blob/v1.5.2/build/cmake/CMakeLists.txt#L144-L152 --- recipe/install.bat | 1 + 1 file changed, 1 insertion(+) diff --git a/recipe/install.bat b/recipe/install.bat index 6a91c86..87f0b4c 100644 --- a/recipe/install.bat +++ b/recipe/install.bat @@ -8,6 +8,7 @@ cmake -GNinja ^ -DCMAKE_PREFIX_PATH="%LIBRARY_PREFIX%" ^ -DZSTD_BUILD_SHARED=ON ^ -DZSTD_BUILD_STATIC=OFF ^ + -DZSTD_PROGRAMS_LINK_SHARED=ON ^ . if %ERRORLEVEL% neq 0 exit 1