-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild-test-sdl2-ems.bat
More file actions
97 lines (84 loc) · 2.6 KB
/
build-test-sdl2-ems.bat
File metadata and controls
97 lines (84 loc) · 2.6 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
@echo off
setlocal EnableDelayedExpansion
:: Get the directory of this script (assumed to be the ImGuiX folder)
set IMGUIX_PATH=%~dp0
:: Remove trailing slash if present
if "%IMGUIX_PATH:~-1%"=="\" set IMGUIX_PATH=%IMGUIX_PATH:~0,-1%
:: Read emsdk and build path from configuration file
set EMSDK_CONF_FILE=%~dp0\emsdk-path.txt
if not exist "%EMSDK_CONF_FILE%" (
echo emsdk-path.txt not found at %EMSDK_CONF_FILE%
PAUSE
exit /b
)
set /p EMSDK_PATH=<"%EMSDK_CONF_FILE%"
set /a __skip=0
for /f "skip=1 delims=" %%i in (%EMSDK_CONF_FILE%) do (
if !__skip! EQU 0 (
set BUILD_PATH=%%i
set /a __skip=1
)
)
if "%EMSDK_PATH%"=="" (
echo EMSDK_PATH is empty.
PAUSE
exit /b
)
if "%BUILD_PATH%"=="" (
echo BUILD_PATH is empty.
PAUSE
exit /b
)
:: Check if the path begins with a drive letter (e.g., C:) or with "\\"
echo Checking BUILD_PATH...
:: If the path does NOT start with "X:\" it's considered relative
echo %BUILD_PATH% | findstr /B /R "^[A-Za-z]:\\\|^\\\\">nul
if errorlevel 1 (
echo BUILD_PATH is relative, prepending script path...
set "BUILD_PATH=%~dp0%BUILD_PATH%"
)
:: Strip possible trailing slash
if "%BUILD_PATH:~-1%"=="\" set "BUILD_PATH=%BUILD_PATH:~0,-1%"
echo Using EMSDK_PATH: %EMSDK_PATH%
echo Using BUILD_PATH: %BUILD_PATH%
cd /d %EMSDK_PATH%
if errorlevel 1 exit /b %errorlevel%
call emsdk_env.bat
if errorlevel 1 exit /b %errorlevel%
cd /d %IMGUIX_PATH%
:: Create build directory
if not exist "%BUILD_PATH%" mkdir "%BUILD_PATH%"
echo Starting compilation...
emcc ^
examples/smoke/backend_demo.cpp ^
libs/imgui/imgui.cpp ^
libs/imgui/imgui_draw.cpp ^
libs/imgui/imgui_tables.cpp ^
libs/imgui/imgui_widgets.cpp ^
libs/imgui/imgui_demo.cpp ^
libs/imgui/backends/imgui_impl_sdl2.cpp ^
libs/imgui/backends/imgui_impl_opengl3.cpp ^
libs/imgui/misc/freetype/imgui_freetype.cpp ^
-DIMGUIX_USE_SDL2_BACKEND ^
-DIMGUI_ENABLE_FREETYPE ^
-Iinclude ^
-Ilibs/imgui ^
-Ilibs/imgui/backends ^
-Ilibs/imgui/misc/freetype ^
-s USE_SDL=2 ^
-s USE_WEBGL2=1 ^
-s USE_FREETYPE=1 ^
-s WASM=1 ^
-s ALLOW_MEMORY_GROWTH=1 ^
--preload-file assets/data/resources/fonts/Roboto-Light.ttf@data/resources/fonts/Roboto-Light.ttf ^
--shell-file assets/data/web/shell-fullscreen.html ^
-o %BUILD_PATH%\index.html > %BUILD_PATH%\build_log.txt 2>&1
if errorlevel 1 (
echo Compilation failed with error code %errorlevel%.
PAUSE
exit /b %errorlevel%
)
:: Display success message
echo Compilation successful! The build is located in %BUILD_PATH%.
echo You can now run the application in your browser.
PAUSE