ing
This commit is contained in:
parent
f20b7ded97
commit
afe6fbad16
62
build.bat
62
build.bat
|
@ -1,50 +1,28 @@
|
||||||
@ECHO OFF
|
@ECHO OFF
|
||||||
|
|
||||||
:: =====================================================================
|
:: build.bat -o windows -a amd64
|
||||||
:: This function sets a variable from a cli arg with value
|
|
||||||
:: 1 cli argument name
|
set o=windows
|
||||||
:: 2 variable name
|
set a=amd64
|
||||||
:: 3 current Argument Name
|
|
||||||
:: 4 current Argument Value
|
:initial
|
||||||
:getArgWithValue
|
if "%1"=="" goto done
|
||||||
if "%~3"=="%~1" (
|
echo %1
|
||||||
if "%~4"=="" (
|
set aux=%1
|
||||||
REM unset the variable if value is not provided
|
if "%aux:~0,1%"=="-" (
|
||||||
set "%~2="
|
set nome=%aux:~1,250%
|
||||||
exit /B 1
|
) else (
|
||||||
)
|
set "%nome%=%1"
|
||||||
set "%~2=%~4"
|
set nome=
|
||||||
exit /B 0
|
|
||||||
)
|
)
|
||||||
exit /B 1
|
shift
|
||||||
goto:eof
|
goto initial
|
||||||
|
:done
|
||||||
|
|
||||||
:: =====================================================================
|
|
||||||
:: 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
|
|
||||||
|
|
||||||
|
|
||||||
:: your code here ...
|
:: your code here ...
|
||||||
echo OS: %o_os%
|
echo OS: %o%
|
||||||
echo ARCH: %o_arch%
|
echo ARCH: %a%
|
||||||
|
|
||||||
goto:eof
|
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
|
#!/bin/bash
|
||||||
|
|
||||||
#rm ./dist
|
# ./build.sh -o linux -a amd64
|
||||||
#CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags="-s" -o ./dist/probe
|
|
||||||
|
|
||||||
while getopts "o:a:" option; do
|
while getopts "o:a:" option; do
|
||||||
case "${option}" in
|
case "${option}" in
|
||||||
|
@ -25,4 +24,5 @@ if [ -z "${o_arch}" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
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
|
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