Skip to content

Commit

Permalink
Add macOS build and parse to CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcserep committed Feb 7, 2024
1 parent cbb76ab commit f29f518
Show file tree
Hide file tree
Showing 11 changed files with 154 additions and 20 deletions.
70 changes: 70 additions & 0 deletions .github/scripts/macos-12/compile_build.sh
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions .github/scripts/macos-12/download_build.sh
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 6 additions & 0 deletions .github/scripts/macos-12/postcompile_build.sh
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions .github/scripts/macos-12/setup_build.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions .github/scripts/macos-12/setup_postgresql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# Install PostgreSQL
brew install postgresql@14
4 changes: 4 additions & 0 deletions .github/scripts/macos-12/setup_sqlite3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# Install SQLite3
brew install sqlite
4 changes: 0 additions & 4 deletions .github/scripts/ubuntu-20.04/postcompile_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/
3 changes: 3 additions & 0 deletions .github/scripts/ubuntu-20.04/setup_build.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/scripts/ubuntu-22.04/postcompile_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions .github/scripts/ubuntu-22.04/setup_build.sh
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
20 changes: 7 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand 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 }}
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f29f518

Please sign in to comment.