Skip to content

Commit 2e02409

Browse files
committed
Add macOS build and parse to CI.
1 parent 999dd59 commit 2e02409

File tree

12 files changed

+155
-21
lines changed

12 files changed

+155
-21
lines changed
+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash
2+
3+
# Compile dependencies that cannot be acquired via the official repositories
4+
5+
mkdir -p ${INSTALL_PATH}
6+
7+
## Compile Thrift
8+
CXXFLAGS_OLD=$CXXFLAGS
9+
LDFLAGS_OLD=$LDFLAGS
10+
export CXXFLAGS="$CXXFLAGS -I/opt/homebrew/include"
11+
export LDFLAGS="$LDFLAGS -L/opt/homebrew/lib"
12+
export CXXFLAGS="$CXXFLAGS -Wno-error"
13+
14+
tar -xvf ${DOWNLOAD_PATH}/thrift-0.16.0.tar.gz
15+
cd thrift-0.16.0
16+
./configure --prefix=${INSTALL_PATH}/thrift --silent --without-python \
17+
--enable-libtool-lock --enable-tutorial=no --enable-tests=no \
18+
--with-libevent --with-zlib --without-nodejs --without-lua \
19+
--without-ruby --without-csharp --without-erlang --without-perl \
20+
--without-php --without-php_extension --without-dart \
21+
--without-haskell --without-go --without-rs --without-haxe \
22+
--without-dotnetcore --without-d --without-qt4 --without-qt5 \
23+
--without-java --without-swift \
24+
--with-openssl=/opt/homebrew/opt/openssl
25+
26+
make install -j $(nproc)
27+
28+
export CXXFLAGS=$CXXFLAGS_OLD
29+
export LDFLAGS=$LDFLAGS_OLD
30+
31+
## Compile build2
32+
33+
sh "${DOWNLOAD_PATH}/install_latest_build2.sh" ${INSTALL_PATH}/build2
34+
35+
## Compile libodb runtime libraries
36+
mkdir -p ${DOWNLOAD_PATH}/libodb
37+
cd ${DOWNLOAD_PATH}/libodb
38+
${INSTALL_PATH}/build2/bin/bpkg create --quiet --jobs $(nproc) cc \
39+
config.cxx=g++ \
40+
config.cc.coptions=-O3 \
41+
config.bin.rpath=${INSTALL_PATH}/odb/lib \
42+
config.install.root=${INSTALL_PATH}/odb
43+
44+
### Getting the source
45+
${INSTALL_PATH}/build2/bin/bpkg add https://pkg.cppget.org/1/beta --trust-yes
46+
${INSTALL_PATH}/build2/bin/bpkg fetch --trust-yes
47+
48+
### Building ODB runtime library
49+
${INSTALL_PATH}/build2/bin/bpkg build libodb --yes
50+
${INSTALL_PATH}/build2/bin/bpkg build libodb-sqlite --yes
51+
${INSTALL_PATH}/build2/bin/bpkg build libodb-pgsql --yes
52+
${INSTALL_PATH}/build2/bin/bpkg install --all --recursive
53+
54+
## Compile odb compiler
55+
mkdir -p ${DOWNLOAD_PATH}/odb
56+
cd ${DOWNLOAD_PATH}/odb
57+
bpkg create --quiet --jobs $(nproc) cc \
58+
config.cxx=g++-13 \
59+
config.cc.poptions=-I/opt/homebrew/include \
60+
config.cc.coptions=-O3 \
61+
config.bin.rpath=${INSTALL_PATH}/odb/lib \
62+
config.install.root=${INSTALL_PATH}/odb
63+
64+
### Getting the source
65+
bpkg add https://pkg.cppget.org/1/beta --trust-yes
66+
bpkg fetch --trust-yes
67+
68+
### Building ODB Compiler
69+
bpkg build odb --yes
70+
bpkg install odb
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# Download installers for compiled dependencies
4+
5+
mkdir -p "${DOWNLOAD_PATH}"
6+
7+
## Thrift 0.16
8+
9+
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"
10+
11+
## ODB
12+
13+
wget -O "${DOWNLOAD_PATH}/install_latest_build2.sh" "https://github.com/Ericsson/CodeCompass/raw/master/scripts/install_latest_build2.sh"
14+
build2_version=$(sh "${DOWNLOAD_PATH}/install_latest_build2.sh" --version)
15+
odb_signature=$(wget -qO- https://pkg.cppget.org/1/beta/signature.manifest)
16+
17+
# Calculate hash of dependencies for Github Cache Action
18+
19+
dependencies_to_hash=("thrift-0.16.0.tar.gz")
20+
21+
concatenated_hashes=""
22+
for file in "${dependencies_to_hash[@]}"; do
23+
file_hash=$(md5sum "${DOWNLOAD_PATH}/${file}" | awk '{print $1}')
24+
concatenated_hashes="${concatenated_hashes}${file_hash}"
25+
done
26+
concatenated_hashes="${concatenated_hashes}${build2_version}${odb_signature}"
27+
28+
hash_value=$(echo -n "$concatenated_hashes" | md5sum | awk '{print $1}')
29+
30+
## Save said hash
31+
32+
### Restore action
33+
echo "macos-12-compile-hash-key=${hash_value}" >> "$GITHUB_OUTPUT"
34+
35+
### Save action
36+
echo "CACHE_KEY=${hash_value}" >> "$GITHUB_ENV"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
# Post compilation configuration for building (environmental variables, library location settings etc..)
4+
5+
echo "${INSTALL_PATH}/odb/bin" >> $GITHUB_PATH
6+
echo "CMAKE_PREFIX_PATH=${INSTALL_PATH}/odb:$CMAKE_PREFIX_PATH" >> $GITHUB_ENV
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
# Install available dependencies from HomeBrew
4+
brew install wget
5+
brew install node
6+
brew install sqlite
7+
brew install cmake
8+
brew install llvm@15
9+
brew install gcc
10+
brew install boost
11+
brew install bison
12+
brew install graphviz
13+
brew install googletest
14+
brew install libgit2
15+
brew install libmagic
16+
brew install openssl@3
17+
brew install gnu-sed
18+
brew install coreutils
19+
20+
# Place Bison on the PATH
21+
echo "/opt/homebrew/opt/bison/bin" >> $GITHUB_PATH
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
# Install PostgreSQL
4+
brew install postgresql@14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
# Install SQLite3
4+
brew install sqlite

.github/scripts/ubuntu-20.04/postcompile_build.sh

-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,3 @@
22

33
echo "${INSTALL_PATH}/thrift/bin" >> $GITHUB_PATH
44
echo "CMAKE_PREFIX_PATH=${INSTALL_PATH}/thrift:$CMAKE_PREFIX_PATH" >> $GITHUB_ENV
5-
6-
# Clean up dependency sources and intermediate binaries to save space
7-
rm -f ${DOWNLOAD_PATH}/thrift-0.16.0.tar.gz
8-
rm -rf ${DOWNLOAD_PATH}/thrift-0.16.0/

.github/scripts/ubuntu-20.04/setup_build.sh

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
22

3+
# Update package repository
4+
sudo apt-get update
5+
36
# Add official LLVM repositories
47
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
58
echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main" | sudo tee /etc/apt/sources.list.d/llvm.list

.github/scripts/ubuntu-22.04/postcompile_build.sh

-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,3 @@
44

55
echo "${INSTALL_PATH}/odb/bin" >> $GITHUB_PATH
66
echo "CMAKE_PREFIX_PATH=${INSTALL_PATH}/odb:$CMAKE_PREFIX_PATH" >> $GITHUB_ENV
7-
8-
# Clean up dependency sources and intermediate binaries to save space
9-
rm -rf ${DOWNLOAD_PATH}/odb

.github/scripts/ubuntu-22.04/setup_build.sh

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
22

3+
# Update package repository
4+
sudo apt-get update
5+
36
# Install required packages for CodeCompass build
47
sudo apt install git cmake make g++ libboost-all-dev \
58
llvm-15-dev clang-15 libclang-15-dev \

.github/workflows/ci.yml

+7-13
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ on: [push, pull_request, workflow_dispatch]
44

55
env:
66
BUILD_TYPE: Debug
7-
## For locally compiled dependencies
7+
# For locally compiled dependencies
88
INSTALL_PATH: ${{github.workspace}}/dependencies/install
9-
## Temp directory for installers of the downloaded dependencies
9+
# Temp directory for installers of the downloaded dependencies
1010
DOWNLOAD_PATH: ${{github.workspace}}/dependencies/download
1111

1212
permissions: read-all
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
matrix:
1919
db: [postgresql, sqlite3]
20-
os: [ubuntu-20.04, ubuntu-22.04]
20+
os: [ubuntu-20.04, ubuntu-22.04, macos-12]
2121
fail-fast: false
2222

2323
runs-on: ${{ matrix.os }}
@@ -45,9 +45,6 @@ jobs:
4545
steps:
4646
- uses: actions/checkout@v3
4747

48-
- name: Update apt-get
49-
run: sudo apt-get update
50-
5148
- name: Install required packages for build
5249
run: ./.github/scripts/${{ matrix.os }}/setup_build.sh
5350

@@ -165,13 +162,13 @@ jobs:
165162
zip -Rq ${{github.workspace}}/artifacts/codecompass-${{ matrix.os }}-${{ matrix.db }}-compiletime.zip *.c *.h *.cpp *.hpp *.cxx *.hxx *.ixx *.js compile_commands.json
166163
167164
- name: Upload CodeCompass binaries
168-
uses: actions/upload-artifact@v2
165+
uses: actions/upload-artifact@v3
169166
with:
170167
name: codecompass-${{ matrix.os }}-${{ matrix.db }}-bin
171168
path: ${{github.workspace}}/artifacts/codecompass-${{ matrix.os }}-${{ matrix.db }}-bin.zip
172169

173170
- name: Upload CodeCompass compile-time source files
174-
uses: actions/upload-artifact@v2
171+
uses: actions/upload-artifact@v3
175172
with:
176173
name: codecompass-${{ matrix.os }}-${{ matrix.db }}-compiletime
177174
path: ${{github.workspace}}/artifacts/codecompass-${{ matrix.os }}-${{ matrix.db }}-compiletime.zip
@@ -209,9 +206,6 @@ jobs:
209206
steps:
210207
- uses: actions/checkout@v3
211208

212-
- name: Update apt-get
213-
run: sudo apt-get update
214-
215209
# We need build dependencies for CodeCompass, as it will parsed as well
216210
- name: Install required packages for build
217211
run: ./.github/scripts/${{ matrix.os }}/setup_build.sh
@@ -241,13 +235,13 @@ jobs:
241235
${{ matrix.os }}-compile-install-${{ needs.build.outputs.ubuntu-22-04-compile-hash-key }}
242236
243237
- name: Download CodeCompass binaries
244-
uses: actions/download-artifact@v2
238+
uses: actions/download-artifact@v3
245239
with:
246240
name: codecompass-${{ matrix.os }}-${{ matrix.db }}-bin
247241
path: ${{github.workspace}}/artifacts
248242

249243
- name: Download CodeCompass compile-time source files
250-
uses: actions/download-artifact@v2
244+
uses: actions/download-artifact@v3
251245
with:
252246
name: codecompass-${{ matrix.os }}-${{ matrix.db }}-compiletime
253247
path: ${{github.workspace}}/artifacts

plugins/cpp_metrics/service/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ target_link_libraries(cxxmetricsservice
5858
if(APPLE)
5959
# Use Linux-like linking behaviour, dynamic libraries may contain references without implementation.
6060
# cppmetricsservice references headers from the webserver without implementation
61-
set_target_properties(cppmetricsservice PROPERTIES LINK_FLAGS
61+
set_target_properties(cxxmetricsservice PROPERTIES LINK_FLAGS
6262
"-undefined dynamic_lookup")
6363
endif(APPLE)
6464

0 commit comments

Comments
 (0)