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 Apr 25, 2023
1 parent 65e374a commit 0d89c7f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 13 deletions.
11 changes: 8 additions & 3 deletions recipe/build-abseil.bat
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
@echo on

SetLocal EnableDelayedExpansion

mkdir build
cd build

if [%PKG_NAME%] == [pyarrow] (
set "EXTRA_ARGS=-DBUILD_TESTING=ON -DABSL_BUILD_TEST_HELPERS=ON -DABSL_BUILD_TESTING=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 ^
-DBUILD_TESTING=ON ^
-DABSL_BUILD_TEST_HELPERS=ON ^
-DABSL_BUILD_TESTING=ON ^
-DABSL_PROPAGATE_CXX_STD=ON ^
-DABSL_USE_EXTERNAL_GOOGLETEST=ON ^
-DABSL_FIND_GOOGLETEST=ON ^
!EXTRA_ARGS! ^
..
if %ERRORLEVEL% neq 0 exit 1

Expand Down
12 changes: 8 additions & 4 deletions recipe/build-abseil.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ if [[ "${target_platform}" == osx-* ]]; then
CXXFLAGS="${CXXFLAGS} -D_LIBCPP_DISABLE_AVAILABILITY"
fi

cmake ${CMAKE_ARGS} \
EXTRA_ARGS=""
if [[ "$PKG_NAME" == "pyarrow" ]]; then
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 \
-DBUILD_TESTING=ON \
-DABSL_BUILD_TESTING=ON \
-DABSL_PROPAGATE_CXX_STD=ON \
-DABSL_USE_EXTERNAL_GOOGLETEST=ON \
-DABSL_FIND_GOOGLETEST=ON \
-GNinja \
${EXTRA_ARGS} \
..

cmake --build .
Expand Down
48 changes: 42 additions & 6 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"scoped_set_env", "spinlock_wait", "stacktrace", "status", "statusor", "strerror", "strings",
"symbolize", "synchronization", "time", "time_zone"
] %}
# test dependencies (but used e.g. by protobuf)
{% set absl_libs = absl_libs + ["scoped_mock_log"] %}
# test helper targets (but used e.g. by protobuf)
{% set absl_test_libs = ["scoped_mock_log"] %}

package:
name: abseil-split
Expand Down Expand Up @@ -85,8 +85,6 @@ 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]
- 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_libs %}
Expand All @@ -107,8 +105,7 @@ outputs:
{% endfor %}

# pkg-config (abseil_dll & abseil_test_dll)
- pkg-config --print-errors --exact-version "{{ v_major }}" abseil_dll # [win]
- pkg-config --print-errors --exact-version "{{ v_major }}" abseil_test_dll # [win]
- pkg-config --print-errors --exact-version "{{ v_major }}" abseil_dll # [win]

# CMake integration
- cd cmake_test
Expand All @@ -120,6 +117,45 @@ outputs:
- ./flags_example # [unix]
- flags_example.exe # [win]

# test-helpers
- name: libabseil-test
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:
- gmock
- {{ pin_subpackage("libabseil", exact=True) }}
run:
- {{ pin_subpackage("libabseil", exact=True) }}

test:
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 0d89c7f

Please sign in to comment.