From ec595c4f62e94e02b225006b1cef1845993c7310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=28x*ln=287=29=29=E2=81=BB=C2=B9?= <100133857+DerivativeOfLog7@users.noreply.github.com> Date: Tue, 11 Jul 2023 23:13:33 +0200 Subject: [PATCH] More friendly batch files & error handling --- SandboxiePlus/install_jom.cmd | 21 +++++++++++++++++- SandboxiePlus/qmake_plus.cmd | 41 ++++++++++++++++++++++------------- 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/SandboxiePlus/install_jom.cmd b/SandboxiePlus/install_jom.cmd index 449f116af5..4507d5236b 100644 --- a/SandboxiePlus/install_jom.cmd +++ b/SandboxiePlus/install_jom.cmd @@ -1,6 +1,25 @@ +@echo off + +::Check that needed programs exist in path +where /q curl +if %ERRORLEVEL% == 1 ( + echo curl.exe not found in path! + exit /b 1 +) + +where /q 7z +if %ERRORLEVEL% == 1 ( + echo 7z.exe not found in path! + exit /b 2 +) + curl -LsSO --output-dir %~dp0..\..\ https://download.qt.io/official_releases/jom/jom.zip -"C:\Program Files\7-Zip\7z.exe" x -aoa -o%~dp0..\..\Qt\Tools\QtCreator\bin\ %~dp0..\..\jom.zip +7z x -aoa -o%~dp0..\..\Qt\Tools\QtCreator\bin\ %~dp0..\..\jom.zip REM dir %~dp0..\..\ REM dir %~dp0..\..\Qt REM dir %~dp0..\..\Qt\Tools + +echo Success! +::/b terminates the script without closing the CMD +exit /b 0 \ No newline at end of file diff --git a/SandboxiePlus/qmake_plus.cmd b/SandboxiePlus/qmake_plus.cmd index a0f8e4bcce..e226030b91 100644 --- a/SandboxiePlus/qmake_plus.cmd +++ b/SandboxiePlus/qmake_plus.cmd @@ -1,9 +1,13 @@ -REM @echo off +@echo off REM echo Current dir: %cd% REM echo folder: %~dp0 REM echo arch: %1 +IF "%1" == "" ( + call :print_usage + exit /b 2 +) IF %1 == Win32 ( set qt_path=%~dp0..\..\Qt\5.15.2\msvc2019 @@ -13,20 +17,18 @@ IF %1 == Win32 ( set build_arch=Win32 set qt_params= call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars32.bat" -) -IF %1 == x64 ( +) ELSE IF %1 == x64 ( set qt_path=%~dp0..\..\Qt\5.15.2\msvc2019_64 -REM set qt_path=%~dp0..\..\Qt\6.3.1\msvc2019_64 + REM set qt_path=%~dp0..\..\Qt\6.3.1\msvc2019_64 REM get private headers for QtCore Xcopy /E /I /Y /Q %~dp0..\..\Qt\5.15.2\msvc2019_64\include\QtCore\5.15.2\QtCore %~dp0..\..\Qt\5.15.2\msvc2019_64\include\QtCore -REM Xcopy /E /I /Y /Q %~dp0..\..\Qt\6.3.1\msvc2019_64\include\QtCore\6.3.1\QtCore %~dp0..\..\Qt\6.3.1\msvc2019_64\include\QtCore + REM Xcopy /E /I /Y /Q %~dp0..\..\Qt\6.3.1\msvc2019_64\include\QtCore\6.3.1\QtCore %~dp0..\..\Qt\6.3.1\msvc2019_64\include\QtCore set build_arch=x64 set qt_params= call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" -) -IF %1 == ARM64 ( +) ELSE IF %1 == ARM64 ( set qt_path=%~dp0..\..\Qt\6.3.1\msvc2019_64 REM get private headers for QtCore @@ -34,10 +36,10 @@ IF %1 == ARM64 ( set build_arch=ARM64 -REM set qt_params=-qtconf "%~dp0..\..\Qt\6.3.1\msvc2019_arm64\bin\target_qt.conf" - -REM type %~dp0..\..\Qt\6.3.1\msvc2019_arm64\bin\target_qt.conf - + REM set qt_params=-qtconf "%~dp0..\..\Qt\6.3.1\msvc2019_arm64\bin\target_qt.conf" + + REM type %~dp0..\..\Qt\6.3.1\msvc2019_arm64\bin\target_qt.conf + REM REM The target_qt.conf as provided by the windows-2019 github action runner REM is non functional, hence we create our own working edition here. @@ -58,8 +60,12 @@ REM type %~dp0..\..\Qt\6.3.1\msvc2019_arm64\bin\target_qt.conf set qt_params=-qtconf "%~dp0..\..\Qt\6.3.1\msvc2019_arm64\bin\my_target_qt.conf" -REM set VSCMD_DEBUG=3 -call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsamd64_arm64.bat" + REM set VSCMD_DEBUG=3 + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsamd64_arm64.bat" +) ELSE ( + echo Unknown architecture! + call :print_usage + exit /b 2 ) @echo on @@ -121,8 +127,13 @@ rem dir .\bin rem dir .\bin\%build_arch% rem dir .\bin\%build_arch%\Release -goto :eof +exit /b 0 + +:print_usage +echo Usage: qmake_plus.cmd ^ +echo Architecture can be Win32 / x64 / ARM64 :error echo Build failed -exit 1 +exit /b 1 +