diff --git a/P/protobuf/bundled/files/c++safe b/P/protobuf/bundled/files/c++safe new file mode 100755 index 00000000000..66c1c05eb73 --- /dev/null +++ b/P/protobuf/bundled/files/c++safe @@ -0,0 +1,2 @@ +#!/bin/bash +exec c++ $(echo '' "$@" '' | sed -e 's/ -Ofast / -O3 -fexcess-precision=fast -fno-math-errno /g;s/ -ffast-math / -fexcess-precision=fast -fno-math-errno /g;s/ -funsafe-math-optimizations / /g;s/ -march=[^ ]* / /g;s/ -maes / /g;s/ -msse4[.]1 / /g;s/ -Xarch_[^ ]* / /g') diff --git a/P/protobuf/bundled/files/ccsafe b/P/protobuf/bundled/files/ccsafe new file mode 100755 index 00000000000..2d7ebc061a2 --- /dev/null +++ b/P/protobuf/bundled/files/ccsafe @@ -0,0 +1,2 @@ +#!/bin/bash +exec cc $(echo '' "$@" '' | sed -e 's/ -Ofast / -O3 -fexcess-precision=fast -fno-math-errno /g;s/ -ffast-math / -fexcess-precision=fast -fno-math-errno /g;s/ -funsafe-math-optimizations / /g;s/ -march=[^ ]* / /g;s/ -maes / /g;s/ -msse4[.]1 / /g;s/ -Xarch_[^ ]* / /g') diff --git a/P/protobuf/common.jl b/P/protobuf/common.jl new file mode 100644 index 00000000000..eaa9bc24e0d --- /dev/null +++ b/P/protobuf/common.jl @@ -0,0 +1,44 @@ +version = v"3.16.0" + +sources = [ + GitSource("https://github.com/protocolbuffers/protobuf.git", "2dc747c574b68a808ea4699d26942c8132fe2b09"), + DirectorySource(joinpath(@__DIR__, "bundled")), +] + +script = raw""" +cd $WORKSPACE/srcdir/protobuf + +# Avoid problems with `-march`, `-ffast-math` etc. +sed -i -e 's!set(CMAKE_C_COMPILER.*!set(CMAKE_C_COMPILER '${WORKSPACE}/srcdir/files/ccsafe')!' ${CMAKE_TARGET_TOOLCHAIN} +sed -i -e 's!set(CMAKE_CXX_COMPILER.*!set(CMAKE_CXX_COMPILER '${WORKSPACE}/srcdir/files/c++safe')!' ${CMAKE_TARGET_TOOLCHAIN} + +cmake_extra_args=() +if [[ "$BUILD_SHARED_LIBS" == "OFF" ]]; then + cmake_extra_args+=( + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ + ) +fi + +cmake \ + -B work \ + -G Ninja \ + -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_CXX_STANDARD=14 \ + -DCMAKE_FIND_ROOT_PATH=${prefix} \ + -DCMAKE_INSTALL_PREFIX=${prefix} \ + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \ + -Dprotobuf_BUILD_PROTOC_BINARIES=OFF \ + -Dprotobuf_BUILD_TESTS=OFF \ + ${cmake_extra_args[@]} \ + cmake +cmake --build work --parallel ${nproc} +cmake --install work +install_license LICENSE +""" + +platforms = expand_cxxstring_abis(supported_platforms()) + +dependencies = [ + Dependency("Zlib_jll") +] diff --git a/P/protobuf/protobuf/build_tarballs.jl b/P/protobuf/protobuf/build_tarballs.jl new file mode 100644 index 00000000000..02521390960 --- /dev/null +++ b/P/protobuf/protobuf/build_tarballs.jl @@ -0,0 +1,20 @@ +# Note that this script can accept some limited command-line arguments, run +# `julia build_tarballs.jl --help` to see a usage message. +using BinaryBuilder, Pkg + +include(joinpath(@__DIR__, "..", "common.jl")) + +name = "protobuf" + +script = raw""" +export BUILD_SHARED_LIBS=ON +""" * +script + +products = [ + LibraryProduct("libprotobuf", :libprotobuf), + LibraryProduct("libprotobuf-lite", :libprotobuf_lite), +] + +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; + julia_compat="1.6", preferred_gcc_version=v"9") diff --git a/P/protobuf/protobuf_static/build_tarballs.jl b/P/protobuf/protobuf_static/build_tarballs.jl new file mode 100644 index 00000000000..bde0e67c40e --- /dev/null +++ b/P/protobuf/protobuf_static/build_tarballs.jl @@ -0,0 +1,20 @@ +# Note that this script can accept some limited command-line arguments, run +# `julia build_tarballs.jl --help` to see a usage message. +using BinaryBuilder, Pkg + +include(joinpath(@__DIR__, "..", "common.jl")) + +name = "protobuf_static" + +script = raw""" +export BUILD_SHARED_LIBS=OFF +""" * +script + +products = [ + FileProduct("lib/libprotobuf.a", :libprotobuf_static), + FileProduct("lib/libprotobuf-lite.a", :libprotobuf_lite_static), +] + +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; + julia_compat="1.6", preferred_gcc_version=v"9")