diff --git a/recipe/build-shared.sh b/recipe/build-shared.sh new file mode 100644 index 0000000..ca7bc09 --- /dev/null +++ b/recipe/build-shared.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +set -ex + +if [ "$(uname)" == "Linux" ]; +then + # protobuf uses PROTOBUF_OPT_FLAG to set the optimization level + # unit test can fail if optmization above 0 are used. + CPPFLAGS="${CPPFLAGS//-O[0-9]/}" + CXXFLAGS="${CXXFLAGS//-O[0-9]/}" + export PROTOBUF_OPT_FLAG="-O2" + # to improve performance, disable checks intended for debugging + CXXFLAGS="$CXXFLAGS -DNDEBUG" +elif [ "$(uname)" == "Darwin" ]; +then + # remove pie from LDFLAGS + LDFLAGS="${LDFLAGS//-pie/}" +fi + +# required to pick up conda installed zlib +export CPPFLAGS="${CPPFLAGS} -I${PREFIX}/include" +export LDFLAGS="${LDFLAGS} -L${PREFIX}/lib" + +# Build configure/Makefile as they are not present. +aclocal +libtoolize +autoconf +autoreconf -i +automake --add-missing + +./configure --prefix="${PREFIX}" \ + --build=${BUILD} \ + --host=${HOST} \ + --with-pic \ + --with-zlib \ + --enable-shared \ + CC_FOR_BUILD=${CC} \ + CXX_FOR_BUILD=${CXX} + +# Skip memory hungry tests +export GTEST_FILTER="-IoTest.LargeOutput" +if [ "${HOST}" == "powerpc64le-conda_cos7-linux-gnu" ]; then + make -j 2 + make check -j 2 || (cat src/test-suite.log; exit 1) +else + make -j ${CPU_COUNT} + if [[ "$CONDA_BUILD_CROSS_COMPILATION" != 1 ]]; then + make check -j ${CPU_COUNT} || (cat src/test-suite.log; exit 1) + fi +fi +make install +rm ${PREFIX}/lib/libprotobuf.a +rm ${PREFIX}/lib/libprotobuf-lite.a +rm ${PREFIX}/lib/libprotoc.a diff --git a/recipe/build-static.sh b/recipe/build-static.sh new file mode 100644 index 0000000..f4666ac --- /dev/null +++ b/recipe/build-static.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -euo pipefail + +mkdir -p ${PREFIX}/lib +ls -l ./src/.libs/libproto*.a +cp ./src/.libs/libproto*.a ${PREFIX}/lib/ diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 9809f77..f0dd47d 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -29,11 +29,14 @@ source: folder: third_party/googletest build: - number: 1 + number: 2 outputs: - name: libprotobuf - script: build-lib.sh # [unix] + script: build-shared.sh # [unix] + # cmake script currently disabled due to compatibility issues with + # existing builds; see #49 for potential solution, or switch with 3.22 + # script: build-lib.sh # [unix] script: build-lib.bat # [win] build: run_exports: @@ -45,8 +48,14 @@ outputs: build: - {{ compiler('c') }} - {{ compiler('cxx') }} - - cmake - - ninja + - cmake # [win] + - ninja # [win] + - autoconf # [not win] + - automake # [not win] + - libtool # [not win] + - pkg-config # [not win] + - unzip # [not win] + - make # [not win] host: - zlib run: @@ -65,8 +74,8 @@ outputs: - if exist %LIBRARY_LIB%\{{ each_lib }}.lib exit 1 # [win] {% endfor %} - # cmake - - test -f ${PREFIX}/lib/cmake/protobuf/protobuf-config.cmake # [unix] + # cmake (disabled on unix currently) + # - test -f ${PREFIX}/lib/cmake/protobuf/protobuf-config.cmake # [unix] - if not exist %LIBRARY_LIB%\cmake\protobuf\protobuf-config.cmake exit 1 # [win] # pkgconfig @@ -79,14 +88,16 @@ outputs: - protoc --help - name: libprotobuf-static - script: build-lib.sh # [unix] + script: build-static.sh # [unix] + # cmake script currently disabled due to compatibility issues with + # existing builds; see #49 for potential solution, or switch with 3.22 script: build-lib.bat # [win] requirements: build: - {{ compiler('c') }} - {{ compiler('cxx') }} - - cmake - - ninja + - cmake # [win] + - ninja # [win] host: - zlib - {{ pin_subpackage('libprotobuf', exact=True) }}