name: Emu build 2 (Windows) on: workflow_call: inputs: emu-variant: description: | Which variant of the emu to build: regular: build the regular version of the emu exp: build the experimental version of the emu client: build the experimental steamclient version of the emu tools: build the tools only all: build all variants default: 'all' required: false type: string x32: description: | build architecture, unused when 'emu-variant' == 'all' or 'emu-variant' == 'tools' true: x32 false: x64 default: false required: false type: boolean debug: description: | build mode, unused when 'emu-variant' == 'all' true: build in debug mode false: build in release mode default: false required: false type: boolean workflow_dispatch: # allows manual trigger permissions: contents: write env: DEPS_CACHE_KEY: emu-deps-win DEPS_CACHE_DIR: build/deps/win PACKAGE_BASE_DIR: "build/package/win" THIRD_PARTY_BASE_DIR: 'third-party' jobs: dependencies: name: Restore or build deps if: ${{ !cancelled() }} uses: ./.github/workflows/deps-win.yml build: runs-on: windows-2022 needs: [ dependencies ] if: ${{ !cancelled() }} steps: ### setup build vars - name: Setup build vars shell: cmd run: | echo env file = "${{ GITHUB_ENV }}" if /i "${{ inputs.debug }}"=="true" ( set "build_switches=%build_switches% debug" >>"${{ GITHUB_ENV }}" echo build_mode=debug ) else ( >>"${{ GITHUB_ENV }}" echo build_mode=release ) set "arch=" if /i "${{ inputs.x32 }}"=="true" ( set "arch=32" ) else ( set "arch=64" ) set "build_switches=" if "${{ inputs.emu-variant }}"=="regular" ( set "build_switches=+lib-%arch%" ) else if "${{ inputs.emu-variant }}"=="exp" ( set "build_switches=+ex-lib-%arch% +ex-client-%arch%" ) else if "${{ inputs.emu-variant }}"=="client" ( set "build_switches=+exclient-%arch% +exclient-ldr-%arch% +exclient-extra-%arch% +lib-gameoverlay-%arch%" ) else if "${{ inputs.emu-variant }}"=="tools" ( set "build_switches=+tool-itf +tool-lobby" ) else if "${{ inputs.emu-variant }}"=="all" ( set "build_switches=+lib-32 +lib-64 +ex-lib-32 +ex-lib-64 +ex-client-32 +ex-client-64 +exclient-32 +exclient-64 +exclient-ldr-32 +exclient-ldr-64 +tool-itf +tool-lobby +exclient-extra-32 +exclient-extra-64 +lib-gameoverlay-32 +lib-gameoverlay-64" ) else ( 1>&2 echo [X] invalid emu variant "${{ inputs.emu-variant }}" exit /b 1 ) echo final build switches %build_switches% >>"${{ GITHUB_ENV }}" echo build_switches=%build_switches% ### on Windows Git will auto change line ending to CRLF, not preferable - name: Ensure LF line ending shell: cmd working-directory: ${{ github.workspace }} run: | git config --local core.autocrlf false git config --system core.autocrlf false git config --global core.autocrlf false - name: Checkout branch uses: actions/checkout@v4 ### deps - name: Restore deps id: emu-deps-cache-step uses: actions/cache@v4 with: key: ${{ env.DEPS_CACHE_KEY }} path: ${{ env.DEPS_CACHE_DIR }} ## extra helpers/tools, these are not built inside the deps build dir - name: Clone third-party build helpers (common/win) uses: actions/checkout@v4 with: ref: 'third-party/common/win' path: "${{env.THIRD_PARTY_BASE_DIR}}/common/win" - name: Clone third-party deps (deps/win) uses: actions/checkout@v4 with: ref: 'third-party/deps/win' path: "${{env.THIRD_PARTY_BASE_DIR}}/deps/win" - name: Clone third-party deps (build/win) uses: actions/checkout@v4 with: ref: 'third-party/build/win' path: "${{env.THIRD_PARTY_BASE_DIR}}/build/win" ### build target(s) - name: Build target(s) if: inputs.emu-variant != 'all' shell: cmd working-directory: ${{ github.workspace }} run: build_win.bat -verbose ${{ env.build_mode }} clean +build_str ${{ github.sha }} ${{ env.build_switches }} ### build all - name: Build all if: inputs.emu-variant == 'all' shell: cmd working-directory: ${{ github.workspace }} run: | build_win.bat -verbose release clean +build_str ${{ github.sha }} ${{ env.build_switches }} || exit /b %errorlevel% build_win.bat -verbose debug clean +build_str ${{ github.sha }} ${{ env.build_switches }} || exit /b %errorlevel% ### package target(s) - name: Package target(s) if: inputs.emu-variant != 'all' shell: cmd working-directory: ${{ github.workspace }} run: package_win.bat ${{ env.build_mode }} ### package all - name: Package all if: inputs.emu-variant == 'all' shell: cmd working-directory: ${{ github.workspace }} run: | package_win.bat release || exit /b %errorlevel% package_win.bat debug || exit /b %errorlevel% ### upload artifact/package to github Actions (release mode) - name: Upload build package uses: actions/upload-artifact@v4 with: name: "build-win-release-${{ github.sha }}" path: "${{ env.PACKAGE_BASE_DIR }}/" if-no-files-found: 'error' compression-level: 9 retention-days: 1