-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathbootstrap.bat
178 lines (154 loc) · 4.4 KB
/
bootstrap.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
@echo off
setlocal enabledelayedexpansion
set projectDir=%CD%
echo ::::::::::::::::::::::::::::::::::::::
echo ::::::::::::::::::::::::::::::::::::::
echo ::::: Black Tek Server Bootstrap :::::
echo ::::: (for windows) :::::
echo ::::::::::::::::::::::::::::::::::::::
echo ::::::::::::::::::::::::::::::::::::::
:: Check if vcpkg is installed first.
where vcpkg >nul 2>&1
if %ERRORLEVEL%==0 (
echo Vcpkg installation has been found!
echo skipping vcpkg installation..
goto premake_input
) else (
echo Vcpkg installation has not been detected!
echo moving forward with vpckg installation...
)
:vcpkg_input
echo Please provide the path to the directory you wish to store your vcpgk installation!
echo Warning!! This folder MUST ALREADY EXIST, or it won't be accepted.
echo Example input: C:\Packages\vcpkg
set /p VCPKG_INSTALL_PATH=Path:
:: Remove quotes if user included them
set VCPKG_INSTALL_PATH=!VCPKG_INSTALL_PATH:"=!
:: Check if path exists
if not exist "!VCPKG_INSTALL_PATH!" (
echo Error: The specified path does not exist.
echo Please enter a valid path.
goto vcpkg_input
)
cd "!VCPKG_INSTALL_PATH!"
:: Download and extract vcpkg
echo Downloading vcpkg...
curl -L "https://github.com/microsoft/vcpkg/archive/refs/heads/master.zip" -o vcpkg.zip || (
echo Failed to download vcpkg.
exit /b
)
tar -xf vcpkg.zip
del vcpkg.zip
ren "vcpkg-master" "vcpkg"
:: Setup vcpkg
echo Setting up vcpkg...
cd "!VCPKG_INSTALL_PATH!\vcpkg"
call bootstrap-vcpkg.bat || (
echo Failed to bootstrap vcpkg.
exit /b
)
vcpkg integrate install || (
echo Failed to integrate vcpkg.
exit /b
)
cd "!projectDir!"
:premake_input
echo Please enter a path to a folder for storing premake
echo Warning: This folder must already exist, or it won't be accepted.
echo Example: C:\premake
set /p PREMAKE_PATH=Path:
set PREMAKE_PATH=!PREMAKE_PATH:"=!
:: Check if path exists
if not exist "!PREMAKE_PATH!" (
echo Error: The specified path does not exist.
echo Please enter a valid path.
goto premake_input
)
cd "!PREMAKE_PATH!"
:: Download and extract premake.
:: We are currently locked into a version of premake
:: which does not fail to build using its bootstrap.bat
:: but also supports our needed features.
echo Downloading premake...
curl -L "https://github.com/premake/premake-core/archive/490686ceb24b29f16c1ec817ed05c07c5cce89c6.zip" -o premake.zip || (
echo Failed to download premake.
exit /b
)
tar -xf premake.zip
del premake.zip
ren "premake-core-490686ceb24b29f16c1ec817ed05c07c5cce89c6" "premake-core"
set premakeBin=!PREMAKE_PATH!\premake-core\bin\release\premake5.exe
:: Build premake
echo Building premake...
cd premake-core
cmd /c Bootstrap.bat || (
echo Premake build failed.
exit /b
)
cls
:: Copy premake5.exe to BlackTek-Server
echo Copying premake5.exe...
if not exist "!premakeBin!" (
echo Source file does not exist: "!premakeBin!"
exit /b
)
if not exist "!projectDir!" (
echo Destination directory does not exist: "!projectDir!"
exit /b
)
copy "!premakeBin!" "!projectDir!"
if errorlevel 1 (
echo Failed to copy premake5.exe.
echo Error level: %errorlevel%
echo From: "!premakeBin!"
echo To: "!projectDir!"
exit /b
)
:select_vs_version
cls
echo Select Visual Studio version:
echo [1] Visual Studio 2022
echo [2] Visual Studio 2019
echo [3] Visual Studio 2015
echo [4] Visual Studio 2013
echo [5] Visual Studio 2012
echo.
set /p choice="Enter number (1-5): "
:: Set the vs_version variable based on user choice
if "%choice%"=="1" (
set "vs_version=vs2022"
) else if "%choice%"=="2" (
set "vs_version=vs2019"
) else if "%choice%"=="3" (
set "vs_version=vs2015"
) else if "%choice%"=="4" (
set "vs_version=vs2013"
) else if "%choice%"=="5" (
set "vs_version=vs2012"
) else (
echo Invalid selection. Please try again.
timeout /t 2 >nul
goto select_vs_version
)
:: Confirm selection
echo.
echo You selected Visual Studio %vs_version%
echo.
set /p confirm="Is this correct? (Y/N): "
if /i not "%confirm%"=="Y" goto select_vs_version
:: Run premake with selected version
echo.
echo Generating solution files for %vs_version%...
cd !projectDir!
cmd /c premake5.exe %vs_version%
if errorlevel 1 (
echo Failed to generate solution files.
echo Error level: %errorlevel%
pause
exit /b 1
)
echo Solution files generated successfully!
echo Setup complete. BlackTek has been successfully installed!
pause
exit
endlocal