Introduce options for Windows packaging script
authorPierrick Bouvier <pierrick.bouvier@linaro.org>
Thu, 20 Oct 2022 12:12:28 +0000 (14:12 +0200)
committerTobias Hieta <tobias@hieta.se>
Thu, 20 Oct 2022 12:13:28 +0000 (14:13 +0200)
Options:
--version: [required] version to build
--help: display this help
--x86: build and test x86 variant
--x64: build and test x64 variant

Note: At least one variant to build is required.

Example: build_llvm_release.bat --version 15.0.0 --x64

Reviewed By: hans, thieta

Differential Revision: https://reviews.llvm.org/D135255

llvm/utils/release/build_llvm_release.bat

index 7922066..01502a0 100755 (executable)
@@ -1,28 +1,58 @@
 @echo off\r
 setlocal enabledelayedexpansion\r
 \r
-if "%1"=="" goto usage\r
 goto begin\r
 \r
 :usage\r
 echo Script for building the LLVM installer on Windows,\r
 echo used for the releases at https://github.com/llvm/llvm-project/releases\r
 echo.\r
-echo Usage: build_llvm_release.bat ^<version^>\r
+echo Usage: build_llvm_release.bat --version ^<version^> [--x86,--x64]\r
 echo.\r
-echo Example: build_llvm_release.bat 14.0.4\r
+echo Options:\r
+echo --version: [required] version to build\r
+echo --help: display this help\r
+echo --x86: build and test x86 variant\r
+echo --x64: build and test x64 variant\r
 echo.\r
+echo Note: At least one variant to build is required.\r
+echo.\r
+echo Example: build_llvm_release.bat --version 15.0.0 --x86 --x64\r
 exit /b 1\r
 \r
 :begin\r
 \r
+::==============================================================================\r
+:: parse args\r
+set version=\r
+set help=\r
+set x86=\r
+set x64=\r
+call :parse_args %*\r
+\r
+if "%help%" NEQ "" goto usage\r
+\r
+if "%version%" == "" (\r
+    echo --version option is required\r
+    echo =============================\r
+    goto usage\r
+)\r
+\r
+if "%x64%" == "" if "%x86%" == "" (\r
+    echo nothing to build!\r
+    echo choose one or several variants from: --x86 --x64\r
+    exit /b 1\r
+)\r
+\r
+::==============================================================================\r
+:: check prerequisites\r
 REM Note:\r
 REM   7zip versions 21.x and higher will try to extract the symlinks in\r
 REM   llvm's git archive, which requires running as administrator.\r
 \r
 REM Check 7-zip version and/or administrator permissions.\r
-for /f "delims=" %%i in ('7z.exe ^| findstr /r "2[1-9].[0-9][0-9]"') do set version=%%i\r
-if not "%version%"=="" (\r
+for /f "delims=" %%i in ('7z.exe ^| findstr /r "2[1-9].[0-9][0-9]"') do set version_7z=%%i\r
+if not "%version_7z%"=="" (\r
   REM Unique temporary filename to use by the 'mklink' command.\r
   set "link_name=%temp%\%username%_%random%_%random%.tmp"\r
 \r
@@ -32,7 +62,7 @@ if not "%version%"=="" (
   if errorlevel 1 (\r
     echo.\r
     echo Script requires administrator permissions, or a 7-zip version 20.x or older.\r
-    echo Current version is "%version%"\r
+    echo Current version is "%version_7z%"\r
     exit /b 1\r
   ) else (\r
     REM Remove the temporary symbolic link.\r
@@ -50,8 +80,9 @@ REM
 REM\r
 REM   For LLDB, SWIG version <= 3.0.8 needs to be used to work around\r
 REM   https://github.com/swig/swig/issues/769\r
+REM\r
 \r
-\r
+:: Detect Visual Studio\r
 set vsdevcmd=\r
 set vs_2019_prefix=C:\Program Files (x86)\Microsoft Visual Studio\2019\r
 :: try potential activated visual studio, then 2019, with different editions\r
@@ -66,13 +97,15 @@ if not exist "%vsdevcmd%" (
 )\r
 echo Using VS devcmd: %vsdevcmd%\r
 \r
+::==============================================================================\r
 :: start echoing what we do\r
 @echo on\r
+\r
 set python32_dir=C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310-32\r
 set python64_dir=C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python310\r
 \r
-set revision=llvmorg-%1\r
-set package_version=%1\r
+set revision=llvmorg-%version%\r
+set package_version=%version%\r
 set build_dir=%cd%\llvm_package_%package_version%\r
 \r
 echo Revision: %revision%\r
@@ -118,8 +151,8 @@ REM Preserve original path
 set OLDPATH=%PATH%\r
 \r
 REM Build the 32-bits and/or 64-bits binaries.\r
-call :do_build_32 || exit /b 1\r
-call :do_build_64 || exit /b 1\r
+if "%x86%" == "true" call :do_build_32 || exit /b 1\r
+if "%x64%" == "true" call :do_build_64 || exit /b 1\r
 exit /b 0\r
 \r
 ::==============================================================================\r