[PATCH] D133483: Add command line argument parsing to the Windows packaging script.
Carlos Alberto Enciso via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 9 02:28:27 PDT 2022
CarlosAlbertoEnciso updated this revision to Diff 458991.
CarlosAlbertoEnciso added a comment.
Update title, example and how to use the function.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133483/new/
https://reviews.llvm.org/D133483
Files:
llvm/utils/release/build_llvm_release.bat
Index: llvm/utils/release/build_llvm_release.bat
===================================================================
--- llvm/utils/release/build_llvm_release.bat
+++ llvm/utils/release/build_llvm_release.bat
@@ -251,3 +251,63 @@
exit /b 0
::==============================================================================
+
+::=============================================================================
+:: Parse command line arguments.
+:: The format for the arguments is:
+:: Boolean: --option
+:: Value: --option<separator>value
+:: with <separator> being: space, colon, semicolon or equal sign
+::
+:: Command line usage example:
+:: my-batch-file.bat --build --type=release --version 123
+:: It will create 3 variables:
+:: 'build' with the value 'true'
+:: 'type' with the value 'release'
+:: 'version' with the value '123'
+::
+:: Usage:
+:: set "build="
+:: set "type="
+:: set "version="
+::
+:: REM Parse arguments.
+:: call :parse_args %*
+::
+:: if defined build (
+:: ...
+:: )
+:: if %type%=='release' (
+:: ...
+:: )
+:: if %version%=='123' (
+:: ...
+:: )
+::=============================================================================
+:parse_args
+ set "arg_name="
+ :parse_args_start
+ if "%1" == "" (
+ :: Set a seen boolean argument.
+ if "%arg_name%" neq "" (
+ set "%arg_name%=true"
+ )
+ goto :parse_args_done
+ )
+ set aux=%1
+ if "%aux:~0,2%" == "--" (
+ :: Set a seen boolean argument.
+ if "%arg_name%" neq "" (
+ set "%arg_name%=true"
+ )
+ set "arg_name=%aux:~2,250%"
+ ) else (
+ set "%arg_name%=%1"
+ set "arg_name="
+ )
+ shift
+ goto :parse_args_start
+
+:parse_args_done
+exit /b 0
+::==============================================================================
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133483.458991.patch
Type: text/x-patch
Size: 1870 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220909/77ec5be8/attachment.bin>
More information about the llvm-commits
mailing list