From a6bbef55c1c95adc90cf85dfb0f5bf2807c6a275 Mon Sep 17 00:00:00 2001 From: halx99 Date: Sat, 4 Jan 2025 18:53:16 +0800 Subject: [PATCH] Improve build system, report error when build fail finally --- .github/workflows/build.yml | 14 +++++--------- tools/cmdline/axmol.ps1 | 2 ++ tools/cmdline/build.ps1 | 17 +++++++---------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f167cdd3593d..3d07ca966a5a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,7 @@ jobs: submodules: 'recursive' - name: Build shell: pwsh - run: .\tools\cmdline\axmol -p win32 -a x64 ; .\tools\cmdline\axmol run -p win32 -a x64 -xb '--target,unit-tests' + run: .\tools\cmdline\axmol -p win32 -a x64 && .\tools\cmdline\axmol run -p win32 -a x64 -t unit-tests - uses: actions/upload-artifact@v4 with: name: windows_x64 @@ -76,7 +76,7 @@ jobs: - name: Build shell: pwsh - run: ./tools/cmdline/axmol -p linux -a x64 ; ./tools/cmdline/axmol -p linux -a x64 -xb '--target,lua-tests' ; ./tools/cmdline/axmol run -p linux -a x64 -xb '--target,unit-tests' -wait + run: ./tools/cmdline/axmol -p linux -a x64 -t 'cpp-tests,lua-tests' && ./tools/cmdline/axmol run -p linux -a x64 -xb -t unit-tests -wait osx-arm64: runs-on: macos-latest steps: @@ -85,7 +85,7 @@ jobs: submodules: 'recursive' - name: Build shell: pwsh - run: ./tools/cmdline/axmol -p osx ; ./tools/cmdline/axmol run -p osx -xb '--target,unit-tests' + run: ./tools/cmdline/axmol -p osx && ./tools/cmdline/axmol run -p osx -t unit-tests osx-x64: runs-on: macos-13 steps: @@ -94,7 +94,7 @@ jobs: submodules: 'recursive' - name: Build shell: pwsh - run: ./tools/cmdline/axmol -p osx ; ./tools/cmdline/axmol run -p osx -xb '--target,unit-tests' + run: ./tools/cmdline/axmol -p osx && ./tools/cmdline/axmol run -p osx -t unit-tests android: runs-on: ubuntu-latest strategy: @@ -145,11 +145,7 @@ jobs: submodules: 'recursive' - name: Build shell: pwsh - run: | - ./tools/cmdline/axmol -p wasm -xc '-DAX_ENABLE_EXT_EFFEKSEER=ON,-DAX_WASM_THREADS=8' -j2 - echo "ErrorActionPreference=$ErrorActionPreference" - ./tools/cmdline/axmol -p wasm -xc '-DAX_ENABLE_EXT_EFFEKSEER=ON,-DAX_WASM_THREADS=8' -j2 -xb '--target,fairygui-tests' - ./tools/cmdline/axmol -p wasm -xc '-DAX_ENABLE_EXT_EFFEKSEER=ON,-DAX_WASM_THREADS=8' -j2 -xb '--target,lua-tests' + run: ./tools/cmdline/axmol -p wasm -xc '-DAX_ENABLE_EXT_EFFEKSEER=ON,-DAX_WASM_THREADS=8' -j2 -t 'cpp-tests,fairygui-tests,lua-tests' - uses: actions/upload-artifact@v4 with: name: wasm diff --git a/tools/cmdline/axmol.ps1 b/tools/cmdline/axmol.ps1 index 6c8524ad1290..64ef0151ef5f 100644 --- a/tools/cmdline/axmol.ps1 +++ b/tools/cmdline/axmol.ps1 @@ -403,3 +403,5 @@ if ($args[0] -eq 'new') { } . $plugin.proc @sub_args @sub_opts + +exit $LASTEXITCODE diff --git a/tools/cmdline/build.ps1 b/tools/cmdline/build.ps1 index f62adb1c5cf6..077062d24de7 100644 --- a/tools/cmdline/build.ps1 +++ b/tools/cmdline/build.ps1 @@ -197,14 +197,11 @@ if ($forceConfig) { } . $1k_script @1k_args @forward_args @unhandled_args - -if (!$configOnly) { - if ($?) { - $1k.pause('Build success') - } else { - throw "Build fail, ret=$LASTEXITCODE" - } -} -else { - $1k.pause('Generate done') +$op_name = @('Generate', 'Build')[!$configOnly] +if ($?) { + $1k.pause("$op_name success") +} else { + Write-Error "$op_name fail, ret=$LASTEXITCODE" } + +exit $LASTEXITCODE