From f29f5181bef89aa7c3949f920a2d6c75e61abfac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Cser=C3=A9p?= Date: Wed, 7 Feb 2024 18:26:11 +0100 Subject: [PATCH] Add macOS build and parse to CI. --- .github/scripts/macos-12/compile_build.sh | 70 +++++++++++++++++++ .github/scripts/macos-12/download_build.sh | 36 ++++++++++ .github/scripts/macos-12/postcompile_build.sh | 6 ++ .github/scripts/macos-12/setup_build.sh | 21 ++++++ .github/scripts/macos-12/setup_postgresql.sh | 4 ++ .github/scripts/macos-12/setup_sqlite3.sh | 4 ++ .../scripts/ubuntu-20.04/postcompile_build.sh | 4 -- .github/scripts/ubuntu-20.04/setup_build.sh | 3 + .../scripts/ubuntu-22.04/postcompile_build.sh | 3 - .github/scripts/ubuntu-22.04/setup_build.sh | 3 + .github/workflows/ci.yml | 20 ++---- 11 files changed, 154 insertions(+), 20 deletions(-) create mode 100644 .github/scripts/macos-12/compile_build.sh create mode 100644 .github/scripts/macos-12/download_build.sh create mode 100644 .github/scripts/macos-12/postcompile_build.sh create mode 100644 .github/scripts/macos-12/setup_build.sh create mode 100644 .github/scripts/macos-12/setup_postgresql.sh create mode 100644 .github/scripts/macos-12/setup_sqlite3.sh diff --git a/.github/scripts/macos-12/compile_build.sh b/.github/scripts/macos-12/compile_build.sh new file mode 100644 index 000000000..9d80b6180 --- /dev/null +++ b/.github/scripts/macos-12/compile_build.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# Compile dependencies that cannot be acquired via the official repositories + +mkdir -p ${INSTALL_PATH} + +## Compile Thrift +CXXFLAGS_OLD=$CXXFLAGS +LDFLAGS_OLD=$LDFLAGS +export CXXFLAGS="$CXXFLAGS -I/opt/homebrew/include" +export LDFLAGS="$LDFLAGS -L/opt/homebrew/lib" +export CXXFLAGS="$CXXFLAGS -Wno-error" + +tar -xvf ${DOWNLOAD_PATH}/thrift-0.16.0.tar.gz +cd thrift-0.16.0 +./configure --prefix=${INSTALL_PATH}/thrift --silent --without-python \ + --enable-libtool-lock --enable-tutorial=no --enable-tests=no \ + --with-libevent --with-zlib --without-nodejs --without-lua \ + --without-ruby --without-csharp --without-erlang --without-perl \ + --without-php --without-php_extension --without-dart \ + --without-haskell --without-go --without-rs --without-haxe \ + --without-dotnetcore --without-d --without-qt4 --without-qt5 \ + --without-java --without-swift \ + --with-openssl=/opt/homebrew/opt/openssl + +make install -j $(nproc) + +export CXXFLAGS=$CXXFLAGS_OLD +export LDFLAGS=$LDFLAGS_OLD + +## Compile build2 + +sh "${DOWNLOAD_PATH}/install_latest_build2.sh" ${INSTALL_PATH}/build2 + +## Compile libodb runtime libraries +mkdir -p ${DOWNLOAD_PATH}/libodb +cd ${DOWNLOAD_PATH}/libodb +${INSTALL_PATH}/build2/bin/bpkg create --quiet --jobs $(nproc) cc \ + config.cxx=g++ \ + config.cc.coptions=-O3 \ + config.bin.rpath=${INSTALL_PATH}/odb/lib \ + config.install.root=${INSTALL_PATH}/odb + +### Getting the source +${INSTALL_PATH}/build2/bin/bpkg add https://pkg.cppget.org/1/beta --trust-yes +${INSTALL_PATH}/build2/bin/bpkg fetch --trust-yes + +### Building ODB runtime library +${INSTALL_PATH}/build2/bin/bpkg build libodb --yes +${INSTALL_PATH}/build2/bin/bpkg build libodb-sqlite --yes +${INSTALL_PATH}/build2/bin/bpkg build libodb-pgsql --yes +${INSTALL_PATH}/build2/bin/bpkg install --all --recursive + +## Compile odb compiler +mkdir -p ${DOWNLOAD_PATH}/odb +cd ${DOWNLOAD_PATH}/odb +bpkg create --quiet --jobs $(nproc) cc \ + config.cxx=g++-13 \ + config.cc.poptions=-I/opt/homebrew/include \ + config.cc.coptions=-O3 \ + config.bin.rpath=${INSTALL_PATH}/odb/lib \ + config.install.root=${INSTALL_PATH}/odb + +### Getting the source +bpkg add https://pkg.cppget.org/1/beta --trust-yes +bpkg fetch --trust-yes + +### Building ODB Compiler +bpkg build odb --yes +bpkg install odb \ No newline at end of file diff --git a/.github/scripts/macos-12/download_build.sh b/.github/scripts/macos-12/download_build.sh new file mode 100644 index 000000000..6147ca878 --- /dev/null +++ b/.github/scripts/macos-12/download_build.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Download installers for compiled dependencies + +mkdir -p "${DOWNLOAD_PATH}" + +## Thrift 0.16 + +wget -O ${DOWNLOAD_PATH}/thrift-0.16.0.tar.gz "http://archive.apache.org/dist/thrift/0.16.0/thrift-0.16.0.tar.gz" + +## ODB + +wget -O "${DOWNLOAD_PATH}/install_latest_build2.sh" "https://github.com/Ericsson/CodeCompass/raw/master/scripts/install_latest_build2.sh" +build2_version=$(sh "${DOWNLOAD_PATH}/install_latest_build2.sh" --version) +odb_signature=$(wget -qO- https://pkg.cppget.org/1/beta/signature.manifest) + +# Calculate hash of dependencies for Github Cache Action + +dependencies_to_hash=("thrift-0.16.0.tar.gz") + +concatenated_hashes="" +for file in "${dependencies_to_hash[@]}"; do + file_hash=$(md5sum "${DOWNLOAD_PATH}/${file}" | awk '{print $1}') + concatenated_hashes="${concatenated_hashes}${file_hash}" +done +concatenated_hashes="${concatenated_hashes}${build2_version}${odb_signature}" + +hash_value=$(echo -n "$concatenated_hashes" | md5sum | awk '{print $1}') + +## Save said hash + +### Restore action +echo "macos-12-compile-hash-key=${hash_value}" >> "$GITHUB_OUTPUT" + +### Save action +echo "CACHE_KEY=${hash_value}" >> "$GITHUB_ENV" \ No newline at end of file diff --git a/.github/scripts/macos-12/postcompile_build.sh b/.github/scripts/macos-12/postcompile_build.sh new file mode 100644 index 000000000..48515d214 --- /dev/null +++ b/.github/scripts/macos-12/postcompile_build.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# Post compilation configuration for building (environmental variables, library location settings etc..) + +echo "${INSTALL_PATH}/odb/bin" >> $GITHUB_PATH +echo "CMAKE_PREFIX_PATH=${INSTALL_PATH}/odb:$CMAKE_PREFIX_PATH" >> $GITHUB_ENV diff --git a/.github/scripts/macos-12/setup_build.sh b/.github/scripts/macos-12/setup_build.sh new file mode 100644 index 000000000..842a263f6 --- /dev/null +++ b/.github/scripts/macos-12/setup_build.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Install available dependencies from HomeBrew +brew install wget +brew install node +brew install sqlite +brew install cmake +brew install llvm@15 +brew install gcc +brew install boost +brew install bison +brew install graphviz +brew install googletest +brew install libgit2 +brew install libmagic +brew install openssl@3 +brew install gnu-sed +brew install coreutils + +# Place Bison on the PATH +echo "/opt/homebrew/opt/bison/bin" >> $GITHUB_PATH \ No newline at end of file diff --git a/.github/scripts/macos-12/setup_postgresql.sh b/.github/scripts/macos-12/setup_postgresql.sh new file mode 100644 index 000000000..406ba58e7 --- /dev/null +++ b/.github/scripts/macos-12/setup_postgresql.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# Install PostgreSQL +brew install postgresql@14 \ No newline at end of file diff --git a/.github/scripts/macos-12/setup_sqlite3.sh b/.github/scripts/macos-12/setup_sqlite3.sh new file mode 100644 index 000000000..e881585eb --- /dev/null +++ b/.github/scripts/macos-12/setup_sqlite3.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# Install SQLite3 +brew install sqlite \ No newline at end of file diff --git a/.github/scripts/ubuntu-20.04/postcompile_build.sh b/.github/scripts/ubuntu-20.04/postcompile_build.sh index 8b071bdf8..4769932cb 100644 --- a/.github/scripts/ubuntu-20.04/postcompile_build.sh +++ b/.github/scripts/ubuntu-20.04/postcompile_build.sh @@ -2,7 +2,3 @@ echo "${INSTALL_PATH}/thrift/bin" >> $GITHUB_PATH echo "CMAKE_PREFIX_PATH=${INSTALL_PATH}/thrift:$CMAKE_PREFIX_PATH" >> $GITHUB_ENV - -# Clean up dependency sources and intermediate binaries to save space -rm -f ${DOWNLOAD_PATH}/thrift-0.16.0.tar.gz -rm -rf ${DOWNLOAD_PATH}/thrift-0.16.0/ \ No newline at end of file diff --git a/.github/scripts/ubuntu-20.04/setup_build.sh b/.github/scripts/ubuntu-20.04/setup_build.sh index a19925d6e..c696d2708 100755 --- a/.github/scripts/ubuntu-20.04/setup_build.sh +++ b/.github/scripts/ubuntu-20.04/setup_build.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Update package repository +sudo apt-get update + # Add official LLVM repositories wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main" | sudo tee /etc/apt/sources.list.d/llvm.list diff --git a/.github/scripts/ubuntu-22.04/postcompile_build.sh b/.github/scripts/ubuntu-22.04/postcompile_build.sh index c33212c69..48515d214 100755 --- a/.github/scripts/ubuntu-22.04/postcompile_build.sh +++ b/.github/scripts/ubuntu-22.04/postcompile_build.sh @@ -4,6 +4,3 @@ echo "${INSTALL_PATH}/odb/bin" >> $GITHUB_PATH echo "CMAKE_PREFIX_PATH=${INSTALL_PATH}/odb:$CMAKE_PREFIX_PATH" >> $GITHUB_ENV - -# Clean up dependency sources and intermediate binaries to save space -rm -rf ${DOWNLOAD_PATH}/odb \ No newline at end of file diff --git a/.github/scripts/ubuntu-22.04/setup_build.sh b/.github/scripts/ubuntu-22.04/setup_build.sh index 99627a015..3545d3bcf 100755 --- a/.github/scripts/ubuntu-22.04/setup_build.sh +++ b/.github/scripts/ubuntu-22.04/setup_build.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Update package repository +sudo apt-get update + # Install required packages for CodeCompass build sudo apt install git cmake make g++ libboost-all-dev \ llvm-15-dev clang-15 libclang-15-dev \ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f542fa96..7ef4e23e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,9 +4,9 @@ on: [push, pull_request, workflow_dispatch] env: BUILD_TYPE: Debug - ## For locally compiled dependencies + # For locally compiled dependencies INSTALL_PATH: ${{github.workspace}}/dependencies/install - ## Temp directory for installers of the downloaded dependencies + # Temp directory for installers of the downloaded dependencies DOWNLOAD_PATH: ${{github.workspace}}/dependencies/download permissions: read-all @@ -17,7 +17,7 @@ jobs: strategy: matrix: db: [postgresql, sqlite3] - os: [ubuntu-20.04, ubuntu-22.04] + os: [ubuntu-20.04, ubuntu-22.04, macos-12] fail-fast: false runs-on: ${{ matrix.os }} @@ -45,9 +45,6 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Update apt-get - run: sudo apt-get update - - name: Install required packages for build run: ./.github/scripts/${{ matrix.os }}/setup_build.sh @@ -165,13 +162,13 @@ jobs: zip -Rq ${{github.workspace}}/artifacts/codecompass-${{ matrix.os }}-${{ matrix.db }}-compiletime.zip *.c *.h *.cpp *.hpp *.cxx *.hxx *.ixx *.js compile_commands.json - name: Upload CodeCompass binaries - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: codecompass-${{ matrix.os }}-${{ matrix.db }}-bin path: ${{github.workspace}}/artifacts/codecompass-${{ matrix.os }}-${{ matrix.db }}-bin.zip - name: Upload CodeCompass compile-time source files - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: codecompass-${{ matrix.os }}-${{ matrix.db }}-compiletime path: ${{github.workspace}}/artifacts/codecompass-${{ matrix.os }}-${{ matrix.db }}-compiletime.zip @@ -209,9 +206,6 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Update apt-get - run: sudo apt-get update - # We need build dependencies for CodeCompass, as it will parsed as well - name: Install required packages for build run: ./.github/scripts/${{ matrix.os }}/setup_build.sh @@ -241,13 +235,13 @@ jobs: ${{ matrix.os }}-compile-install-${{ needs.build.outputs.ubuntu-22-04-compile-hash-key }} - name: Download CodeCompass binaries - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: codecompass-${{ matrix.os }}-${{ matrix.db }}-bin path: ${{github.workspace}}/artifacts - name: Download CodeCompass compile-time source files - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: codecompass-${{ matrix.os }}-${{ matrix.db }}-compiletime path: ${{github.workspace}}/artifacts