Skip to content

Commit

Permalink
add separate output for test targets
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed May 8, 2023
1 parent c1d57be commit a1d09ad
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 2 deletions.
9 changes: 9 additions & 0 deletions recipe/build-abseil.bat
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
@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 ^
-DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
-DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
-DBUILD_SHARED_LIBS=ON ^
-DABSL_PROPAGATE_CXX_STD=ON ^
!EXTRA_ARGS! ^
..
if %ERRORLEVEL% neq 0 exit 1

Expand Down
11 changes: 9 additions & 2 deletions recipe/build-abseil.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
55 changes: 55 additions & 0 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 %}
Expand All @@ -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]

Expand All @@ -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
Expand Down

0 comments on commit a1d09ad

Please sign in to comment.