From 8d020ed760dbe4479db11040aa5e2c186446d381 Mon Sep 17 00:00:00 2001 From: fengzero Date: Mon, 26 Sep 2022 09:40:09 +0000 Subject: [PATCH] ci: build neuron by docker --- .github/workflows/ci.yml | 32 ++++++++++---------------------- install.sh | 36 +++++++++++++++++++----------------- 2 files changed, 29 insertions(+), 39 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac9dd6a2..c2936b7e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,22 +13,16 @@ jobs: strategy: matrix: arch: - - [aarch64-linux-gnu, aarch64, gcc-aarch64-linux-gnu, g++-aarch64-linux-gnu, /opt/externs/libs, arm64] - - [arm-linux-gnueabihf, armv4, gcc-arm-linux-gnueabihf, g++-arm-linux-gnueabihf, /opt/externs/libs, armhf] - - [x86_64-linux-gnu, x86_64, gcc, g++, /usr/local, amd64] + - [aarch64-linux-gnu, aarch64, arm64] + - [arm-linux-gnueabihf, armv4, armhf] + - [x86_64-linux-gnu, x86_64, amd64] + container: neugates/build:${{ matrix.arch[1] }}-2.2 steps: - uses: actions/checkout@v2 with: submodules: recursive - - name: install - run: sudo apt-get update && sudo apt-get install -y ${{ matrix.arch[2] }} ${{ matrix.arch[3] }} pkg-config alien - - - name: install dep - run: | - ./install.sh -d ${{ matrix.arch[4] }} -c ${{ matrix.arch[0] }} -a ${{ matrix.arch[1] }} - - name: get version id: get_version run: echo "::set-output name=version::$(cat version)" @@ -58,11 +52,11 @@ jobs: - name: Create neuron sdk package run: | - ./package-sdk.sh -p ${{ matrix.arch[5] }} -n neuron-sdk-${{ steps.get_version.outputs.version }} + ./package-sdk.sh -p ${{ matrix.arch[2] }} -n neuron-sdk-${{ steps.get_version.outputs.version }} - uses: actions/upload-artifact@v3 with: - name: neuron-sdk-${{ matrix.arch[5] }} + name: neuron-sdk-${{ matrix.arch[2] }} path: | neuron-sdk-*.tar.gz @@ -71,20 +65,14 @@ jobs: strategy: matrix: arch: - - [x86_64-linux-gnu, x86_64, gcc, g++, /usr/local, amd64] + - [x86_64-linux-gnu, x86_64, amd64] + container: neugates/build:${{ matrix.arch[1] }}-2.2 steps: - uses: actions/checkout@v2 with: submodules: recursive - - name: install - run: sudo apt-get update && sudo apt-get install -y ${{ matrix.arch[2] }} ${{ matrix.arch[3] }} pkg-config alien - - - name: install dep - run: | - ./install.sh -d ${{ matrix.arch[4] }} -c ${{ matrix.arch[0] }} -a ${{ matrix.arch[1] }} - - name: get version id: get_version run: echo "::set-output name=version::$(cat version)" @@ -98,11 +86,11 @@ jobs: - name: Create neuron sdk package run: | - ./package-sdk.sh -p ${{ matrix.arch[5] }} -n neuron-sdk-debug-${{ steps.get_version.outputs.version }} + ./package-sdk.sh -p ${{ matrix.arch[2] }} -n neuron-sdk-debug-${{ steps.get_version.outputs.version }} - uses: actions/upload-artifact@v3 with: - name: neuron-sdk-debug-${{ matrix.arch[5] }} + name: neuron-sdk-debug-${{ matrix.arch[2] }} path: | neuron-sdk-debug-*.tar.gz diff --git a/install.sh b/install.sh index 1738718d..ac673f6b 100755 --- a/install.sh +++ b/install.sh @@ -2,26 +2,26 @@ set -e -compiler_prefix="x86_64-linux-gnu" -dir="/usr/local/" install_dir= arch=x86_64 +compile= -while getopts ":c:d:a:" OPT; do +while getopts ":d:a:c:x:" OPT; do case ${OPT} in a) arch=$OPTARG ;; - c) - compiler_prefix=$OPTARG - ;; d) - dir=$OPTARG + install_dir=$OPTARG + ;; + c) + compile=$OPTARG ;; esac done -install_dir=${dir}/${compiler_prefix} +gcc_compile=${compile}-gcc +gxx_compile=${compile}-g++ #$1 rep #$2 tag @@ -31,8 +31,8 @@ function compile_source() { cd tmp git checkout -b br $2 mkdir build && cd build - cmake .. -DCMAKE_C_COMPILER=${compiler_prefix}-gcc \ - -DCMAKE_CXX_COMPILER=${compiler_prefix}-g++ \ + cmake .. -DCMAKE_C_COMPILER=${gcc_compile} \ + -DCMAKE_CXX_COMPILER=${gxx_compile} \ -DCMAKE_STAGING_PREFIX=${install_dir} \ -DCMAKE_PREFIX_PATH=${install_dir} \ $3 @@ -44,16 +44,17 @@ function compile_source() { function build_openssl() { echo "Installing openssl (1.1.1)" - if [ $compiler_prefix == "x86_64-linux-gnu" ]; then + if [ $arch == "x86_64" ]; then sudo apt-get install -y openssl libssl-dev else + git clone -b OpenSSL_1_1_1 https://github.com/openssl/openssl.git cd openssl mkdir -p ${install_dir}/openssl/ssl ./Configure linux-${arch} no-asm shared \ - --prefix=${install_dir}/ \ + --prefix=${install_dir} \ --openssldir=${install_dir}/openssl/ssl \ - --cross-compile-prefix=${compiler_prefix}- + --cross-compile-prefix=${compile}- make clean make -j4 make install_sw @@ -65,8 +66,9 @@ function build_openssl() { function build_zlog() { git clone -b 1.2.15 https://github.com/HardySimpson/zlog.git cd zlog - make CC=${compiler_prefix}-gcc - if [ $compiler_prefix == "x86_64-linux-gnu" ]; then + echo ${gcc_compile} + make CC=${gcc_compile} + if [ $arch == "x86_64" ]; then sudo make install sudo make PREFIX=${install_dir} install else @@ -82,7 +84,7 @@ function build_sqlite3() { cd sqlite3 ./configure --prefix=${install_dir} \ --disable-shared --disable-readline \ - --host ${arch} CC=${compiler_prefix}-gcc \ + --host ${arch} CC=${gcc_compile} \ && make -j4 \ && sudo make install cd ../ @@ -96,6 +98,6 @@ compile_source benmcollins/libjwt.git v1.13.1 "-DENABLE_PIC=ON -DBUILD_SHARED_LI compile_source neugates/MQTT-C.git HEAD "-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DMQTT_C_OpenSSL_SUPPORT=ON -DMQTT_C_EXAMPLES=OFF" build_sqlite3 -if [ $compiler_prefix == "x86_64-linux-gnu" ]; then +if [ $arch == "x86_64" ]; then compile_source google/googletest.git release-1.11.0 fi