Repository navigation
Expand file tree
/
Copy pathbuild.bat
More file actions
120 lines (95 loc) · 3.59 KB
/
Copy pathbuild.bat
File metadata and controls
120 lines (95 loc) · 3.59 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
@echo off
setlocal EnableExtensions EnableDelayedExpansion
cd /d "%~dp0"
set "CONFIG_OVERRIDE=%~1"
set "PYTHON_EXE=.venv\Scripts\python.exe"
if not "%~3"=="" (
echo Usage: build.bat [Debug^|Release^|RelWithDebInfo^|MinSizeRel] [ME^|ME-OH]
exit /b 2
)
if not exist "%PYTHON_EXE%" (
echo Missing .venv. Run init.bat first.
exit /b 1
)
for /f "usebackq eol=# tokens=1,2 delims==" %%a in ("versions.conf") do set %%a=%%b
if "%~2"=="" goto :variant_default
if /i "%~2"=="ME" goto :variant_me
if /i "%~2"=="ME-OH" goto :variant_me_oh
echo Unknown SFML variant "%~2". Use ME or ME-OH.
exit /b 2
:variant_me
set "SFML_VARIANT=ME"
set "SFML_VARIANT_TAG=%SFML_ME_TAG%"
goto :variant_ready
:variant_me_oh
set "SFML_VARIANT=ME-OH"
set "SFML_VARIANT_TAG=%SFML_ME_OH_TAG%"
goto :variant_ready
:variant_default
set "SFML_VARIANT="
set "SFML_VARIANT_TAG=%SFML_TAG%"
goto :variant_ready
:variant_ready
if not exist "third_party\SFML\CMakeLists.txt" (
echo Missing third_party\SFML. Run init.bat %SFML_VARIANT% first.
exit /b 1
)
set "SFML_TAG_CURRENT="
if exist "third_party\SFML\.luasf-sfml-tag" set /p SFML_TAG_CURRENT=<"third_party\SFML\.luasf-sfml-tag"
if not "!SFML_TAG_CURRENT!"=="!SFML_VARIANT_TAG!" (
echo third_party\SFML is not the !SFML_VARIANT! ^(!SFML_VARIANT_TAG!^) checkout.
echo Run init.bat %SFML_VARIANT% first.
exit /b 1
)
if not exist "third_party\Lua\src\lua.h" (
echo Missing third_party\Lua. Run init.bat %SFML_VARIANT% first.
exit /b 1
)
set "VARIANT_FILE=%~dp0.luasf-sfml-variant"
set "PREVIOUS_VARIANT="
if exist "%VARIANT_FILE%" set /p PREVIOUS_VARIANT=<"%VARIANT_FILE%"
if not "!PREVIOUS_VARIANT!"=="!SFML_VARIANT!" (
echo SFML variant changed; discarding the previous output\build directory.
if exist "output\build" rmdir /s /q "output\build"
)
echo Extracting SFML public API...
"%PYTHON_EXE%" tools\extract_sfml_api.py --include-dir third_party/SFML/include
if errorlevel 1 exit /b 1
echo Generating LuaGlue bindings...
"%PYTHON_EXE%" tools\generate_glue_bindings.py
if errorlevel 1 exit /b 1
echo Generating standalone output CMake project...
"%PYTHON_EXE%" tools\generate_build_files.py --force-sort
if errorlevel 1 exit /b 1
if "%SFML_VARIANT%"=="" (
rem The default variant is intentionally represented by an empty marker.
rem `set /p` is not reliable for creating an empty file in cmd.exe.
type nul >"%VARIANT_FILE%"
) else (
>"%VARIANT_FILE%" echo %SFML_VARIANT%
)
set "CONFIGURE_ARGS=-DLUASF_SFML_ROOT=%~dp0third_party\SFML -DLUASF_LUA_ROOT=%~dp0third_party\Lua"
if not "%CONFIG_OVERRIDE%"=="" (
set "CONFIGURE_ARGS=!CONFIGURE_ARGS! -DLUASF_DEFAULT_CONFIG=%CONFIG_OVERRIDE% -DCMAKE_BUILD_TYPE=%CONFIG_OVERRIDE%"
)
echo Configuring output CMake project...
cmake -S output\LuaSF -B output\build %CONFIGURE_ARGS%
if errorlevel 1 exit /b 1
set "BUILD_CONFIG="
for /f "tokens=2 delims==" %%a in ('cmake -N -LA output\build 2^>nul ^| findstr /B /C:"LUASF_DEFAULT_CONFIG:"') do set "BUILD_CONFIG=%%a"
if "%BUILD_CONFIG%"=="" (
echo Failed to read LUASF_DEFAULT_CONFIG from CMake cache.
exit /b 1
)
echo Building embedded LuaSF, host luac, and Lua stub from output CMake project...
cmake --build output\build --config %BUILD_CONFIG% --target LuaSF_build_outputs --parallel 1
if errorlevel 1 exit /b 1
set "EMBEDDED_DLL=%~dp0output\build\bin\%BUILD_CONFIG%\embedded\LuaSF.dll"
if not exist "%EMBEDDED_DLL%" set "EMBEDDED_DLL=%~dp0output\build\bin\embedded\%BUILD_CONFIG%\LuaSF.dll"
echo.
echo Done.
echo Project: %~dp0output
echo SFML variant: %SFML_VARIANT% (%SFML_VARIANT_TAG%)
echo Embedded DLL: %EMBEDDED_DLL%
echo Stub: %~dp0output\build\LuaSF.d.lua
endlocal