-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerate.bat
More file actions
135 lines (111 loc) · 3.42 KB
/
Copy pathgenerate.bat
File metadata and controls
135 lines (111 loc) · 3.42 KB
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
@echo off
REM -----------------------------
REM generate.bat
REM Generates the VS solution
REM Uses premake5.exe and preserves extra arguments
REM -----------------------------
set "PREMAKE_URL=https://github.com/premake/premake-core/releases/download/v5.0.0-beta8/premake-5.0.0-beta8-windows.zip"
set "PREMAKE_HASH=2301e3e23ff3074cb83a5ea6103d68c7ea81dad56b786807c84b0643cddea31b"
REM The following variables can be set:
REM PREMAKE_NO_GLOBAL - Ignore premake5 executable from PATH
REM PREMAKE_NO_PROMPT - Download premake5 without prompting
cd /d "%~dp0"
git submodule sync --recursive
if errorlevel 1 (
echo Failed to sync git submodules. >&2
exit /b 1
)
git submodule update --init --recursive
if errorlevel 1 (
echo Failed to update git submodules. >&2
exit /b 1
)
if exist "deps\SDL\include\SDL.h" (
echo Using SDL source from deps\SDL
) else if exist "deps\SDL2-src\SDL2-2.32.10\include\SDL.h" (
echo Using SDL fallback source from deps\SDL2-src\SDL2-2.32.10
) else (
echo WARNING: SDL source not found. SDL backend project will not be generated.
)
if "%PREMAKE_NO_GLOBAL%"=="" (
where /q "premake5.exe"
if not errorlevel 1 (
set "PREMAKE_BIN=premake5.exe"
goto runpremake
)
)
if exist "tools\premake5.exe" (
call :verifypremake "tools\premake5.exe"
if not errorlevel 1 (
set "PREMAKE_BIN=tools\premake5.exe"
goto runpremake
)
echo Existing tools\premake5.exe does not match the pinned Premake build.
)
if not "%PREMAKE_NO_PROMPT%"=="" (
call :downloadpremake
if errorlevel 1 exit /b 1
set "PREMAKE_BIN=tools\premake5.exe"
goto runpremake
)
echo Could not find premake5. You can either install it yourself or this script can download it for you.
set /p choice="Do you wish to download it automatically? [y/N]> "
if /i "%choice%"=="y" (
call :downloadpremake
if errorlevel 1 exit /b 1
set "PREMAKE_BIN=tools\premake5.exe"
goto runpremake
)
echo Please install premake5 and try again.
exit /b 1
:downloadpremake
if not exist "tools" mkdir "tools"
where /q "pwsh"
if not errorlevel 1 (
set "POWERSHELL_BIN=pwsh"
) else (
set "POWERSHELL_BIN=powershell"
)
echo Downloading premake5...
%POWERSHELL_BIN% -NoProfile -NonInteractive -Command "Invoke-WebRequest '%PREMAKE_URL%' -OutFile 'tools\premake.zip'"
if errorlevel 1 (
echo Download failed. >&2
exit /b 2
)
echo Extracting premake5...
%POWERSHELL_BIN% -NoProfile -NonInteractive -Command "Expand-Archive -LiteralPath 'tools\premake.zip' -DestinationPath 'tools' -Force"
if errorlevel 1 (
echo Extraction failed. >&2
del /q "tools\premake.zip" >NUL 2>&1
exit /b 2
)
del /q "tools\premake.zip" >NUL 2>&1
echo Verifying premake5 hash...
call :verifypremake "tools\premake5.exe"
if errorlevel 1 (
echo Hash verification failed. >&2
del /q "tools\premake5.exe" >NUL 2>&1
exit /b 2
)
exit /b 0
:verifypremake
if "%POWERSHELL_BIN%"=="" (
where /q "pwsh"
if not errorlevel 1 (
set "POWERSHELL_BIN=pwsh"
) else (
set "POWERSHELL_BIN=powershell"
)
)
%POWERSHELL_BIN% -NoProfile -NonInteractive -Command "if ((Get-FileHash -LiteralPath '%~1' -Algorithm SHA256).Hash -eq '%PREMAKE_HASH%') { exit 0 } else { exit 1 }"
exit /b %ERRORLEVEL%
:runpremake
%PREMAKE_BIN% %* vs2022
if errorlevel 1 (
echo Premake generation failed. >&2
exit /b 1
)
if not exist "build" (
mkdir build
)
echo consolation-client.sln should now be in build\