dfhack/.github/workflows/build-linux.yml

174 lines
5.7 KiB
YAML

2023-07-31 06:37:57 -06:00
name: Build linux64
2023-07-30 20:36:12 -06:00
on:
workflow_call:
inputs:
dfhack_ref:
type: string
scripts_ref:
2023-07-31 02:49:02 -06:00
type: string
2023-08-03 02:09:57 -06:00
structures_ref:
type: string
2023-07-30 20:36:12 -06:00
artifact-name:
type: string
append-date-and-hash:
type: boolean
default: false
cache-id:
type: string
default: ''
2023-07-31 03:50:32 -06:00
cache-readonly:
type: boolean
default: false
2023-07-30 20:36:12 -06:00
platform-files:
type: boolean
default: true
common-files:
type: boolean
default: true
docs:
type: boolean
default: false
html:
type: boolean
default: true
2023-07-30 20:36:12 -06:00
stonesense:
type: boolean
2023-07-30 20:53:46 -06:00
default: false
2023-07-30 20:36:12 -06:00
extras:
type: boolean
default: false
tests:
type: boolean
default: false
xml-dump-type-sizes:
type: boolean
default: false
2023-07-30 20:36:12 -06:00
gcc-ver:
type: string
2023-07-31 04:56:11 -06:00
default: "10"
2023-07-30 20:36:12 -06:00
jobs:
build-linux64:
2023-07-30 20:53:46 -06:00
name: Build linux64
2023-07-30 20:36:12 -06:00
runs-on: ubuntu-22.04
steps:
- name: Install basic build dependencies
run: |
sudo apt-get update
sudo apt-get install ninja-build
- name: Install binary build dependencies
if: inputs.platform-files || inputs.xml-dump-type-sizes
2023-07-30 20:36:12 -06:00
run: |
sudo apt-get install \
ccache \
gcc-${{ inputs.gcc-ver }} \
g++-${{ inputs.gcc-ver }} \
libxml-libxslt-perl
- name: Install stonesense dependencies
if: inputs.stonesense
run: sudo apt-get install libgl-dev
- name: Install doc dependencies
if: inputs.docs
run: pip install 'sphinx<4.4.0'
- name: Clone DFHack
uses: actions/checkout@v3
with:
2023-08-06 00:25:10 -06:00
repository: ${{ inputs.dfhack_ref && github.repository || 'DFHack/dfhack' }}
ref: ${{ inputs.dfhack_ref }}
2023-07-30 20:36:12 -06:00
submodules: true
fetch-depth: ${{ !inputs.platform-files && 1 || 0 }}
- name: Clone scripts
if: inputs.scripts_ref
uses: actions/checkout@v3
with:
2023-08-06 00:25:10 -06:00
repository: ${{ inputs.scripts_ref && github.repository || 'DFHack/scripts' }}
ref: ${{ inputs.scripts_ref }}
path: scripts
2023-08-03 02:09:57 -06:00
- name: Clone structures
if: inputs.structures_ref
uses: actions/checkout@v3
with:
2023-08-06 00:25:10 -06:00
repository: ${{ inputs.structures_ref && github.repository || 'DFHack/df-structures' }}
2023-08-03 02:09:57 -06:00
ref: ${{ inputs.structures_ref }}
path: library/xml
2023-08-16 23:32:05 -06:00
- name: Clone structures (temporary override)
if: '!inputs.structures_ref'
uses: actions/checkout@v3
with:
repository: DFHack/df-structures
ref: refs/heads/linux
path: library/xml
2023-07-30 20:36:12 -06:00
- name: Fetch ccache
if: inputs.platform-files
2023-07-31 03:50:32 -06:00
uses: actions/cache/restore@v3
2023-07-30 20:36:12 -06:00
with:
2023-07-30 22:04:52 -06:00
path: ~/.cache/ccache
2023-07-30 20:36:12 -06:00
key: linux-gcc-${{ inputs.gcc-ver }}-${{ inputs.cache-id }}-${{ github.sha }}
restore-keys: |
linux-gcc-${{ inputs.gcc-ver }}-${{ inputs.cache-id }}
linux-gcc-${{ inputs.gcc-ver }}
- name: Configure DFHack
env:
CC: gcc-${{ inputs.gcc-ver }}
CXX: g++-${{ inputs.gcc-ver }}
run: |
cmake \
-S . \
-B build \
-G Ninja \
-DCMAKE_INSTALL_PREFIX=build/image \
-DCMAKE_BUILD_TYPE=Release \
2023-07-30 20:53:46 -06:00
${{ inputs.platform-files && '-DCMAKE_C_COMPILER_LAUNCHER=ccache' || '' }} \
${{ inputs.platform-files && '-DCMAKE_CXX_COMPILER_LAUNCHER=ccache' || '' }} \
2023-07-30 20:36:12 -06:00
-DBUILD_LIBRARY:BOOL=${{ inputs.platform-files }} \
-DBUILD_PLUGINS:BOOL=${{ inputs.platform-files }} \
2023-07-30 21:47:59 -06:00
-DBUILD_STONESENSE:BOOL=${{ inputs.stonesense }} \
2023-07-30 20:36:12 -06:00
-DBUILD_DEV_PLUGINS:BOOL=${{ inputs.extras }} \
-DBUILD_SIZECHECK:BOOL=${{ inputs.extras }} \
-DBUILD_SKELETON:BOOL=${{ inputs.extras }} \
-DBUILD_DOCS:BOOL=${{ inputs.docs }} \
-DBUILD_DOCS_NO_HTML:BOOL=${{ !inputs.html }} \
-DBUILD_TESTS:BOOL=${{ inputs.tests }} \
-DBUILD_XMLDUMP:BOOL=${{ inputs.xml-dump-type-sizes }} \
-DINSTALL_XMLDUMP:BOOL=1 \
2023-07-30 20:36:12 -06:00
-DINSTALL_DATA_FILES:BOOL=${{ inputs.common-files }} \
-DINSTALL_SCRIPTS:BOOL=${{ inputs.common-files }}
- name: Build DFHack
run: ninja -C build install
- name: Run cpp tests
2023-07-30 20:53:46 -06:00
if: inputs.platform-files
2023-07-30 20:36:12 -06:00
run: ninja -C build test
2023-08-07 12:01:42 -06:00
- name: Finalize cache
2023-07-30 20:36:12 -06:00
if: inputs.platform-files
run: |
2023-07-31 03:50:32 -06:00
ccache --max-size 40M
2023-07-30 20:36:12 -06:00
ccache --cleanup
2023-07-30 22:04:52 -06:00
ccache --show-stats --verbose
2023-07-31 03:50:32 -06:00
- name: Save ccache
if: inputs.platform-files && !inputs.cache-readonly
uses: actions/cache/save@v3
with:
path: ~/.cache/ccache
key: linux-gcc-${{ inputs.gcc-ver }}-${{ inputs.cache-id }}-${{ github.sha }}
2023-07-30 20:36:12 -06:00
- name: Format artifact name
if: inputs.artifact-name
2023-07-30 20:36:12 -06:00
id: artifactname
run: |
if test "false" = "${{ inputs.append-date-and-hash }}"; then
echo name=${{ inputs.artifact-name }} >> $GITHUB_OUTPUT
else
echo name=${{ inputs.artifact-name }}-$(date +%Y%m%d)-$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT
fi
- name: Prep artifact
if: inputs.artifact-name
run: |
cd build/image
tar cjf ../../${{ steps.artifactname.outputs.name }}.tar.bz2 .
2023-07-30 20:36:12 -06:00
- name: Upload artifact
if: inputs.artifact-name
uses: actions/upload-artifact@v3
with:
name: ${{ steps.artifactname.outputs.name }}
path: ${{ steps.artifactname.outputs.name }}.tar.bz2