mirror of
https://github.com/lifting-bits/sleigh
synced 2026-06-21 13:56:12 +00:00
e6cfbacd67
Errors with Ghidra repo FetchContent when using CMake less than this version. FetchContent runs the patch step before update and so we lose the patches, which can cause build errors. CMake 3.15 can still be used if you specify your own Ghidra repo on the command line.
231 lines
8.0 KiB
YAML
231 lines
8.0 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- '*'
|
|
|
|
# Version tags should start with "v"
|
|
tags:
|
|
- 'v*'
|
|
|
|
pull_request:
|
|
branches:
|
|
- '*'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
build_type: [RelWithDebInfo, Debug]
|
|
release: [stable, HEAD]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup Git User for Applying Patches
|
|
# See this thread for more details https://github.community/t/github-actions-bot-email-address/17204/5
|
|
run: |
|
|
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git config --global user.name "github-actions[bot]"
|
|
|
|
- name: Install Linux system dependencies
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y \
|
|
clang \
|
|
rpm \
|
|
doxygen \
|
|
xdot \
|
|
graphviz
|
|
|
|
# Minimum supported CMake version testing
|
|
curl -L "https://github.com/Kitware/CMake/releases/download/v3.18.0/cmake-3.18.0-Linux-$(uname -m).sh" -o /tmp/cmake-install.sh
|
|
mkdir -p "${HOME}/.local"
|
|
bash /tmp/cmake-install.sh --skip-license --exclude-subdir "--prefix=${HOME}/.local"
|
|
|
|
# Use Homebrew for latest build tool version for use in CI
|
|
brew install \
|
|
ccache
|
|
|
|
- name: Install macOS system dependencies
|
|
if: runner.os == 'macOS'
|
|
run: |
|
|
echo "MACOSX_DEPLOYMENT_TARGET=10.15" >> ${GITHUB_ENV}
|
|
brew install \
|
|
ccache \
|
|
cmake \
|
|
doxygen \
|
|
graphviz
|
|
|
|
- name: Install Windows system dependencies
|
|
if: runner.os == 'Windows'
|
|
run: choco install ccache
|
|
|
|
- name: Generate cache key
|
|
id: cache_key
|
|
shell: cmake -P {0}
|
|
run: |
|
|
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
|
|
message("::set-output name=VALUE::build_${{ matrix.os }}_type-${{ matrix.build_type }}-${{ matrix.release }}")
|
|
message("::set-output name=timestamp::${current_date}")
|
|
|
|
- name: Update the cache (ccache)
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: "${{ github.workspace }}/ccache"
|
|
key: ${{ steps.cache_key.outputs.VALUE }}_ccache_${{ steps.cache_key.outputs.timestamp }}
|
|
restore-keys: |
|
|
${{ steps.cache_key.outputs.VALUE }}_ccache_
|
|
|
|
- name: Setup ccache
|
|
working-directory: "${{ github.workspace }}"
|
|
shell: cmake -P {0}
|
|
run: |
|
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/ccache")
|
|
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_BASEDIR=${CMAKE_CURRENT_SOURCE_DIR}\n")
|
|
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/ccache\n")
|
|
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_COMPRESS=true\n")
|
|
# Trial and error to get all files in here
|
|
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_COMPRESSLEVEL=10\n")
|
|
# This should be multiplied by the number of compilation jobs and be no
|
|
# larger than 5G, which is the cache max size
|
|
file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_MAXSIZE=400M\n")
|
|
# Clear stats before every build
|
|
execute_process(COMMAND ccache -z)
|
|
|
|
- name: CMake version
|
|
run: cmake --version
|
|
|
|
- name: Configure the project
|
|
run: cmake
|
|
-S .
|
|
-B build
|
|
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
|
-DCMAKE_C_COMPILER_LAUNCHER=ccache
|
|
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
|
-Dsleigh_GHIDRA_RELEASE_TYPE=${{ matrix.release }}
|
|
-Dsleigh_ENABLE_TESTS=ON
|
|
-Dsleigh_ENABLE_EXAMPLES=ON
|
|
-Dsleigh_ENABLE_PACKAGING=ON
|
|
-Dsleigh_ENABLE_DOCUMENTATION=ON
|
|
|
|
- name: Build the project
|
|
run: cmake
|
|
--build build
|
|
--config ${{ matrix.build_type }}
|
|
-j 2
|
|
-v
|
|
|
|
- name: Run the example
|
|
run: cmake
|
|
--build build
|
|
-j 2
|
|
--config ${{ matrix.build_type }}
|
|
--target sleighexample_runner
|
|
|
|
- name: Run the install target
|
|
run: cmake --install build
|
|
--config ${{ matrix.build_type }}
|
|
--prefix install
|
|
|
|
- name: Test install directory
|
|
working-directory: tests/find_package
|
|
run: |
|
|
cmake -B build -S . "-Dsleigh_DIR=${{ github.workspace }}/install/lib/cmake/sleigh" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
|
cmake --build build -j 2 --config ${{ matrix.build_type }}
|
|
cd build
|
|
ctest -V -C ${{ matrix.build_type }}
|
|
|
|
- name: Create the packages
|
|
run: cmake
|
|
--build build
|
|
-j 2
|
|
--config ${{ matrix.build_type }}
|
|
--target package
|
|
|
|
- name: Test the DEB package
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
sudo dpkg -i build/*.deb
|
|
|
|
cmake -S tests/find_package -B find_package_build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
|
cmake --build find_package_build -j 2 --config ${{ matrix.build_type }} --verbose
|
|
|
|
- name: Locate the packages (RelWithDebInfo only)
|
|
if: matrix.build_type == 'RelWithDebInfo'
|
|
shell: bash
|
|
id: package_locations
|
|
run: |
|
|
echo ::set-output name=DEB_PACKAGE_PATH::$(ls build/*.deb)
|
|
echo ::set-output name=DEB_PACKAGE_NAME::$(cd build && ls *.deb)
|
|
|
|
echo ::set-output name=RPM_PACKAGE_PATH::$(ls build/*.rpm)
|
|
echo ::set-output name=RPM_PACKAGE_NAME::$(cd build && ls *.rpm)
|
|
|
|
# Rename .tar.gz files for OS
|
|
pushd build
|
|
for f in *.tar.gz; do mv "$f" "${{ runner.os }}-$f"; done
|
|
popd
|
|
|
|
echo ::set-output name=TGZ_PACKAGE_PATH::$(ls build/*.tar.gz)
|
|
echo ::set-output name=TGZ_PACKAGE_NAME::$(cd build && ls *.tar.gz)
|
|
|
|
# DEB Package
|
|
- name: Upload the DEB package artifact (RelWithDebInfo only)
|
|
if: matrix.build_type == 'RelWithDebInfo' && runner.os == 'Linux'
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ steps.package_locations.outputs.DEB_PACKAGE_NAME }}
|
|
path: ${{ steps.package_locations.outputs.DEB_PACKAGE_PATH }}
|
|
|
|
- name: Release DEB package artifact (RelWithDebInfo only)
|
|
uses: softprops/action-gh-release@v0.1.14
|
|
if: matrix.build_type == 'RelWithDebInfo' && runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/') && matrix.release == 'stable'
|
|
with:
|
|
files: ${{ steps.package_locations.outputs.DEB_PACKAGE_PATH }}
|
|
|
|
# RPM Package
|
|
- name: Upload the RPM package artifact (RelWithDebInfo only)
|
|
if: matrix.build_type == 'RelWithDebInfo' && runner.os == 'Linux'
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ steps.package_locations.outputs.RPM_PACKAGE_NAME }}
|
|
path: ${{ steps.package_locations.outputs.RPM_PACKAGE_PATH }}
|
|
- name: Release RPM package artifact (RelWithDebInfo only)
|
|
uses: softprops/action-gh-release@v0.1.14
|
|
if: matrix.build_type == 'RelWithDebInfo' && runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/') && matrix.release == 'stable'
|
|
with:
|
|
files: ${{ steps.package_locations.outputs.RPM_PACKAGE_PATH }}
|
|
|
|
# TGZ Package
|
|
- name: Upload the TGZ package artifact (RelWithDebInfo only)
|
|
if: matrix.build_type == 'RelWithDebInfo'
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ steps.package_locations.outputs.TGZ_PACKAGE_NAME }}
|
|
path: ${{ steps.package_locations.outputs.TGZ_PACKAGE_PATH }}
|
|
|
|
- name: Release TGZ package artifact (RelWithDebInfo only)
|
|
uses: softprops/action-gh-release@v0.1.14
|
|
if: matrix.build_type == 'RelWithDebInfo' && startsWith(github.ref, 'refs/tags/') && matrix.release == 'stable'
|
|
with:
|
|
files: ${{ steps.package_locations.outputs.TGZ_PACKAGE_PATH }}
|
|
|
|
# This step is down at the bottom because Windows fails but we still want
|
|
# to upload the built binaries, regardless. We also want to see if/when
|
|
# Windows tests start passing or are still failing, so there is no special
|
|
# handling. GitHub Actions does not support the concept of an allowable
|
|
# failure state
|
|
- name: Run the tests
|
|
working-directory: build
|
|
run: ctest -V -C ${{ matrix.build_type }}
|
|
|
|
- name: ccache stats
|
|
run: ccache -s --verbose
|