From aa007cf43c643dbc9da043178f81fbab6973d03e Mon Sep 17 00:00:00 2001 From: aceforeverd Date: Wed, 8 Dec 2021 15:13:30 +0800 Subject: [PATCH] refactor: use CMakeLists (#17) upgrade thirdparty list: - libunwind 1.1.0 -> 1.5.0 - llvm: 9.0.0 -> 9.0.1 - rm bison --- .github/workflows/build.yml | 270 ++++++++--------------------- Dockerfile | 2 +- fetch_resource.sh | 111 ------------ pack_all.sh | 42 ++--- pack_boost.sh | 53 ------ pack_llvm.sh | 49 ------ pack_other.sh | 330 ------------------------------------ var.sh | 6 + 8 files changed, 90 insertions(+), 773 deletions(-) delete mode 100755 fetch_resource.sh delete mode 100755 pack_boost.sh delete mode 100755 pack_llvm.sh delete mode 100755 pack_other.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d3b5d7f..075078d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,270 +9,134 @@ on: pull_request: +env: + OPENMLDB_REPO: 4paradigm/OpenMLDB + OPENMLDB_REF: 374fff1951bad85ef6e3f135ef1a8e9ecd15d221 + jobs: - build-other: + thirdparty-linux: runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + include: + - container: ghcr.io/aceforeverd/hybridsql-base:0.4.0 + flags: "" + distro: centos + - container: ubuntu:20.04 + flags: -DBUILD_ZOOKEEPER_PATCH=ON + distro: ubuntu + container: - image: ghcr.io/aceforeverd/hybridsql-base:0.4.0 + image: ${{ matrix.container }} + env: + MAKEOPTS: -j2 + DISTRO: ${{ matrix.distro }} steps: - uses: actions/checkout@v2 - - name: Cache Source - id: cache-source - uses: actions/cache@v2 - with: - path: | - src/*.tar.* - src/*.zip - key: ${{ hashFiles('**/CMakeLists.txt', 'fetch_resource.sh') }} - - - name: download - if: steps.cache-source.outputs.cache-hit != 'true' + - name: setup deps + if: startsWith(matrix.container, 'ubuntu') run: | - ./fetch_resource.sh - - - name: build + apt update + DEBIAN_FRONTEND=noninteractive apt-get install -y bison python3-dev libcppunit-dev build-essential cmake autoconf tcl pkg-config git curl patch libtool-bin + - name: setup deps(centos) + if: startsWith(matrix.container, 'ghcr') run: | - ./pack_other.sh + yum install -y patch - - name: Upload Artifact - if: ${{ github.event_name == 'push' }} - uses: actions/upload-artifact@v2 + - name: download thirdparty source + uses: actions/checkout@v2 with: - path: | - libother-*.tar.gz - src/apache-zookeeper-*.tar.gz - - build-other-mac: - runs-on: macos-latest + repository: ${{ env.OPENMLDB_REPO }} + ref: ${{ env.OPENMLDB_REF }} + path: openmldb - steps: - - uses: actions/checkout@v2 - - - name: Cache Source - id: cache-source - uses: actions/cache@v2 - with: - path: | - src/*.tar.* - src/*.zip - key: ${{ hashFiles('**/CMakeLists.txt', 'fetch_resource.sh') }} - - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v1.9 - with: - cmake-version: '3.20.x' - - - name: Install System Dependencies - # coreutils for nproc - # gnu-getopt for brpc + - name: configure run: | - brew install automake - brew install coreutils - brew install gnu-getopt - - - name: download - if: steps.cache-source.outputs.cache-hit != 'true' - run: | - ./fetch_resource.sh + cmake -S openmldb/third-party -B deps -DBUILD_BUNDLED=ON -DWITH_ZETASQL=OFF ${{ env.flags }} - name: build run: | - getopt -V - echo 'export PATH="/usr/local/opt/gnu-getopt/bin:$PATH"' >> ~/.bash_profile - source ~/.bash_profile - getopt -V - ./pack_other.sh - - - name: Upload Artifact - if: ${{ github.event_name == 'push' }} - uses: actions/upload-artifact@v2 - with: - name: artifact-mac - path: | - libother-*.tar.gz - src/apache-zookeeper-*.tar.gz - - build-llvm: - runs-on: ubuntu-latest - container: - image: ghcr.io/aceforeverd/hybridsql-base:0.4.0 - steps: - - uses: actions/checkout@v2 - - - name: Cache Source - id: cache-source - uses: actions/cache@v2 - with: - path: | - src/*.tar.* - src/*.zip - key: ${{ hashFiles('**/CMakeLists.txt', 'fetch_resource.sh') }} - - - name: download - if: steps.cache-source.outputs.cache-hit != 'true' - run: | - ./fetch_resource.sh + cmake --build deps - - name: build llvm + - name: create archive + if: startsWith(github.ref, 'refs/tags/v') run: | - ./pack_llvm.sh + ./pack_all.sh deps - name: Upload Artifact if: ${{ github.event_name == 'push' }} uses: actions/upload-artifact@v2 with: - path: llvm-*.tar.gz + path: deps/thirdparty-*.tar.gz - build-llvm-mac: + thirdparty-darwin: runs-on: macos-latest + env: + MAKEOPTS: -j3 + steps: - uses: actions/checkout@v2 - - name: Cache Source - id: cache-source - uses: actions/cache@v2 - with: - path: | - src/*.tar.* - src/*.zip - key: ${{ hashFiles('**/CMakeLists.txt', 'fetch_resource.sh') }} - - name: Setup cmake uses: jwlawson/actions-setup-cmake@v1.9 with: - cmake-version: '3.20.x' + cmake-version: "3.20.x" - - name: Install System Dependencies - # coreutils for nproc - run: | - brew install coreutils - - - name: download - if: steps.cache-source.outputs.cache-hit != 'true' - run: | - ./fetch_resource.sh - - - name: build llvm - run: | - ./pack_llvm.sh - - - name: Upload Artifact - if: ${{ github.event_name == 'push' }} - uses: actions/upload-artifact@v2 - with: - name: artifact-mac - path: llvm-*.tar.gz - - - build-boost: - runs-on: ubuntu-latest - container: - image: ghcr.io/aceforeverd/hybridsql-base:0.4.0 - steps: - - uses: actions/checkout@v2 - - - name: Cache Source - id: cache-source - uses: actions/cache@v2 + - name: download thirdparty source + uses: actions/checkout@v2 with: - path: | - src/*.tar.* - src/*.zip - key: ${{ hashFiles('**/CMakeLists.txt', 'fetch_resource.sh') }} + repository: ${{ env.OPENMLDB_REPO }} + ref: ${{ env.OPENMLDB_REF }} + path: openmldb - - name: download - if: steps.cache-source.outputs.cache-hit != 'true' - run: | - ./fetch_resource.sh - - - name: build boost + - name: Install System Dependencies + # coreutils for nproc + # gnu-getopt for brpc run: | - ./pack_boost.sh + brew install automake coreutils gnu-getopt - - name: Upload Artifact - if: ${{ github.event_name == 'push' }} - uses: actions/upload-artifact@v2 - with: - path: boost-*.tar.gz - - build-boost-mac: - runs-on: macos-latest - steps: - - uses: actions/checkout@v2 - - - name: Cache Source - id: cache-source - uses: actions/cache@v2 - with: - path: | - src/*.tar.* - src/*.zip - key: ${{ hashFiles('**/CMakeLists.txt', 'fetch_resource.sh') }} - - - name: Install System Dependencies - # coreutils for nproc + - name: configure run: | - brew install coreutils + cmake -S openmldb/third-party -B deps -DBUILD_BUNDLED=ON -DWITH_ZETASQL=OFF ${{ env.flags }} - - name: download - if: steps.cache-source.outputs.cache-hit != 'true' + - name: build run: | - ./fetch_resource.sh + cmake --build deps - - name: build boost + - name: create archive + if: startsWith(github.ref, 'refs/tags/v') run: | - ./pack_boost.sh + ./pack_all.sh deps - name: Upload Artifact if: ${{ github.event_name == 'push' }} uses: actions/upload-artifact@v2 with: - name: artifact-mac - path: boost-*.tar.gz + path: deps/thirdparty-*.tar.gz release: runs-on: ubuntu-latest + needs: ["thirdparty-linux", "thirdparty-darwin"] if: startsWith(github.ref, 'refs/tags/v') - needs: - - build-other - - build-llvm - - build-boost - - build-other-mac - - build-llvm-mac - - build-boost-mac steps: - uses: actions/checkout@v2 - name: Download Artifacts uses: actions/download-artifact@v2 - with: - name: artifact - path: linux/ - - - name: Download Artifacts For Mac - uses: actions/download-artifact@v2 - with: - name: artifact-mac - path: darwin/ - - name: Pack All Linux + - name: generate signature + working-directory: artifact run: | - ./pack_all.sh linux - - - name: Pack All For Mac - run: | - ./pack_all.sh darwin - env: - OS: darwin - ARCH: x86_64 + sha256sum third*.tar.gz > SHA256SUM - name: Release uses: softprops/action-gh-release@v1 with: files: | - linux/third*.tar.gz - darwin/thirdparty-*.tar.gz + artifact/thirdparty*.tar.gz + artifact/SHA256SUM env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dockerfile b/Dockerfile index 33f6dbf..224b0e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ ARG TARGETARCH RUN yum update -y && yum install -y centos-release-scl epel-release && yum clean all RUN yum install -y devtoolset-8 rh-git227 flex autoconf automake unzip bc expect libtool \ - rh-python38-python-devel gettext byacc xz tcl cppunit-devel rh-python38-python-wheel \ + rh-python38-python-devel gettext byacc xz tcl cppunit-devel rh-python38-python-wheel patch \ && yum clean all COPY setup_cmake.sh / diff --git a/fetch_resource.sh b/fetch_resource.sh deleted file mode 100755 index 899dbf5..0000000 --- a/fetch_resource.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/bash -# Copyright 2021 4Paradigm -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# fetch_resource.sh: fetch all source/binary files from network, -# downloaded files were saved into $DOWNLOAD_DIR - -set -eE - -RED='\033[0;31m' -GREEN='\033[0;32m' -NC='\033[0m' - -cd "$(dirname "$0")" - -DOWNLOAD_DIR=${1:-"$PWD/src"} - -fetch() { - if [ $# -ne 2 ]; then - echo "usage: fetch url output_file" - exit 1 - fi - local url=$1 - local file_name=$2 - if [ ! -e "$file_name" ]; then - echo -e "${GREEN}downloading $url ...${NC}" - curl -SL -o "$file_name" "$url" - echo -e "${GREEN}download $url${NC}" - else - echo "$file_name" already downloaded - fi -} - -mkdir -p "$DOWNLOAD_DIR" -pushd "$DOWNLOAD_DIR" - -echo -e "${GREEN}downloading resources into $DOWNLOAD_DIR${NC}" - -# google test -fetch https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz googletest-release-1.11.0.tar.gz - -# zlib -fetch https://github.com/madler/zlib/archive/v1.2.11.tar.gz zlib-1.2.11.tar.gz - -# snappy -fetch https://src.fedoraproject.org/lookaside/pkgs/snappy/snappy-1.1.1.tar.gz/8887e3b7253b22a31f5486bca3cbc1c2/snappy-1.1.1.tar.gz snappy-1.1.1.tar.gz - -# gflags -fetch https://github.com/gflags/gflags/archive/refs/tags/v2.2.0.tar.gz gflags-2.2.0.tar.gz - -# libunwind, use 1.5.0 only for aarch64 build -fetch https://github.com/libunwind/libunwind/archive/refs/tags/v1.1.tar.gz libunwind-1.1.tar.gz -fetch https://github.com/libunwind/libunwind/releases/download/v1.5/libunwind-1.5.0.tar.gz libunwind-1.5.0.tar.gz -# gperftools -fetch https://github.com/gperftools/gperftools/releases/download/gperftools-2.5/gperftools-2.5.tar.gz gperftools-2.5.tar.gz -# leveldb -fetch https://github.com/google/leveldb/archive/refs/tags/v1.20.tar.gz leveldb-1.20.tar.gz -# openssl -fetch https://github.com/openssl/openssl/archive/refs/tags/OpenSSL_1_1_1k.tar.gz OpenSSL_1_1_1k.tar.gz -fetch https://github.com/openssl/openssl/archive/OpenSSL_1_1_0.zip OpenSSL_1_1_0.zip -# glog -fetch https://github.com/google/glog/archive/refs/tags/v0.4.0.tar.gz glog-0.4.0.tar.gz -# bison -fetch https://ftp.gnu.org/gnu/bison/bison-3.4.tar.gz bison-3.4.tar.gz - -# absl, use 2e94e5b6e152df9fa9c2fe8c1b96e1393973d32c only for aarch64 build -fetch https://github.com/abseil/abseil-cpp/archive/a50ae369a30f99f79d7559002aba3413dac1bd48.tar.gz absl.tar.gz -fetch https://github.com/abseil/abseil-cpp/archive/2e94e5b6e152df9fa9c2fe8c1b96e1393973d32c.zip absl.zip - -# swig -fetch https://github.com/swig/swig/archive/v4.0.1.tar.gz swig-4.0.1.tar.gz - -# yaml-cpp -fetch https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.6.3.tar.gz yaml-cpp-0.6.3.tar.gz - -# sqlite -fetch https://github.com/sqlite/sqlite/archive/version-3.32.3.zip sqlite-3.32.3.zip - -# protobuf -fetch https://github.com/protocolbuffers/protobuf/archive/v3.6.1.3.tar.gz protobuf-3.6.1.3.tar.gz - -# llvm -fetch https://releases.llvm.org/9.0.0/llvm-9.0.0.src.tar.xz llvm-9.0.0.src.tar.xz - -# boost -fetch https://boostorg.jfrog.io/artifactory/main/release/1.69.0/source/boost_1_69_0.tar.gz boost_1_69_0.tar.gz - -# google benchmark -fetch https://github.com/google/benchmark/archive/v1.5.0.tar.gz v1.5.0.tar.gz - -# incubator brpc -fetch https://github.com/4paradigm/incubator-brpc/archive/4f69bc0c04abc0734962722ba43aecb4dd7a5dea.zip incubator-brpc.zip - -# zookeeper -fetch https://archive.apache.org/dist/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz apache-zookeeper-3.4.14.tar.gz - -# baidu common -fetch https://github.com/4paradigm/common/archive/refs/tags/v1.0.0.tar.gz common-1.0.0.tar.gz - -popd diff --git a/pack_all.sh b/pack_all.sh index bbb954f..2501906 100755 --- a/pack_all.sh +++ b/pack_all.sh @@ -11,33 +11,23 @@ cd "$(dirname "$0")" source var.sh -WORKDIR=${1:-.} +INSTALL_PREFIX=${1:-deps} + OS=$(os_type) ARCH=$(target_arch) - -ROOT=$(pwd) +DISTRO=$(distro) INSTALL_DIR="thirdparty-$(date +%Y-%m-%d)-$OS-$ARCH" -SRC_DIR="thirdsrc-$(date +%Y-%m-%d)" - -export OUT="$ROOT/$WORKDIR/$INSTALL_DIR" -unpack_and_install() { - local name=$1 - find . -maxdepth 1 -type f -iname "$name*.tar.gz" -exec tar xzf {} -C "$OUT" --strip-components=1 \; -} - -mkdir -p "$OUT" - -pushd "$WORKDIR" - -unpack_and_install boost -unpack_and_install llvm -unpack_and_install libother - -# needs a soft link lib64->lib for Mac OS -tar czf "$INSTALL_DIR.tar.gz" "$INSTALL_DIR" - -mkdir -p "$SRC_DIR" -tar xzf src/apache-zookeeper-*.tar.gz -C "$SRC_DIR" -tar czf "$SRC_DIR.tar.gz" "$SRC_DIR" - +if [ -n "$DISTRO" ]; then + INSTALL_DIR="$INSTALL_DIR-$DISTRO" +fi +# SRC_DIR="thirdsrc-$(date +%Y-%m-%d)" + +pushd "$INSTALL_PREFIX" + mv usr "$INSTALL_DIR" + # needs a soft link lib64->lib for Mac OS + tar czf "$INSTALL_DIR.tar.gz" "$INSTALL_DIR" + + # mv src "$SRC_DIR" + # tar xzf src/apache-zookeeper-*.tar.gz -C "$SRC_DIR" + # tar czf "$SRC_DIR.tar.gz" "$SRC_DIR" popd diff --git a/pack_boost.sh b/pack_boost.sh deleted file mode 100755 index 226fa8e..0000000 --- a/pack_boost.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -# the script will install boost and baidu-common together - -set -e - -cd "$(dirname "$0")" - -VERSION=1.69.0 - -if [ -d '/opt/rh/devtoolset-8' ]; then - # shellcheck disable=SC1091 - source /opt/rh/devtoolset-8/enable -fi - -if [ -d '/opt/rh/rh-python38' ]; then - # shellcheck disable=SC1091 - source /opt/rh/rh-python38/enable -fi - -source var.sh -OS=$(os_type) - -DEPS_SOURCE="$PWD/src" -DEPS_PREFIX="$PWD/boost-$VERSION" - -pushd "$DEPS_SOURCE"/ - -tar -zxf boost_1_69_0.tar.gz -pushd boost_1_69_0/ -if [[ "${OS}" = "darwin" ]]; then - ./bootstrap.sh compiler.blacklist clang -with-toolset=clang -else - ./bootstrap.sh -fi -./b2 link=static cxxflags=-fPIC cflags=-fPIC release install --prefix="$DEPS_PREFIX" - -popd - -tar xzf common-1.0.0.tar.gz -pushd common-1.0.0/ -if [[ "${OS}" = "darwin" ]]; then - # 'syscall' is deprecated: first deprecated in OS X 10.12 - sed -i '' 's/^#include /#include /' src/logging.cc - sed -i '' 's/thread_id = syscall(__NR_gettid)/pthread_threadid_np(0, \&thread_id)/' src/logging.cc -fi -make $MAKEOPTS INCLUDE_PATH="-Iinclude -I$DEPS_PREFIX/include" PREFIX="$DEPS_PREFIX" install - -popd - -popd - -tar czf boost-$VERSION-bin.tar.gz "boost-$VERSION/" diff --git a/pack_llvm.sh b/pack_llvm.sh deleted file mode 100755 index 0162acd..0000000 --- a/pack_llvm.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -set -e - -cd "$(dirname "$0")" - -source var.sh - -VERSION=9.0.0 - -if [ -d '/opt/rh/devtoolset-8' ]; then - # shellcheck disable=SC1091 - source /opt/rh/devtoolset-8/enable -fi - -if [ -d '/opt/rh/rh-python38' ]; then - # shellcheck disable=SC1091 - source /opt/rh/rh-python38/enable -fi - -DEPS_SOURCE="$PWD/src" -DEPS_PREFIX="$PWD/llvm-$VERSION" - -ARCH=$(target_arch) - -if [[ $ARCH = 'aarch64' ]]; then - LLVM_TARGETS="AArch64" -elif [[ $ARCH = 'x86'* || $ARCH = 'i386' ]]; then - LLVM_TARGETS="X86" -else - LLVM_TARGETS=all -fi - -echo "LLVM_TARGETS: $LLVM_TARGETS" - -pushd "$DEPS_SOURCE"/ - -tar xf llvm-$VERSION.src.tar.xz -pushd llvm-$VERSION.src/ -mkdir -p build && cd build - -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$DEPS_PREFIX" -DLLVM_TARGETS_TO_BUILD="$LLVM_TARGETS" -DCMAKE_CXX_FLAGS=-fPIC .. -make $MAKEOPTS -make install -popd - -popd - -tar czf llvm-$VERSION-bin.tar.gz "llvm-$VERSION/" diff --git a/pack_other.sh b/pack_other.sh deleted file mode 100755 index 76a1c44..0000000 --- a/pack_other.sh +++ /dev/null @@ -1,330 +0,0 @@ -#!/bin/bash - -# Copyright 2021 4Paradigm -# Copyright 2021 aceforeverd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# install_deps.sh: build & install dependencies. - -set -eE - -cd "$(dirname "$0")" - -if [ -d '/opt/rh/devtoolset-8' ]; then - # shellcheck disable=SC1091 - source /opt/rh/devtoolset-8/enable -fi - -if [ -d '/opt/rh/rh-python38' ]; then - # shellcheck disable=SC1091 - source /opt/rh/rh-python38/enable -fi - -source var.sh -OS=$(os_type) -ARCH=$(target_arch) - -VERSION=$(date +%Y-%m-%d) - -DEPS_SOURCE="$PWD/src" -DEPS_PREFIX="$PWD/libother-$VERSION" -DEPS_CONFIG="--prefix=$DEPS_PREFIX --disable-shared --with-pic" - -export CXXFLAGS=" -O3 -fPIC" -export CFLAGS=" -O3 -fPIC" - -mkdir -p "$DEPS_PREFIX/lib" "$DEPS_PREFIX/include" "$DEPS_SOURCE" -export PATH=${DEPS_PREFIX}/bin:$PATH - -pushd "$DEPS_SOURCE"/ - -if [ ! -f gtest_succ ]; then - echo "installing gtest ...." - tar xzf googletest-release-1.11.0.tar.gz - - pushd googletest-release-1.11.0 - cmake -H. -Bbuild -DCMAKE_INSTALL_PREFIX="$DEPS_PREFIX" -DCMAKE_CXX_FLAGS=-fPIC - cmake --build build -- $MAKEOPTS - cmake --build build --target install - popd - - touch gtest_succ - echo "install gtest done" -fi - -if [ -f "glog_succ" ]; then - echo "glog exist" -else - echo "installing glog ..." - tar xzf glog-0.4.0.tar.gz - pushd glog-0.4.0 - ./autogen.sh && CXXFLAGS=-fPIC ./configure --prefix="$DEPS_PREFIX" --enable-shared=no - make $MAKEOPTS install - popd - touch glog_succ - echo "installed glog" -fi - -if [ -f "gflags_succ" ]; then - echo "gflags-2.2.0.tar.gz exist" -else - tar zxf gflags-2.2.0.tar.gz - pushd gflags-2.2.0 - # Mac will failed in create build/ cuz the dir contains a file named 'BUILD', so we use 'cmake_build' as the build dir. - # gflags BUILD_SHARED_LIBS default is OFF. And if BUILD_SHARED_LIBS=OFF, BUILD_STATIC_LIBS will be ON. - cmake -H. -Bcmake_build -DCMAKE_INSTALL_PREFIX="$DEPS_PREFIX" -DGFLAGS_NAMESPACE=google -DCMAKE_CXX_FLAGS=-fPIC - cmake --build cmake_build -- $MAKEOPTS - cmake --build cmake_build --target install - popd - - touch gflags_succ - echo "install gflags done" -fi - -if [ -f "zlib_succ" ]; then - echo "zlib exist" -else - echo "installing zlib..." - tar xzf zlib-1.2.11.tar.gz - pushd zlib-1.2.11 - CFLAGS="-O3 -fPIC" ./configure --static --prefix="$DEPS_PREFIX" - make $MAKEOPTS - make install - popd - touch zlib_succ - echo "install zlib done" -fi - -if [ -f "protobuf_succ" ]; then - echo "protobuf exist" -else - echo "start install protobuf ..." - tar zxf protobuf-3.6.1.3.tar.gz - - pushd protobuf-*/ - ./autogen.sh && ./configure --disable-shared --with-pic --prefix "${DEPS_PREFIX}" CPPFLAGS=-I"$DEPS_PREFIX/include" LDFLAGS=-L"$DEPS_PREFIX/lib" - make $MAKEOPTS - make install - popd - - touch protobuf_succ - echo "install protobuf done" -fi - -if [ -f "snappy_succ" ]; then - echo "snappy exist" -else - echo "start install snappy ..." - tar zxf snappy-1.1.1.tar.gz - pushd snappy-1.1.1/ - ./configure $DEPS_CONFIG - make $MAKEOPTS - make install - popd - - touch snappy_succ - echo "install snappy done" -fi - -if [[ -f "unwind_succ" ]]; then - echo "unwind_exist" -elif [[ $OS = "darwin" ]]; then - echo "For Mac, libunwind doesn't need to be built separately" -else - if [[ $ARCH = 'aarch64' ]]; then - tar zxf libunwind-1.5.0.tar.gz - pushd libunwind-1.5.0/ - else - tar xzf libunwind-1.1.tar.gz - pushd libunwind-1.1/ - autoreconf -i - fi - ./configure --prefix="$DEPS_PREFIX" --enable-shared=no - make $MAKEOPTS - make install - popd - - touch unwind_succ -fi - -if [ -f "gperf_succ" ]; then - echo "gperf_succ exist" -else - tar zxf gperftools-2.5.tar.gz - pushd gperftools-2.5/ - ./configure --enable-cpu-profiler --enable-heap-checker --enable-heap-profiler --prefix="$DEPS_PREFIX" --enable-shared=no - make $MAKEOPTS - make install - popd - touch gperf_succ -fi - -if [ -f "leveldb_succ" ]; then - echo "leveldb exist" -else - # TODO fix compile on leveldb 1.23 - tar zxf leveldb-1.20.tar.gz - pushd leveldb-1.20 - make $MAKEOPTS OPT="-O2 -DNDEBUG -fPIC" - cp -rf include/* "$DEPS_PREFIX/include" - cp out-static/libleveldb.a "$DEPS_PREFIX/lib" - popd - touch leveldb_succ -fi - -if [ -f "openssl_succ" ]; then - echo "openssl exist" -else - if [[ $ARCH = 'aarch64' ]]; then - # static link issue in arm64: https://github.com/openssl/openssl/issues/10842 - tar xzf OpenSSL_1_1_1k.tar.gz - pushd openssl-OpenSSL_1_1_1k/ - ./config --prefix="$DEPS_PREFIX" --openssldir="$DEPS_PREFIX" no-afalgeng no-shared - else - unzip OpenSSL_1_1_0.zip - pushd openssl-OpenSSL_1_1_0 - # On Mac OS, sed must use `-i extension` for saving backups with the specified extension. - # But we can give a zero-length extension, no backup will be saved. - sed -i'' -e 's#qw/glob#qw/:glob#' Configure - sed -i'' -e 's#qw/glob#qw/:glob#' test/build.info - ./config --prefix="$DEPS_PREFIX" --openssldir="$DEPS_PREFIX" no-shared - fi - make $MAKEOPTS - make install - rm -rf "$DEPS_PREFIX"/lib/libssl.so* - rm -rf "$DEPS_PREFIX"/lib/libcrypto.so* - popd - touch openssl_succ - echo "openssl done" -fi - -if [[ $ARCH = 'aarch64' ]]; then - unzip absl.zip - pushd abseil-cpp-2e94e5b6e152df9fa9c2fe8c1b96e1393973d32c/ -else - tar xf absl.tar.gz - pushd abseil-cpp-a50ae369a30f99f79d7559002aba3413dac1bd48/ -fi -cmake -H. -Bbuild -DCMAKE_INSTALL_LIBDIR=lib \ - -DCMAKE_INSTALL_PREFIX="$DEPS_PREFIX" -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_CXX_STANDARD=17 -DABSL_USE_GOOGLETEST_HEAD=OFF -DABSL_RUN_TESTS=OFF \ - -DCMAKE_POSITION_INDEPENDENT_CODE=ON -cmake --build build -cmake --build build --target install -popd - -if [ -f "brpc_succ" ]; then - echo "brpc exist" -else - unzip incubator-brpc.zip - pushd incubator-brpc-*/ - if [[ $ARCH = aarch64 ]]; then - patch -ruN < "$DEPS_SOURCE/patch/incubator-brpc-aarch64.patch" - fi - sh config_brpc.sh --with-glog --headers="$DEPS_PREFIX/include" --libs="$DEPS_PREFIX/lib" - make $MAKEOPTS libbrpc.a output/include - cp -rf output/include/* "$DEPS_PREFIX/include/" - cp libbrpc.a "$DEPS_PREFIX/lib" - popd - - touch brpc_succ - echo "brpc done" -fi - -if [ -f "bison_succ" ]; then - echo "bison exist" -else - tar zxf bison-3.4.tar.gz - pushd bison-3.4 - ./configure --prefix="$DEPS_PREFIX" --enable-relocatable - make install - popd - touch bison_succ -fi - -if [ -f "benchmark_succ" ]; then - echo "benchmark exist" -else - tar zxf v1.5.0.tar.gz - pushd benchmark-1.5.0 - mkdir -p build - cd build - cmake -DCMAKE_INSTALL_PREFIX="$DEPS_PREFIX" -DCMAKE_CXX_FLAGS=-fPIC -DBENCHMARK_ENABLE_GTEST_TESTS=OFF .. - make $MAKEOPTS - make install - popd - touch benchmark_succ -fi - -if [ -f "swig_succ" ]; then - echo "swig exist" -else - tar -zxf swig-4.0.1.tar.gz - pushd swig-4.0.1 - ./autogen.sh - ./configure --without-pcre --prefix="$DEPS_PREFIX" - make $MAKEOPTS - make install - popd - touch swig_succ -fi - -if [ -f "yaml_succ" ]; then - echo "yaml-cpp installed" -else - tar -zxf yaml-cpp-0.6.3.tar.gz - pushd yaml-cpp-yaml-cpp-0.6.3 - mkdir -p build - cd build - cmake -DCMAKE_INSTALL_PREFIX="$DEPS_PREFIX" .. - make $MAKEOPTS - make install - popd - touch yaml_succ -fi - -if [ -f "sqlite_succ" ]; then - echo "sqlite installed" -else - unzip sqlite-*.zip - pushd sqlite-version-3.32.3 - mkdir -p build - cd build - ../configure --prefix="$DEPS_PREFIX" --disable-tcl --enable-shared=no - make $MAKEOPTS && make install - popd - touch sqlite_succ -fi - -if [ -f zookeeper_succ ]; then - echo "zookeeper installed" -else - tar -zxf apache-zookeeper-3.4.14.tar.gz - pushd zookeeper-3.4.14/zookeeper-client/zookeeper-client-c/ - if [[ $OS = "darwin" ]]; then - CC="clang" CFLAGS="$CFLAGS" ./configure --prefix="$DEPS_PREFIX" --enable-shared=no - else - autoreconf -if - # see https://issues.apache.org/jira/browse/ZOOKEEPER-3293 - CFLAGS="$CFLAGS -Wno-error=format-overflow=" ./configure --prefix="$DEPS_PREFIX" --enable-shared=no - fi - - make $MAKEOPTS - make install - popd -fi - -popd - -tar czf "libother-$VERSION.tar.gz" "libother-$VERSION"/ diff --git a/var.sh b/var.sh index 46ae036..4a04664 100644 --- a/var.sh +++ b/var.sh @@ -15,5 +15,11 @@ target_arch() { # if ARCH environment variable is not provided, use the host architecture echo "${ARCH:-$(arch)}" } + +distro() +{ + echo "${DISTRO:-""}" +} + _MAKEOPTS="-j$(nproc)" MAKEOPTS=${MAKEOPTS:-$_MAKEOPTS}