Skip to content

Commit

Permalink
Merge pull request #128 from h-vetinari/cmake_main
Browse files Browse the repository at this point in the history
Build with CMake on unix
  • Loading branch information
h-vetinari authored Sep 6, 2022
2 parents 79d5eb2 + c42a5b8 commit ab262d6
Show file tree
Hide file tree
Showing 15 changed files with 189 additions and 170 deletions.
4 changes: 4 additions & 0 deletions .azure-pipelines/azure-pipelines-linux.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .ci_support/linux_aarch64_.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cxx_compiler:
cxx_compiler_version:
- '10'
docker_image:
- quay.io/condaforge/linux-anvil-aarch64
- quay.io/condaforge/linux-anvil-cos7-x86_64
pin_run_as_build:
zlib:
max_pin: x.x
Expand Down
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

11 changes: 3 additions & 8 deletions README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion conda-forge.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
provider: {linux_aarch64: default, linux_ppc64le: default, win: azure}
conda_forge_output_validation: true
build_platform: {osx_arm64: osx_64, linux_ppc64le: linux_64}
build_platform: {osx_arm64: osx_64, linux_aarch64: linux_64, linux_ppc64le: linux_64}
test_on_native_only: true
github:
branch_name: main
Expand Down
22 changes: 0 additions & 22 deletions recipe/bld-static.bat

This file was deleted.

23 changes: 13 additions & 10 deletions recipe/bld-shared.bat → recipe/build-lib.bat
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
:: Setup directory structure per protobuf's instructions.
cd cmake
if errorlevel 1 exit 1
@echo on

mkdir build-shared
if errorlevel 1 exit 1
cd build-shared
if errorlevel 1 exit 1
if "%PKG_NAME%"=="libprotobuf-static" (
set CF_SHARED=OFF
mkdir build-static
cd build-static
) else (
set CF_SHARED=ON
mkdir build-shared
cd build-shared
)

:: Configure and install based on protobuf's instructions and other `bld.bat`s.
cmake -G "Ninja" ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
-DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
-Dprotobuf_WITH_ZLIB=ON ^
-Dprotobuf_BUILD_SHARED_LIBS=ON ^
-Dprotobuf_BUILD_SHARED_LIBS=%CF_SHARED% ^
-Dprotobuf_MSVC_STATIC_RUNTIME=OFF ^
..
if errorlevel 1 exit 1
if %ERRORLEVEL% neq 0 exit 1
cmake --build . --target install --config Release
if errorlevel 1 exit 1
if %ERRORLEVEL% neq 0 exit 1
50 changes: 50 additions & 0 deletions recipe/build-lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/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"

if [[ "$PKG_NAME" == "libprotobuf-static" ]]; then
export CF_SHARED=OFF
mkdir build-static
cd build-static
else
export CF_SHARED=ON
mkdir build-shared
cd build-shared
fi

if [[ "$CONDA_BUILD_CROSS_COMPILATION" == 1 ]]; then
export CMAKE_ARGS="${CMAKE_ARGS} -Dprotobuf_BUILD_TESTS=OFF"
fi

cmake -G "Ninja" \
${CMAKE_ARGS} \
-DCMAKE_BUILD_TYPE=Release \
-Dprotobuf_WITH_ZLIB=ON \
-Dprotobuf_BUILD_SHARED_LIBS=$CF_SHARED \
..

cmake --build .

if [[ "$CONDA_BUILD_CROSS_COMPILATION" != 1 ]]; then
ninja check
fi

cmake --install .
54 changes: 0 additions & 54 deletions recipe/build-shared.sh

This file was deleted.

7 changes: 0 additions & 7 deletions recipe/build_static.sh

This file was deleted.

91 changes: 51 additions & 40 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
# protobuf doesn't add the major version in the tag...
{% set major = "3" %}

{% set libraries = ["libprotoc", "libprotobuf", "libprotobuf-lite"] %}

package:
name: libprotobuf
name: libprotobuf-split
version: {{ major + "." + version }}

source:
- url: https://github.com/protocolbuffers/protobuf/archive/v{{ version }}/protobuf-v{{ version }}.tar.gz
sha256: 4a7e87e4166c358c63342dddcde6312faee06ea9d5bb4e2fa87d3478076f6639
patches:
- 0001-remove-Werror-from-test-flags.patch # [ppc64le or aarch64]
- patches/0001-remove-Werror-from-test-flags.patch # [ppc64le or aarch64]
- patches/0002-use-consistent-cmake-location.patch
- patches/0003-set-import-lib-extension-on-windows.patch
# This issue gets fixed and then reintroduced often
# https://github.com/protocolbuffers/protobuf/issues/7567
#- issue-7567.patch
# - patches/issue-7567.patch
# these are git submodules from the v21.5 release
# https://github.com/protocolbuffers/protobuf/tree/v21.5/third_party
- url: https://github.com/google/benchmark/archive/5b7683f49e1e9223cf9927b24f6fd3d6bd82e3f8.tar.gz
Expand All @@ -25,12 +29,12 @@ source:
folder: third_party/googletest

