-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathbuild.bat
137 lines (121 loc) · 3.11 KB
/
build.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
@echo off
setlocal
set BINARY_NAME=objs\srs-sip.exe
set MAIN_PATH=main\main.go
set VUE_DIR=html\NextGB
set CONFIG_FILE=conf\config.yaml
if "%1"=="" goto all
if "%1"=="build" goto build
if "%1"=="clean" goto clean
if "%1"=="run" goto run
if "%1"=="vue-install" goto vue-install
if "%1"=="vue-build" goto vue-build
if "%1"=="vue-dev" goto vue-dev
if "%1"=="all" goto all
:build
echo Building Go binary...
if not exist "objs" mkdir objs
go build -o %BINARY_NAME% %MAIN_PATH%
echo Copying config file...
if exist "%CONFIG_FILE%" (
if not exist "objs\conf" mkdir "objs\conf"
xcopy /s /i /y "%CONFIG_FILE%" "objs\conf\"
echo Config file copied to objs\conf
) else (
echo Warning: %CONFIG_FILE% not found
)
goto :eof
:clean
echo Cleaning...
if exist %BINARY_NAME% del /F /Q %BINARY_NAME%
if exist %VUE_DIR%\dist rd /S /Q %VUE_DIR%\dist
if exist %VUE_DIR%\node_modules rd /S /Q %VUE_DIR%\node_modules
if exist objs\html rd /S /Q objs\html
if exist objs\%CONFIG_FILE% del /F /Q objs\%CONFIG_FILE%
goto :eof
:run
echo Running application...
go build -o %BINARY_NAME% %MAIN_PATH%
%BINARY_NAME%
goto :eof
:vue-install
echo Installing Vue dependencies...
cd %VUE_DIR%
call npm install
cd ..\..
goto :eof
:vue-build
echo Building Vue project...
if not exist "%VUE_DIR%" (
echo Error: Vue directory not found at %VUE_DIR%
goto :eof
)
rem Check Node.js version
where node >nul 2>nul
if errorlevel 1 (
echo Error: Node.js is not installed
goto :eof
)
for /f "tokens=1,2,3 delims=." %%a in ('node -v') do (
set NODE_MAJOR=%%a
)
set NODE_MAJOR=%NODE_MAJOR:~1%
if %NODE_MAJOR% LSS 17 (
echo Error: Node.js version 17 or higher is required ^(current version: %NODE_MAJOR%^)
echo Please upgrade Node.js using the official installer or nvm-windows
goto :eof
)
pushd %VUE_DIR%
echo Current directory: %CD%
if not exist "package.json" (
echo Error: package.json not found in %VUE_DIR%
popd
goto :eof
)
rem Check if node_modules exists and install dependencies if needed
if not exist "node_modules" (
echo Node modules not found, installing dependencies...
call npm install
if errorlevel 1 (
echo Error: Failed to install dependencies
popd
goto :eof
)
)
echo Running npm run build...
call npm run build
if errorlevel 1 (
echo Error: Vue build failed
popd
goto :eof
)
popd
echo Vue build completed successfully
echo Copying dist files to objs directory...
if exist objs\html rd /S /Q objs\html
if not exist objs mkdir objs
if not exist "%VUE_DIR%\dist" (
echo Error: Vue dist directory not found at %VUE_DIR%\dist
goto :eof
)
robocopy "%VUE_DIR%\dist" "objs\html" /E /NFL /NDL /NJH /NJS /nc /ns /np
if errorlevel 8 (
echo Error copying files
) else (
echo Vue dist files successfully copied to objs\html
)
goto :eof
:vue-dev
echo Starting Vue development server...
cd %VUE_DIR%
call npm run dev
cd ..\..
goto :eof
:all
echo Building entire project...
call :build
call :vue-build
echo.
echo Press any key to exit...
pause>nul
goto :eof