You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.1 KiB

@echo off
setlocal enabledelayedexpansion
REM 处理架构参数(第三个参数)
if "%3"=="" (
set "goarch=amd64"
set "releasePath=x86_64"
) else if "%3"=="arm" (
set "goarch=arm"
set "releasePath=arm"
) else if "%3"=="arm64" (
set "goarch=arm64"
set "releasePath=arm64"
) else if "%3"=="loong64" (
set "goarch=loong64"
set "releasePath=loong64"
) else (
echo 目标 %3 无法编译
exit /b 1
)
REM 处理操作系统参数(第二个参数)
if "%2"=="linux" (
echo 交叉编译目标为linux+%goarch%
set "CGO_ENABLED=0"
set "GOOS=linux"
set "GOARCH=%goarch%"
go build -o "%~n1-!releasePath!" %1
) else if "%2"=="windows" (
echo 交叉编译目标为windows+%goarch%
set "CGO_ENABLED=0"
set "GOOS=windows"
set "GOARCH=%goarch%"
go build -o "%~n1-!releasePath!.exe" %1
) else if "%2"=="darwin" (
echo 交叉编译目标为maxos+%goarch%
set "CGO_ENABLED=0"
set "GOOS=darwin"
set "GOARCH=%goarch%"
go build -o "%~n1-!releasePath!" %1
) else (
echo 参数不正确: %2
exit /b 1
)
echo 脚本执行结束...
endlocal