Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to build with Clang #507

Merged
merged 9 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 0 additions & 102 deletions .github/composite-actions/download-libraries/action.yml

This file was deleted.

186 changes: 186 additions & 0 deletions .github/composite-actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
name: 'Install dependencies'
description: 'Download and install build system and libraries'
inputs:
os:
type: string
description: 'Any default runner name in Github Actions'
required: true

toolset:
type: choice
options:
gcc
llvm-clang
apple-clang
default: gcc

install-toolset:
p-senichenkov marked this conversation as resolved.
Show resolved Hide resolved
type: boolean
default: true

install-boost:
type: boolean
default: true

download-googletest:
type: boolean
description: 'Download googletest'
default: true

download-pybind:
type: boolean
description: 'Download pybind11'
default: false

runs:
using: 'composite'
steps:
- uses: actions/checkout@v4

- name: Get short OS name
shell: bash
run: |
function get_short_os_name() {
if [[ $1 == *"ubuntu"* ]]; then
echo "ubuntu"
elif [[ $1 == *"macos"* ]]; then
echo "macos"
else
echo "ERROR: unknown OS"
exit 1
fi
}

echo "OS=$(get_short_os_name ${{ inputs.os }})" >> $GITHUB_ENV

- name: Install build tools using apt
run: |
sudo apt-get update -y
sudo apt-get install cmake build-essential -y
shell: bash
if: env.OS == 'ubuntu'
- name: Install build tools using brew
run: brew install make cmake
shell: bash
if: env.OS == 'macos'

- name: Install GCC toolset
p-senichenkov marked this conversation as resolved.
Show resolved Hide resolved
run: |
sudo apt-get install gcc-10 g++-10 -y
shell: bash
if: inputs.install-toolset == 'true' && inputs.toolset == 'gcc'
- name: Install Clang toolset (on Linux)
# "all" option is needed to install libc++ and libc++abi
# apt is hardcoded in llvm.sh, so we can't use it everywhere
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 17 all
shell: bash
if: inputs.install-toolset == 'true' && inputs.toolset == 'llvm-clang' && env.OS == 'ubuntu'
- name: Install LLVM Clang toolset (on macOS)
run: brew install llvm@17
shell: bash
if: inputs.install-toolset == 'true' && inputs.toolset == 'llvm-clang' && env.OS == 'macos'
# Apple Clang is installed by default on macOS runner

- name: Make lib directory
run: |
mkdir -p lib
shell: bash

- name: Download atomicbitvector
uses: ./.github/composite-actions/download-library
with:
directory: atomicbitvector
download-command: git clone https://github.com/ekg/atomicbitvector.git --depth 1

- name: Download better-enums
uses: ./.github/composite-actions/download-library
with:
directory: better-enums
download-command: git clone https://github.com/aantron/better-enums.git --branch 0.11.3 --depth 1

- name: Download boost
uses: ./.github/composite-actions/download-library
with:
directory: boost
download-command: wget -O boost_1_85_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.85.0/boost_1_85_0.tar.gz/download && tar xzvf boost_1_85_0.tar.gz && mv boost_1_85_0 boost

- name: Download easyloggingpp
uses: ./.github/composite-actions/download-library
with:
directory: easyloggingpp
download-command: git clone https://github.com/amrayn/easyloggingpp/ --branch v9.97.0 --depth 1

- name: Download emhash
uses: ./.github/composite-actions/download-library
with:
directory: emhash
download-command: git clone https://github.com/ktprime/emhash.git --depth 1

- name: Download googletest
uses: ./.github/composite-actions/download-library
with:
directory: googletest
download-command: git clone https://github.com/google/googletest/ --branch v1.14.0 --depth 1
if: inputs.download-googletest != 'false'

- name: Download pybind11
uses: ./.github/composite-actions/download-library
with:
directory: pybind11
download-command: git clone https://github.com/pybind/pybind11.git --branch v2.13.4 --depth 1
if: inputs.download-pybind != 'false'

