name: Build win64 on: workflow_call: inputs: dfhack_ref: type: string scripts_ref: type: string structures_ref: type: string artifact-name: type: string append-date-and-hash: type: boolean default: false cache-id: type: string default: '' cache-readonly: type: boolean default: false platform-files: type: boolean default: true common-files: type: boolean default: true docs: type: boolean default: false html: type: boolean default: true stonesense: type: boolean default: false tests: type: boolean default: false xml-dump-type-sizes: type: boolean default: false launchdf: type: boolean default: false jobs: build-win64: name: Build win64 runs-on: ubuntu-22.04 steps: - name: Install dependencies run: | sudo apt-get update sudo apt-get install ccache - name: Clone DFHack uses: actions/checkout@v3 with: repository: ${{ inputs.dfhack_ref && github.repository || 'DFHack/dfhack' }} ref: ${{ inputs.dfhack_ref }} submodules: true fetch-depth: 0 - name: Clone scripts if: inputs.scripts_ref uses: actions/checkout@v3 with: repository: ${{ inputs.scripts_ref && github.repository || 'DFHack/scripts' }} ref: ${{ inputs.scripts_ref }} path: scripts - name: Clone structures if: inputs.structures_ref uses: actions/checkout@v3 with: repository: ${{ inputs.structures_ref && github.repository || 'DFHack/df-structures' }} ref: ${{ inputs.structures_ref }} path: library/xml - name: Get 3rd party SDKs if: inputs.launchdf 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 uses: actions/cache/restore@v3 with: path: build/win64-cross/ccache key: win-msvc-${{ inputs.cache-id }}-${{ github.sha }} restore-keys: | win-msvc-${{ inputs.cache-id }} win-msvc - name: Cross-compile env: 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' || '' }} run: | cd build bash -x build-win64-from-linux.sh - name: Finalize cache run: | cd build ccache -d win64-cross/ccache --show-stats --verbose ccache -d win64-cross/ccache --max-size 150M ccache -d win64-cross/ccache --cleanup ccache -d win64-cross/ccache --max-size 500M ccache -d win64-cross/ccache --zero-stats - name: Save ccache if: inputs.platform-files && !inputs.cache-readonly uses: actions/cache/save@v3 with: path: build/win64-cross/ccache key: win-msvc-${{ inputs.cache-id }}-${{ github.sha }} - name: Format artifact name if: inputs.artifact-name 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 . - 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