Skip to content

Commit

Permalink
back to autotools build on unix for now
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed Sep 7, 2022
1 parent ab262d6 commit 2b886e1
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 9 deletions.
54 changes: 54 additions & 0 deletions recipe/build-shared.sh
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions recipe/build-static.sh
Original file line number Diff line number Diff line change
@@ -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/
29 changes: 20 additions & 9 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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) }}
Expand Down

0 comments on commit 2b886e1

Please sign in to comment.