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

136 lines
4.4 KiB
YAML

2023-07-31 06:37:57 -06:00
name: Build win64
2023-07-30 21:47:59 -06:00
on:
workflow_call:
inputs:
2023-08-03 02:09:57 -06:00
dfhack_ref:
type: string
2023-08-03 05:13:06 -06:00
scripts_ref:
type: string
2023-08-03 02:09:57 -06:00
structures_ref:
2023-07-31 02:49:02 -06:00
type: string
2023-07-30 21:47:59 -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
platform-files:
type: boolean
default: true
2023-07-30 21:47:59 -06:00
common-files:
type: boolean
default: true
2023-08-03 05:13:06 -06:00
docs:
type: boolean
default: false
html:
type: boolean
default: true
2023-08-03 05:13:06 -06:00
stonesense:
type: boolean
default: false
tests:
type: boolean
default: false
xml-dump-type-sizes:
type: boolean
default: false
launchdf:
type: boolean
default: false
2023-07-30 21:47:59 -06:00
2023-07-30 21:47:59 -06:00
jobs:
build-win64:
name: Build win64
2023-07-31 02:49:02 -06:00
runs-on: ubuntu-22.04
2023-07-30 21:47:59 -06:00
steps:
2023-07-31 02:49:02 -06:00
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install ccache
- name: Clone DFHack
uses: actions/checkout@v3
with:
2023-08-06 00:25:10 -06:00
repository: ${{ inputs.dfhack_ref && github.repository || 'DFHack/dfhack' }}
2023-08-03 02:09:57 -06:00
ref: ${{ inputs.dfhack_ref }}
2023-07-31 02:49:02 -06:00
submodules: true
fetch-depth: 0
2023-08-03 05:13:06 -06:00
- 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' }}
2023-08-03 05:13:06 -06:00
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-07-31 02:49:02 -06:00
- name: Get 3rd party SDKs
if: inputs.launchdf
2023-07-31 02:49:02 -06:00
uses: actions/checkout@v3
with:
repository: DFHack/3rdparty
ref: main
ssh-key: ${{ secrets.DFHACK_3RDPARTY_TOKEN }}
path: depends/steam
- name: Fetch ccache
if: inputs.platform-files
2023-07-31 03:50:32 -06:00
uses: actions/cache/restore@v3
2023-07-30 21:47:59 -06:00
with:
2023-07-31 02:49:02 -06:00
path: build/win64-cross/ccache
2023-07-30 21:47:59 -06:00
key: win-msvc-${{ inputs.cache-id }}-${{ github.sha }}
restore-keys: |
win-msvc-${{ inputs.cache-id }}
win-msvc
2023-07-31 02:49:02 -06:00
- name: Cross-compile
2023-07-31 00:50:47 -06:00
env:
2023-09-02 05:16:21 -06:00
CMAKE_EXTRA_ARGS: -DBUILD_LIBRARY=${{ inputs.platform-files }} -DBUILD_STONESENSE:BOOL=${{ inputs.stonesense }} -DBUILD_DOCS:BOOL=${{ inputs.docs }} -DBUILD_DOCS_NO_HTML:BOOL=${{ !inputs.html }} -DINSTALL_DATA_FILES:BOOL=${{ inputs.common-files }} -DINSTALL_SCRIPTS:BOOL=${{ inputs.common-files }} -DBUILD_DFLAUNCH:BOOL=${{ inputs.launchdf }} -DBUILD_TESTS:BOOL=${{ inputs.tests }} -DBUILD_XMLDUMP:BOOL=${{ inputs.xml-dump-type-sizes }} ${{ inputs.xml-dump-type-sizes && '-DINSTALL_XMLDUMP:BOOL=1' || '' }}
2023-07-31 02:49:02 -06:00
run: |
cd build
bash -x build-win64-from-linux.sh
2023-08-07 12:01:42 -06:00
- name: Finalize cache
2023-07-30 21:47:59 -06:00
run: |
2023-07-31 03:50:32 -06:00
cd build
ccache -d win64-cross/ccache --show-stats --verbose
2023-08-03 05:55:40 -06:00
ccache -d win64-cross/ccache --max-size 150M
2023-07-31 02:49:02 -06:00
ccache -d win64-cross/ccache --cleanup
ccache -d win64-cross/ccache --max-size 500M
ccache -d win64-cross/ccache --zero-stats
2023-07-31 03:50:32 -06:00
- name: Save ccache
if: inputs.platform-files && !inputs.cache-readonly
2023-07-31 03:50:32 -06:00
uses: actions/cache/save@v3
with:
path: build/win64-cross/ccache
key: win-msvc-${{ inputs.cache-id }}-${{ github.sha }}
2023-07-30 21:47:59 -06:00
- name: Format artifact name
if: inputs.artifact-name
2023-07-30 21:47:59 -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/win64-cross/output
tar cjf ../../../${{ steps.artifactname.outputs.name }}.tar.bz2 .
2023-07-30 21:47:59 -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