ing
This commit is contained in:
parent
f20b7ded97
commit
afe6fbad16
62
build.bat
62
build.bat
|
@ -1,50 +1,28 @@
|
|||
@ECHO OFF
|
||||
|
||||
:: =====================================================================
|
||||
:: This function sets a variable from a cli arg with value
|
||||
:: 1 cli argument name
|
||||
:: 2 variable name
|
||||
:: 3 current Argument Name
|
||||
:: 4 current Argument Value
|
||||
:getArgWithValue
|
||||
if "%~3"=="%~1" (
|
||||
if "%~4"=="" (
|
||||
REM unset the variable if value is not provided
|
||||
set "%~2="
|
||||
exit /B 1
|
||||
)
|
||||
set "%~2=%~4"
|
||||
exit /B 0
|
||||
:: build.bat -o windows -a amd64
|
||||
|
||||
set o=windows
|
||||
set a=amd64
|
||||
|
||||
:initial
|
||||
if "%1"=="" goto done
|
||||
echo %1
|
||||
set aux=%1
|
||||
if "%aux:~0,1%"=="-" (
|
||||
set nome=%aux:~1,250%
|
||||
) else (
|
||||
set "%nome%=%1"
|
||||
set nome=
|
||||
)
|
||||
exit /B 1
|
||||
goto:eof
|
||||
|
||||
|
||||
:: =====================================================================
|
||||
:: This function sets a variable to value "TRUE" from a cli "flag" argument
|
||||
:: 1 cli argument name
|
||||
:: 2 variable name
|
||||
:: 3 current Argument Name
|
||||
:getArgFlag
|
||||
if "%~3"=="%~1" (
|
||||
set "%~2=TRUE"
|
||||
exit /B 0
|
||||
)
|
||||
exit /B 1
|
||||
goto:eof
|
||||
|
||||
:parseArgs
|
||||
:: asks for the -o argument and store the value in the variable FOO
|
||||
call:getArgWithValue "-o" "o_os" "%~1" "%~2" && shift && shift && goto :parseArgs
|
||||
|
||||
:: asks for the -bar argument and store the value in the variable BAR
|
||||
call:getArgWithValue "-a" "o_arch" "%~1" "%~2" && shift && shift && goto :parseArgs
|
||||
|
||||
shift
|
||||
goto initial
|
||||
:done
|
||||
|
||||
:: your code here ...
|
||||
echo OS: %o_os%
|
||||
echo ARCH: %o_arch%
|
||||
echo OS: %o%
|
||||
echo ARCH: %a%
|
||||
|
||||
goto:eof
|
||||
|
||||
::SET GOOS=%o_os% SET GOARCH=%o_arch% SET CGO_ENABLED=1 go build -a --installsuffix cgo --ldflags="-s" -o ./dist/probe ./cmd/main.go
|
||||
::SET GOOS=%o% SET GOARCH=%a% SET CGO_ENABLED=1 go build -a --installsuffix cgo --ldflags="-s" -o ./dist/probe ./cmd/main.go
|
4
build.sh
4
build.sh
|
@ -1,7 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
#rm ./dist
|
||||
#CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags="-s" -o ./dist/probe
|
||||
# ./build.sh -o linux -a amd64
|
||||
|
||||
while getopts "o:a:" option; do
|
||||
case "${option}" in
|
||||
|
@ -25,4 +24,5 @@ if [ -z "${o_arch}" ]; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
rm ./dist
|
||||
GOOS=${o_os} GOARCH=${o_arch} CGO_ENABLED=1 go build -a --installsuffix cgo --ldflags="-s" -o ./dist/probe ./cmd/main.go
|
||||
|
|
Loading…
Reference in New Issue
Block a user