From a1d09ad416c45539ada043b213166aae4ce3ccf5 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Tue, 25 Apr 2023 19:31:13 +1100 Subject: [PATCH] add separate output for test targets --- recipe/build-abseil.bat | 9 +++++++ recipe/build-abseil.sh | 11 +++++++-- recipe/meta.yaml | 55 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/recipe/build-abseil.bat b/recipe/build-abseil.bat index e2c05b2..d266f58 100644 --- a/recipe/build-abseil.bat +++ b/recipe/build-abseil.bat @@ -1,7 +1,15 @@ @echo on +SetLocal EnableDelayedExpansion + mkdir build cd build + +if [%PKG_NAME%] == [libabseil-tests] ( + set "EXTRA_ARGS=-DBUILD_TESTING=ON -DABSL_BUILD_TEST_HELPERS=ON -DABSL_BUILD_TESTING=ON" + set "EXTRA_ARGS=!EXTRA_ARGS! -DABSL_USE_EXTERNAL_GOOGLETEST=ON -DABSL_FIND_GOOGLETEST=ON" +) + cmake -GNinja ^ -DCMAKE_BUILD_TYPE=Release ^ -DCMAKE_CXX_STANDARD=17 ^ @@ -9,6 +17,7 @@ cmake -GNinja ^ -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^ -DBUILD_SHARED_LIBS=ON ^ -DABSL_PROPAGATE_CXX_STD=ON ^ + !EXTRA_ARGS! ^ .. if %ERRORLEVEL% neq 0 exit 1 diff --git a/recipe/build-abseil.sh b/recipe/build-abseil.sh index 648ba1d..aa53b32 100644 --- a/recipe/build-abseil.sh +++ b/recipe/build-abseil.sh @@ -10,14 +10,21 @@ if [[ "${target_platform}" == osx-* ]]; then CXXFLAGS="${CXXFLAGS} -D_LIBCPP_DISABLE_AVAILABILITY" fi -cmake ${CMAKE_ARGS} \ +EXTRA_ARGS="" +if [[ "$PKG_NAME" == "libabseil-tests" ]]; then + EXTRA_ARGS="-DABSL_USE_EXTERNAL_GOOGLETEST=ON -DABSL_FIND_GOOGLETEST=ON" + EXTRA_ARGS="${EXTRA_ARGS} -DBUILD_TESTING=ON -DABSL_BUILD_TESTING=ON" +fi + +cmake -G Ninja \ + ${CMAKE_ARGS} \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_CXX_STANDARD=17 \ -DCMAKE_INSTALL_LIBDIR=lib \ -DCMAKE_PREFIX_PATH=${PREFIX} \ -DBUILD_SHARED_LIBS=ON \ -DABSL_PROPAGATE_CXX_STD=ON \ - -GNinja \ + ${EXTRA_ARGS} \ .. cmake --build . diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 168fdcc..afcbf1d 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -19,6 +19,8 @@ "scoped_set_env", "spinlock_wait", "stacktrace", "status", "statusor", "strerror", "strings", "symbolize", "synchronization", "time", "time_zone" ] %} +# test helper targets (but used e.g. by protobuf) +{% set absl_test_libs = ["scoped_mock_log"] %} package: name: abseil-split @@ -79,6 +81,9 @@ outputs: # windows-only (almost-)all-in-one DLL + import library - if not exist %LIBRARY_BIN%\\abseil_dll.dll exit 1 # [win] - if not exist %LIBRARY_LIB%\\abseil_dll.lib exit 1 # [win] + # absence of test targets in regular abseil output + - if exist %LIBRARY_BIN%\\abseil_test_dll.dll exit 1 # [win] + - if exist %LIBRARY_LIB%\\abseil_test_dll.lib exit 1 # [win] # absl_* libraries {% for each_lib in absl_libs %} @@ -98,6 +103,14 @@ outputs: - pkg-config --print-errors --exact-version "{{ v_major }}" absl_{{ each_lib }} {% endfor %} + # absence of test targets in regular abseil output + {% for each_lib in absl_test_libs %} + # absence of all libs + - test ! -f $PREFIX/lib/libabsl_{{ each_lib }}${SHLIB_EXT} # [unix] + - test ! -f $PREFIX/lib/libabsl_{{ each_lib }}.a # [unix] + - if exist %LIBRARY_LIB%\\absl_{{ each_lib }}.lib exit 1 # [win] + {% endfor %} + # pkg-config (abseil_dll) - pkg-config --print-errors --exact-version "{{ v_major }}" abseil_dll # [win] @@ -111,6 +124,48 @@ outputs: - ./flags_example # [unix] - flags_example.exe # [win] + # tests & test-helpers + - name: libabseil-tests + script: build-abseil.sh # [unix] + script: build-abseil.bat # [win] + build: + string: cxx{{ cxx_standard }}_h{{ PKG_HASH }}_{{ PKG_BUILDNUM }} + + requirements: + build: + - {{ compiler('c') }} + - {{ compiler('cxx') }} + - cmake + - ninja + host: + - gtest + - {{ pin_subpackage("libabseil", exact=True) }} + run: + - gtest + - {{ pin_subpackage("libabseil", exact=True) }} + + test: + requires: + - pkg-config + commands: + # windows-only (almost-)all-in-one DLL + import library + - if not exist %LIBRARY_BIN%\\abseil_test_dll.dll exit 1 # [win] + - if not exist %LIBRARY_LIB%\\abseil_test_dll.lib exit 1 # [win] + + # absl_* libraries + {% for each_lib in absl_test_libs %} + # presence of shared libs + - test -f $PREFIX/lib/libabsl_{{ each_lib }}${SHLIB_EXT} # [unix] + # absence of static libs + - test ! -f $PREFIX/lib/libabsl_{{ each_lib }}.a # [unix] + + # pkg-config (should point to abseil_test_dll on shared windows builds) + - pkg-config --print-errors --exact-version "{{ v_major }}" absl_{{ each_lib }} + {% endfor %} + + # pkg-config abseil_test_dll + - pkg-config --print-errors --exact-version "{{ v_major }}" abseil_test_dll # [win] + about: home: https://github.com/abseil/abseil-cpp license: Apache-2.0