From 62904968df842b57bd883cb45eaa557ca2aedeac Mon Sep 17 00:00:00 2001 From: otavepto <153766569+otavepto@users.noreply.github.com> Date: Mon, 20 May 2024 03:12:20 +0300 Subject: [PATCH] matrix based workflows for premake --- .github/workflows/emu-build-all-linux.yml | 184 +++++++--------- .github/workflows/emu-build-all-win.yml | 204 +++++++----------- .github/workflows/emu-build-variant-linux.yml | 127 ----------- .github/workflows/emu-build-variant-win.yml | 134 ------------ 4 files changed, 145 insertions(+), 504 deletions(-) delete mode 100644 .github/workflows/emu-build-variant-linux.yml delete mode 100644 .github/workflows/emu-build-variant-win.yml diff --git a/.github/workflows/emu-build-all-linux.yml b/.github/workflows/emu-build-all-linux.yml index 889ada9e..23fc38a3 100644 --- a/.github/workflows/emu-build-all-linux.yml +++ b/.github/workflows/emu-build-all-linux.yml @@ -9,130 +9,90 @@ on: permissions: contents: write +env: + DEPS_CACHE_KEY: emu-deps-linux + DEPS_CACHE_DIR: build/deps/linux + + PACKAGE_BASE_DIR: "build/package/linux" + THIRD_PARTY_BASE_DIR: 'third-party' + jobs: deps: name: Restore or build deps if: ${{ !cancelled() }} uses: ./.github/workflows/emu-deps-linux.yml - emu-regular-x32-release: - name: Regular x32 (release) + builds-matrix-linux: + name: Builds matrix (Linux) needs: [ deps ] + runs-on: ubuntu-22.04 if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-linux.yml - with: - emu-variant: regular - x32: true - debug: false + + strategy: + matrix: +## notice how on linux everything is lowercase, `cd GBE_Build`, then: `make help` + cfg: [ 'debug', 'release', 'experimentaldebug', 'experimentalrelease', ] + arch: [ 'x64', 'x32', ] + prj: [ 'GenerateInterfaces', 'SteamClient', 'SteamEmu', ] + + steps: +### deps + - name: Restore deps + id: emu-deps-cache-step + uses: actions/cache@v4 + with: + key: ${{ env.DEPS_CACHE_KEY }} + path: ${{ env.DEPS_CACHE_DIR }} - emu-regular-x32-debug: - name: Regular x32 (debug) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-linux.yml - with: - emu-variant: regular - x32: true - debug: true +## mandatory Linux packages, installed via sudo apt install ... + - name: Install required packages + shell: bash + run: sudo chmod 777 build_linux_deps.sh && sudo ./build_linux_deps.sh -verbose -packages_only - emu-exp-x32-release: - name: Experimental x32 (release) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-linux.yml - with: - emu-variant: exp - x32: true - debug: false +## extra helpers/tools, these are not built inside the deps build dir + - name: Clone third-party build helpers (common/linux) + uses: actions/checkout@v4 + with: + ref: 'third-party/common/linux' + path: "${{env.THIRD_PARTY_BASE_DIR}}/common/linux" - emu-exp-x32-debug: - name: Experimental x32 (debug) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-linux.yml - with: - emu-variant: exp - x32: true - debug: true + - name: Clone third-party build helpers (build/linux) + uses: actions/checkout@v4 + with: + ref: 'third-party/build/linux' + path: "${{env.THIRD_PARTY_BASE_DIR}}/build/linux" - tools-x32-release: - name: Tools x32 (release) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-linux.yml - with: - emu-variant: tools - x32: true - debug: false +### fix folder permissions! not sure why this fails + # nested subdirs "build/linux/release" cause permission problems + - name: Give all permissions to repo folder + shell: bash + working-directory: ${{ github.workspace }} + run: sudo chmod -R 777 "${{ github.workspace }}" - tools-x32-debug: - name: Tools x32 (debug) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-linux.yml - with: - emu-variant: tools - x32: true - debug: true +### generate project files +## TODO gen proto action is broken, always returns error = 1 + - name: Generate project files + shell: bash + working-directory: ${{ github.workspace }} + run: | + sudo chmod 777 ./third-party/common/linux/premake/premake5 + ./third-party/common/linux/premake/premake5 --file=premake5.lua --os=linux generateproto + ./third-party/common/linux/premake/premake5 --file=premake5.lua --emubuild=${{ github.sha }} --os=linux gmake2 + exit 0 +### build target(s) + - name: Build target(s) + shell: bash + working-directory: ${{ github.workspace }}/GBE_Build + run: | + make -j 2 config=${{ matrix.cfg }}_${{ matrix.arch }} ${{ matrix.prj }} - - emu-regular-x64-release: - name: Regular x64 (release) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-linux.yml - with: - emu-variant: regular - x32: false - debug: false - - emu-regular-x64-debug: - name: Regular x64 (debug) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-linux.yml - with: - emu-variant: regular - x32: false - debug: true - - emu-exp-x64-release: - name: Experimental x64 (release) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-linux.yml - with: - emu-variant: exp - x32: false - debug: false - - emu-exp-x64-debug: - name: Experimental x64 (debug) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-linux.yml - with: - emu-variant: exp - x32: false - debug: true - - tools-x64-release: - name: Tools x64 (release) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-linux.yml - with: - emu-variant: tools - x32: false - debug: false - - tools-x64-debug: - name: Tools x64 (debug) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-linux.yml - with: - emu-variant: tools - x32: false - debug: true +### upload artifact/package to github Actions (for targets) + - name: Upload build package (for targets) + uses: actions/upload-artifact@v4 + with: + name: "emu-linux-${{ matrix.prj }}-${{ matrix.cfg }}-${{ matrix.arch }}-${{ github.sha }}" + path: "bin/" + if-no-files-found: 'error' + compression-level: 9 + retention-days: 1 diff --git a/.github/workflows/emu-build-all-win.yml b/.github/workflows/emu-build-all-win.yml index 170e5156..85508951 100644 --- a/.github/workflows/emu-build-all-win.yml +++ b/.github/workflows/emu-build-all-win.yml @@ -9,150 +9,92 @@ on: permissions: contents: write +env: + DEPS_CACHE_KEY: emu-deps-win + DEPS_CACHE_DIR: build/deps/win + + THIRD_PARTY_BASE_DIR: 'third-party' + jobs: deps: name: Restore or build deps if: ${{ !cancelled() }} uses: ./.github/workflows/emu-deps-win.yml - emu-regular-x32-release: - name: Regular x32 (release) + builds-matrix-win: + name: Builds matrix (Windows) needs: [ deps ] + runs-on: windows-2022 if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-win.yml - with: - emu-variant: regular - x32: true - debug: false + + strategy: + matrix: + prj: [ 'GameOverlayRenderer', 'GenerateInterfaces', 'SteamClient', 'SteamEmu', ] + arch: [ 'x64', 'Win32', ] + cfg: [ 'Debug', 'Release', 'ExperimentalDebug', 'ExperimentalRelease', ] + + steps: +### 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 - emu-regular-x32-debug: - name: Regular x32 (debug) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-win.yml - with: - emu-variant: regular - x32: true - debug: true +### ensure we have msbuild + - name: Add MSBuild to PATH + uses: microsoft/setup-msbuild@v2 - emu-exp-x32-release: - name: Experimental x32 (release) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-win.yml - with: - emu-variant: exp - x32: true - debug: false +### clone branch + - name: Checkout branch + uses: actions/checkout@v4 - emu-exp-x32-debug: - name: Experimental x32 (debug) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-win.yml - with: - emu-variant: exp - x32: true - debug: true +### deps + - name: Restore deps + id: emu-deps-cache-step + uses: actions/cache@v4 + with: + key: ${{ env.DEPS_CACHE_KEY }} + path: ${{ env.DEPS_CACHE_DIR }} - emu-client-x32-release: - name: Client x32 (release) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-win.yml - with: - emu-variant: client - x32: true - debug: false +## 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" - emu-client-x32-debug: - name: Client x32 (debug) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-win.yml - with: - emu-variant: client - x32: true - debug: true + - 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" +### generate project files +## TODO gen proto action is broken, always returns error = 1 + - name: Generate project files + shell: cmd + working-directory: ${{ github.workspace }} + run: | + third-party\common\win\premake\premake5.exe --file=premake5.lua --os=windows generateproto + third-party\common\win\premake\premake5.exe --file=premake5.lua --emubuild=${{ github.sha }} --os=windows vs2022 + exit /b 0 +### build target(s) + - name: Build target(s) + shell: cmd + working-directory: ${{ github.workspace }}/GBE_Build + run: | + msbuild /nologo /target:${{ matrix.prj }} /m:2 /v:diag /p:Configuration=${{ matrix.cfg }},Platform=${{ matrix.arch }} GBE.sln - emu-regular-x64-release: - name: Regular x64 (release) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-win.yml - with: - emu-variant: regular - x32: false - debug: false - - emu-regular-x64-debug: - name: Regular x64 (debug) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-win.yml - with: - emu-variant: regular - x32: false - debug: true - - emu-exp-x64-release: - name: Experimental x64 (release) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-win.yml - with: - emu-variant: exp - x32: false - debug: false - - emu-exp-x64-debug: - name: Experimental x64 (debug) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-win.yml - with: - emu-variant: exp - x32: false - debug: true - - emu-client-x64-release: - name: Client x64 (release) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-win.yml - with: - emu-variant: client - x32: false - debug: false - - emu-client-x64-debug: - name: Client x64 (debug) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-win.yml - with: - emu-variant: client - x32: false - debug: true - - - - tools-release: - name: Tools (release) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-win.yml - with: - emu-variant: tools - debug: false - - tools-debug: - name: Tools (debug) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-win.yml - with: - emu-variant: tools - debug: true +### upload artifact/package to github Actions (for targets) + - name: Upload build package (for targets) + uses: actions/upload-artifact@v4 + with: + name: "emu-win-${{ matrix.prj }}-${{ matrix.cfg }}-${{ matrix.arch }}-${{ github.sha }}" + path: "bin/" + if-no-files-found: 'error' + compression-level: 9 + retention-days: 1 diff --git a/.github/workflows/emu-build-variant-linux.yml b/.github/workflows/emu-build-variant-linux.yml deleted file mode 100644 index 42ab0f1b..00000000 --- a/.github/workflows/emu-build-variant-linux.yml +++ /dev/null @@ -1,127 +0,0 @@ -name: Build emu variant (Linux) - -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 - tools: build the tools only - required: true - type: string - - x32: - description: | - build architecture - true: x32 - false: x64 - required: true - type: boolean - - debug: - description: | - build mode - true: build in debug mode - false: build in release mode - required: true - type: boolean - -permissions: - contents: write - -env: - DEPS_CACHE_KEY: emu-deps-linux - DEPS_CACHE_DIR: build/deps/linux - - PACKAGE_BASE_DIR: "build/package/linux" - THIRD_PARTY_BASE_DIR: 'third-party' - -jobs: - build: - runs-on: ubuntu-22.04 - if: ${{ !cancelled() }} - - steps: -### setup build vars - - name: Setup build vars - shell: bash - run: | - echo "env file = '$GITHUB_ENV'" - echo "workspace = '${{ github.workspace }}'" - - arch="" - if [[ "${{ inputs.x32 }}" = "true" ]]; then - arch="32" - else - arch="64" - fi - echo "build_arch=$arch" >>"$GITHUB_ENV" - - build_switches="" - if [[ "${{ inputs.emu-variant }}" = "regular" ]]; then - build_switches="+lib-$arch +client-$arch" - elif [[ "${{ inputs.emu-variant }}" = "exp" ]]; then - build_switches="+exp-lib-$arch +exp-client-$arch" - elif [[ "${{ inputs.emu-variant }}" = "tools" ]]; then - build_switches="+tool-clientldr +tool-itf-$arch +tool-lobby-$arch" - else - echo "[X] invalid emu variant '${{ inputs.emu-variant }}'" >&2 - exit 1 - fi - echo "build_switches=$build_switches" >>"$GITHUB_ENV" - - build_mode="" - if [[ "${{ inputs.debug }}" = "true" ]]; then - build_mode="debug" - else - build_mode="release" - fi - echo "build_mode=$build_mode" >>"$GITHUB_ENV" - - - 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 }} - -## mandatory Linux packages, installed via sudo apt install ... - - name: Install required packages - shell: bash - run: sudo chmod 777 build_linux_deps.sh && sudo ./build_linux_deps.sh -verbose -packages_only - -## extra helpers/tools, these are not built inside the deps build dir - - name: Clone third-party build helpers (build/linux) - uses: actions/checkout@v4 - with: - ref: 'third-party/build/linux' - path: "${{env.THIRD_PARTY_BASE_DIR}}/build/linux" - -### fix folder permissions! not sure why this fails - # nested subdirs "build/linux/release" cause permission problems - - name: Give all permissions to repo folder - shell: bash - working-directory: ${{ github.workspace }} - run: sudo chmod -R 777 "${{ github.workspace }}" - -### build target(s) - - name: Build target(s) - shell: bash - working-directory: ${{ github.workspace }} - run: "sudo chmod 777 build_linux.sh && ./build_linux.sh -j 3 -verbose ${{ env.build_mode }} clean +build_str ${{ github.sha }} ${{ env.build_switches }}" - -### upload artifact/package to github Actions (for targets) - - name: Upload build package (for targets) - uses: actions/upload-artifact@v4 - with: - name: "emu-linux-${{ inputs.emu-variant }}-${{ env.build_arch }}-${{ env.build_mode }}-${{ github.sha }}" - path: "build/linux/" - if-no-files-found: 'error' - compression-level: 9 - retention-days: 1 diff --git a/.github/workflows/emu-build-variant-win.yml b/.github/workflows/emu-build-variant-win.yml deleted file mode 100644 index 61153f32..00000000 --- a/.github/workflows/emu-build-variant-win.yml +++ /dev/null @@ -1,134 +0,0 @@ -name: Build emu variant (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 - required: true - type: string - - x32: - description: | - build architecture, unused when 'emu-variant' == 'tools' - true: x32 - false: x64 - required: false - type: boolean - default: true - - debug: - description: | - build mode - true: build in debug mode - false: build in release mode - required: true - type: boolean - -permissions: - contents: write - -env: - DEPS_CACHE_KEY: emu-deps-win - DEPS_CACHE_DIR: build/deps/win - - THIRD_PARTY_BASE_DIR: 'third-party' - -jobs: - build: - runs-on: windows-2022 - if: ${{ !cancelled() }} - - steps: -### setup build vars - - name: Setup build vars - shell: cmd - run: | - echo env file = "%GITHUB_ENV%" - echo workspace = "${{ github.workspace }}" - - set "arch=" - if /i "${{ inputs.x32 }}"=="true" ( - set "arch=32" - ) else ( - set "arch=64" - ) - >>"%GITHUB_ENV%" echo build_arch=%arch% - - 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 ( - 1>&2 echo [X] invalid emu variant "${{ inputs.emu-variant }}" - exit /b 1 - ) - >>"%GITHUB_ENV%" echo build_switches=%build_switches% - - set "build_mode=" - if /i "${{ inputs.debug }}"=="true" ( - set "build_mode=debug" - ) else ( - set "build_mode=release" - ) - >>"%GITHUB_ENV%" echo build_mode=%build_mode% - -### 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 (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 -j 3 -verbose ${{ env.build_mode }} clean +build_str ${{ github.sha }} ${{ env.build_switches }} - -### upload artifact/package to github Actions (for targets) - - name: Upload build package (for targets) - uses: actions/upload-artifact@v4 - with: - name: "emu-win-${{ inputs.emu-variant }}-${{ env.build_arch }}-${{ env.build_mode }}-${{ github.sha }}" - path: "build/win/" - if-no-files-found: 'error' - compression-level: 9 - retention-days: 1