39 lines
1019 B
Batchfile
39 lines
1019 B
Batchfile
@echo off
|
|
setlocal
|
|
|
|
set VERSION=1.0.0
|
|
|
|
REM -- 获取干净时间戳 (powershell) --
|
|
for /f %%I in ('powershell -NoProfile -Command "Get-Date -Format 'yyyy-MM-dd HH:mm:ss'"') do set BUILD_TIME=%%I
|
|
|
|
set GOOS=windows
|
|
set GOARCH=amd64
|
|
set LDFLAGS=-s -w -X main.Version=%VERSION% -X main.BuildTime=%BUILD_TIME%
|
|
|
|
echo.
|
|
echo Building Server...
|
|
if not exist dist\server\data mkdir dist\server\data
|
|
go build -ldflags "%LDFLAGS%" -o dist\server\monitor-server.exe .\cmd\server
|
|
if %errorlevel% neq 0 (
|
|
echo [ERROR] Server build failed!
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
echo Building Client...
|
|
if not exist dist\client mkdir dist\client
|
|
go build -ldflags "%LDFLAGS%" -o dist\client\monitor-client.exe .\cmd\client
|
|
if %errorlevel% neq 0 (
|
|
echo [ERROR] Client build failed!
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
echo.
|
|
echo ===================================================
|
|
echo Server: dist\server\monitor-server.exe
|
|
echo Client: dist\client\monitor-client.exe
|
|
echo ===================================================
|
|
echo.
|
|
pause
|