Check for llvm instal directory. /15 #328
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: C/C++ CI | |
on: | |
push: | |
branches: [ "main", "ffi" ] | |
tags: ["v*"] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
strategy: | |
matrix: | |
target: | |
- arm-unknown-linux-gnu | |
- x86_64-unknown-linux-gnu | |
- aarch64-apple-darwin | |
- x86_64-apple-darwin | |
- x86_64-pc-windows-msvc | |
os: | |
- ubuntu-latest | |
- macos-latest | |
- windows-latest | |
exclude: | |
- target: aarch64-apple-darwin | |
os: windows-latest | |
- target: x86_64-apple-darwin | |
os: windows-latest | |
- target: arm-unknown-linux-gnu | |
os: windows-latest | |
- target: x86_64-unknown-linux-gnu | |
os: windows-latest | |
- target: x86_64-pc-windows-msvc | |
os: macos-latest | |
- target: arm-unknown-linux-gnu | |
os: macos-latest | |
- target: x86_64-unknown-linux-gnu | |
os: macos-latest | |
- target: x86_64-pc-windows-msvc | |
os: ubuntu-latest | |
- target: aarch64-apple-darwin | |
os: ubuntu-latest | |
- target: x86_64-apple-darwin | |
os: ubuntu-latest | |
runs-on: ${{ matrix.os }} | |
env: | |
CXXTARGET: ${{ matrix.target }} | |
steps: | |
- uses: actions/[email protected] | |
# https://github.com/taiki-e/setup-cross-toolchain-action | |
# Install VCPKG on Windows | |
- name: Install VCPKG (Windows) | |
if: ${{ runner.os == 'Windows' }} | |
run: | | |
git clone https://github.com/microsoft/vcpkg.git | |
./vcpkg/bootstrap-vcpkg.bat | |
env: | |
VCPKG_ROOT: ${{ github.workspace }}/vcpkg | |
# Set VCPKG_ROOT environment variable (Windows) | |
- name: Set VCPKG_ROOT (Windows) | |
if: ${{ runner.os == 'Windows' }} | |
run: echo "VCPKG_ROOT=${{ github.workspace }}\\vcpkg" >> $GITHUB_ENV | |
# Install libffi for Linux and macOS | |
- name: Install libffi (Linux/macOS) | |
if: ${{ runner.os != 'Windows' }} | |
run: | | |
if [ $(uname) = "Linux" ]; then | |
sudo apt-get update | |
sudo apt-get install -y libffi-dev | |
elif [ $(uname) = "Darwin" ]; then | |
brew install libffi | |
fi | |
# Install cross-compilation tools | |
- name: Install cross-compilation tools | |
uses: taiki-e/setup-cross-toolchain-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
# Optionally install libatomic for cross-compilation | |
- name: Optionally install libatomic for cross-compilation | |
if: ${{ matrix.target == 'arm-unknown-linux-gnu' }} | |
run: sudo apt-get install -y libatomic1-arm64-cross | |
# Install Ninja build system | |
- name: Install Ninja (Linux/macOS) | |
if: ${{ runner.os != 'Windows' }} | |
run: | | |
if [ $(uname) = "Linux" ]; then | |
sudo apt-get install -y ninja-build | |
elif [ $(uname) = "Darwin" ]; then | |
brew install ninja | |
fi | |
- name: Install Ninja (Windows) | |
if: ${{ runner.os == 'Windows' }} | |
run: choco install ninja | |
shell: cmd | |
# Ensure Ninja is available (Windows) | |
- name: Add Ninja to PATH (Windows) | |
if: ${{ runner.os == 'Windows' }} | |
run: | | |
$env:Path += ";C:\ProgramData\chocolatey\bin" | |
shell: pwsh | |
# Install LLVM libraries | |
- name: Install LLVM libraries (Linux) | |
if: ${{ runner.os == 'Linux' }} | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y llvm clang libclang-dev | |
- name: Install LLVM libraries (macOS) | |
if: ${{ runner.os == 'macOS' }} | |
run: brew install llvm | |
- name: Install LLVM libraries (Windows) | |
if: ${{ runner.os == 'Windows' }} | |
run: | | |
choco uninstall llvm -y | |
choco install llvm --version=19.1.5 -y | |
shell: cmd | |
- name: Add LLVM to PATH (Windows) | |
if: ${{ runner.os == 'Windows' }} | |
run: | | |
$env:Path += ";C:\Program Files\LLVM\bin" | |
shell: pwsh | |
- name: Check for LLVM libraries (Windows) | |
if: ${{ runner.os == 'Windows' }} | |
run: | | |
dir "C:\Program Files\LLVM\bin" | |
dir "C:\Program Files\LLVM\lib\cmake\llvm" | |
# targets and version debug | |
- name: targets and version debug | |
run: clang++ -print-targets && clang++ --version | |
# Create build directory | |
- name: Create build directory | |
run: mkdir -p build | |
# Configure CMake (Windows) | |
- name: Configure CMake (Windows) | |
if: ${{ runner.os == 'Windows' }} | |
run: cmake -DCMAKE_MAKE_PROGRAM=C:\ProgramData\chocolatey\bin\ninja.exe -DLLVM_DIR="C:/Program Files/LLVM/lib/cmake/llvm" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ --preset=cibuild .. -G Ninja | |
working-directory: build | |
# Configure CMake (Linux/macOS) | |
- name: Configure CMake (Linux/macOS) | |
if: ${{ runner.os != 'Windows' }} | |
run: cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release .. -G Ninja | |
working-directory: build | |
# Build with make | |
- name: Build with Ninja. | |
run: ninja | |
working-directory: build | |
# List files in build directory | |
- name: List files in dist directory | |
run: ls dist | |
# Add the build artifacts to the action. | |
- name: Get Git Commit ID | |
run: echo "COMMIT_ID=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- name: Upload Build Artifacts | |
uses: actions/[email protected] | |
with: | |
name: 'sorth-${{ matrix.target }}-build-${{ env.COMMIT_ID }}' | |
path: "dist/*" | |
retention-days: 5 | |
# Zip up the build. | |
- name: Archive Release | |
uses: thedoctor0/[email protected] | |
with: | |
type: 'zip' | |
filename: 'sorth-${{ matrix.target }}' | |
directory: 'dist' | |
# Make sure to upload the build. | |
- name: List files again. | |
run: ls dist | |
# Create a draft release for a tag. | |
- name: Release | |
uses: xresloader/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.SORTH_PERSONAL_ACCESS_TOKEN }} | |
with: | |
file: "dist/sorth-${{ matrix.target }}.zip" | |
draft: true | |
tags: true | |
overwrite: true |