build:
number: 0
number: 1

outputs:
- name: libprotobuf
script: build-shared.sh # [unix]
script: bld-shared.bat # [win]
script: build-lib.sh # [unix]
script: build-lib.bat # [win]
build:
run_exports:
# breaks backwards compatibility and new SONAME each minor release
Expand All @@ -41,55 +45,60 @@ outputs:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- cmake # [win]
- ninja # [win]
- autoconf # [not win]
- automake # [not win]
- libtool # [not win]
- pkg-config # [not win]
- unzip # [not win]
- make # [not win]
- cmake
- ninja
host:
- zlib
run:
- ucrt # [win]
test:
commands:
{% for each_lib in libraries %}
# shared libraries
- test -f ${PREFIX}/lib/{{ each_lib }}.so # [linux]
- test -f ${PREFIX}/lib/{{ each_lib }}.dylib # [osx]
- if not exist %LIBRARY_BIN%\{{ each_lib }}.dll exit 1 # [win]
- if not exist %LIBRARY_LIB%\{{ each_lib }}-import.lib exit 1 # [win]

# absence of static libraries
- test ! -f ${PREFIX}/lib/{{ each_lib }}.a # [unix]
- if exist %LIBRARY_LIB%\{{ each_lib }}.lib exit 1 # [win]
{% endfor %}

# cmake
- test -f ${PREFIX}/lib/cmake/protobuf/protobuf-config.cmake # [unix]
- if not exist %LIBRARY_LIB%\cmake\protobuf\protobuf-config.cmake exit 1 # [win]

# pkgconfig
- test -f ${PREFIX}/lib/pkgconfig/protobuf.pc # [unix]
- test -f ${PREFIX}/lib/pkgconfig/protobuf-lite.pc # [unix]
- if not exist %LIBRARY_LIB%\pkgconfig\protobuf.pc exit 1 # [win]
- if not exist %LIBRARY_LIB%\pkgconfig\protobuf-lite.pc exit 1 # [win]

# binary
- protoc --help
- test -f ${PREFIX}/lib/libprotobuf${SHLIB_EXT} # [not win]
- test ! -f ${PREFIX}/lib/libprotobuf.a # [not win]
- if not exist %PREFIX%\\Library\\lib\\libprotoc.lib exit 1 # [win]
- if not exist %PREFIX%\\Library\\lib\\libprotobuf.lib exit 1 # [win]
- if not exist %PREFIX%\\Library\\lib\\libprotobuf-lite.lib exit 1 # [win]

- name: libprotobuf-static
script: build_static.sh # [unix]
script: bld-static.bat # [win]
script: build-lib.sh # [unix]
script: build-lib.bat # [win]
requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- cmake # [win]
- ninja # [win]
- autoconf # [not win]
- automake # [not win]
- libtool # [not win]
- pkg-config # [not win]
- unzip # [not win]
- make # [not win]
- cmake
- ninja
host:
- zlib
- {{ pin_subpackage('libprotobuf', exact=True) }} # [not win]
- {{ pin_subpackage('libprotobuf', exact=True) }}
run:
- {{ pin_subpackage('libprotobuf', exact=True) }} # [not win]
run_constrained:
- libprotobuf <0a0 # [win]
- {{ pin_subpackage('libprotobuf', exact=True) }}
test:
commands:
- test -f ${PREFIX}/lib/libprotobuf.a # [unix]
- test -f ${PREFIX}/lib/libprotobuf-lite.a # [unix]
- test -f ${PREFIX}/lib/libprotoc.a # [unix]
- if exist %PREFIX%\\Library\\bin\\libprotoc.dll exit 1 # [win]
- if not exist %PREFIX%\\Library\\lib\\libprotoc.lib exit 1 # [win]
- if not exist %PREFIX%\\Library\\lib\\libprotobuf.lib exit 1 # [win]
- if not exist %PREFIX%\\Library\\lib\\libprotobuf-lite.lib exit 1 # [win]
{% for each_lib in libraries %}
# static libraries
- test -f ${PREFIX}/lib/{{ each_lib }}.a # [unix]
- if not exist %LIBRARY_LIB%\{{ each_lib }}.lib exit 1 # [win]
{% endfor %}

about:
home: https://developers.google.com/protocol-buffers/
Expand All @@ -101,6 +110,7 @@ about:
Protocol buffers are Google's language-neutral,
platform-neutral, extensible mechanism for serializing structured data-
think XML, but smaller, faster, and simpler.
dev_url: https://github.com/protocolbuffers/protobuf
doc_url: https://developers.google.com/protocol-buffers/
doc_source_url: https://github.com/protocolbuffers/protobuf/releases

Expand All @@ -114,3 +124,4 @@ extra:
- hajapy
- xhochy
- h-vetinari
feedstock-name: libprotobuf
Loading

0 comments on commit ab262d6

Please sign in to comment.