- name: Install Boost built with GCC (on Ubuntu)
run: |
cd lib/boost
./bootstrap.sh --with-libraries=container,thread,graph
sudo ./b2 install --prefix=/usr
shell: bash
if: inputs.install-boost == 'true' && inputs.toolset == 'gcc'
- name: Install Boost built with Clang (on Linux)
run: |
cd lib/boost
./bootstrap.sh
sudo ./b2 install -a --prefix=/usr toolset=clang cxxflags="-stdlib=libc++" \
linkflags="-stdlib=libc++"
shell: bash
if: inputs.install-boost == 'true' && inputs.toolset == 'llvm-clang' && env.OS == 'ubuntu'
- name: Install Boost built with LLVM Clang (on macOS)
run: |
cd lib/boost
./bootstrap.sh
echo "using darwin : : $(brew --prefix llvm@17)/bin/clang++ ;" > user-config.jam
sudo ./b2 install -a --user-config=user-config.jam --prefix=/usr/local \
cxxflags="-std=c++11 -I$(brew --prefix llvm@17)/include" \
linkflags="-L$(brew --prefix llvm@17)/lib/c++"
shell: bash
if: inputs.install-boost == 'true' && inputs.toolset == 'llvm-clang' && env.OS == 'macos'
- name: Install Boost built with Apple Clang
run: brew install boost
shell: bash
if: inputs.install-boost == 'true' && inputs.toolset == 'apple-clang'

- name: Download frozen
uses: ./.github/composite-actions/download-library
with:
directory: frozen
download-command: git clone https://github.com/serge-sans-paille/frozen.git --depth 1

# Uncomment this if we set up our own git lfs server
# - name: Install git-lfs
# run: |
# curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
# git lfs install
# shell: bash
# - name: Generate lfs file list
# run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
# shell: bash
# - name: Restore lfs cache
# uses: actions/cache@v3
# id: lfs-cache
# with:
# path: .git/lfs
# key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1
48 changes: 43 additions & 5 deletions .github/workflows/bindings-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,59 @@ on:
workflow_dispatch:
jobs:
test-python-bindings:
runs-on: ubuntu-latest
name: Run python-bindings tests on ${{ matrix.os }} with ${{ matrix.toolset }}
strategy:
matrix:
include:
- os: ubuntu-latest
toolset: gcc
env: CXX=g++-10

- os: ubuntu-latest
toolset: llvm-clang
# CMake cannot locate clang-scan-deps without `CC=clang`
# https://github.com/emscripten-core/emscripten/issues/22305
env: CC=clang CXX=clang++-17 CXXFLAGS="-stdlib=libc++" LDFLAGS="-lc++abi"

# Uncomment this to enable macOS gcc tests:
# - os: macos-latest
# toolset: gcc
# env: CXX=g++-14 BOOST_ROOT=/usr/local
# runtime-env: DYLD_LIBRARY_PATH=/usr/local/lib:${DYLD_LIBRARY_PATH}

# Uncomment this to enable macOS llvm-clang tests:
# - os: macos-latest
# toolset: llvm-clang
# env: CXX=$(brew --prefix llvm@17)/bin/clang++ BOOST_ROOT=/usr/local
# runtime-env: DYLD_LIBRARY_PATH=/usr/local/lib:${DYLD_LIBRARY_PATH}

- os: macos-latest
toolset: apple-clang
env: CXX=clang++ BOOST_ROOT=$(brew --prefix boost)

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Download libraries
uses: ./.github/composite-actions/download-libraries
- uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/composite-actions/install-dependencies
with:
download-pybind: true
os: ${{ matrix.os }}
toolset: ${{ matrix.toolset }}
download-googletest: false
download-pybind: true
- name: Build pip package
shell: bash
run: |
export ${{ matrix.env }}

python3 -m venv venv
source venv/bin/activate
python3 -m pip install .
- name: Test pip package
shell: bash
run: |
export ${{ matrix.runtime-env }}

source venv/bin/activate

cp test_input_data/WDC_satellites.csv src/python_bindings/
Expand All @@ -60,6 +96,8 @@ jobs:
working-directory: ${{github.workspace}}
shell: bash
run: |
export ${{ matrix.runtime-env }}

source venv/bin/activate

cp test_input_data/TestDataStats.csv src/python_bindings
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/check-codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
clang-format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Pull clang-format
Expand Down Expand Up @@ -49,9 +49,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download libraries
uses: ./.github/composite-actions/download-libraries
- name: Install dependencies
uses: ./.github/composite-actions/install-dependencies
with:
os: ubuntu
toolset: gcc
download-pybind: true
- name: Generate compile_commands.json
run: |
Expand Down
Loading
Loading