mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-03 04:39:18 -05:00
REXM: Using Makefile.Web for specific web versions generation, only with required resources for every example
This commit is contained in:
@ -104,7 +104,7 @@ USE_WAYLAND_DISPLAY ?= FALSE
|
|||||||
BUILD_WEB_ASYNCIFY ?= TRUE
|
BUILD_WEB_ASYNCIFY ?= TRUE
|
||||||
BUILD_WEB_SHELL ?= $(RAYLIB_PATH)/src/shell.html
|
BUILD_WEB_SHELL ?= $(RAYLIB_PATH)/src/shell.html
|
||||||
BUILD_WEB_HEAP_SIZE ?= 134217728
|
BUILD_WEB_HEAP_SIZE ?= 134217728
|
||||||
BUILD_WEB_RESOURCES ?= TRUE
|
BUILD_WEB_RESOURCES ?= FALSE
|
||||||
BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources
|
BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources
|
||||||
# Use WebGL2 backend (OpenGL 3.0)
|
# Use WebGL2 backend (OpenGL 3.0)
|
||||||
# WARNING: Requires raylib compiled with GRAPHICS_API_OPENGL_ES3
|
# WARNING: Requires raylib compiled with GRAPHICS_API_OPENGL_ES3
|
||||||
@ -920,8 +920,7 @@ textures/textures_logo_raylib: textures/textures_logo_raylib.c
|
|||||||
--preload-file textures/resources/raylib_logo.png@resources/raylib_logo.png
|
--preload-file textures/resources/raylib_logo.png@resources/raylib_logo.png
|
||||||
|
|
||||||
textures/textures_mouse_painting: textures/textures_mouse_painting.c
|
textures/textures_mouse_painting: textures/textures_mouse_painting.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
--preload-file textures/my_amazing_texture_painting.png@my_amazing_texture_painting.png
|
|
||||||
|
|
||||||
textures/textures_npatch_drawing: textures/textures_npatch_drawing.c
|
textures/textures_npatch_drawing: textures/textures_npatch_drawing.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||||
|
|||||||
@ -2,26 +2,29 @@
|
|||||||
:: .
|
:: .
|
||||||
:: Compile your examples for web using: build_example_web.bat <example_category>/<example_name>
|
:: Compile your examples for web using: build_example_web.bat <example_category>/<example_name>
|
||||||
:: .
|
:: .
|
||||||
set "INPUT_FILE=%1"
|
SET "INPUT_FILE=%1"
|
||||||
:: Change delimiter for the FOR loop
|
:: Change delimiter for the FOR loop
|
||||||
for /f "tokens=1-10 delims=/" %%a in ("%INPUT_FILE%") do (
|
FOR /f "tokens=1-10 delims=/" %%a IN ("%INPUT_FILE%") DO (
|
||||||
set CATEGORY=%%a
|
SET CATEGORY=%%a
|
||||||
set FILENAME=%%b
|
SET FILENAME=%%b
|
||||||
)
|
)
|
||||||
:: > Setup required Environment
|
:: > SETup required Environment
|
||||||
:: -------------------------------------
|
:: -------------------------------------
|
||||||
set RAYLIB_PATH=C:\GitHub\raylib
|
SET RAYLIB_PATH=C:\GitHub\raylib
|
||||||
set EMSDK_PATH=C:\raylib\emsdk
|
SET EMSDK_PATH=C:\raylib\emsdk
|
||||||
|
SET COMPILER_PATH=C:\raylib\w64devkit\bin
|
||||||
|
ENV_SET PATH=%COMPILER_PATH%
|
||||||
|
SET MAKE=mingw32-make
|
||||||
echo
|
echo
|
||||||
:: Set required web compilation options
|
:: SET required web compilation options
|
||||||
:: -------------------------------------
|
:: -------------------------------------
|
||||||
set CC=%EMSDK_PATH%\upstream\emscripten\emcc
|
SET CC=%EMSDK_PATH%\upstream\emscripten\emcc
|
||||||
set CFLAGS=-Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result -O3 -I. -Iexternal -I%RAYLIB_PATH%\src -I%RAYLIB_PATH%\external -DPLATFORM_WEB
|
SET CFLAGS=-Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result -O3 -I. -Iexternal -I%RAYLIB_PATH%\src -I%RAYLIB_PATH%\external -DPLATFORM_WEB
|
||||||
set LDFLAGS=-L. -L$(RAYLIB_PATH)\src -sUSE_GLFW=3 -sEXPORTED_RUNTIME_METHODS=ccall -sASYNCIFY --shell-file %RAYLIB_PATH%\src\shell.html
|
SET LDFLAGS=-L. -L$(RAYLIB_PATH)\src -sUSE_GLFW=3 -sEXPORTED_RUNTIME_METHODS=ccall -sASYNCIFY --shell-file %RAYLIB_PATH%\src\shell.html
|
||||||
set LDLIBS=%RAYLIB_PATH%\src\libraylib.web.a
|
SET LDLIBS=%RAYLIB_PATH%\src\libraylib.web.a
|
||||||
:: TODO: If using some resources/assets, set the directory path as shown in the commented line!
|
:: TODO: If using some resources/asSETs, SET the directory path as shown in the commented line!
|
||||||
set RESOURCES=
|
::SET RESOURCES=
|
||||||
::set RESOURCES=--preload-file $(RESOURCES_PATH)
|
::SET RESOURCES=--preload-file $(RESOURCES_PATH)
|
||||||
cd %RAYLIB_PATH%\examples\%CATEGORY%
|
cd %RAYLIB_PATH%\examples\%CATEGORY%
|
||||||
echo
|
echo
|
||||||
:: Clean latest build
|
:: Clean latest build
|
||||||
@ -31,13 +34,15 @@ cmd /c if exist %FILENAME%.wasm del /F %FILENAME%.wasm
|
|||||||
cmd /c if exist %FILENAME%.js del /F %FILENAME%.js
|
cmd /c if exist %FILENAME%.js del /F %FILENAME%.js
|
||||||
cmd /c if exist %FILENAME%.data del /F %FILENAME%.data
|
cmd /c if exist %FILENAME%.data del /F %FILENAME%.data
|
||||||
echo
|
echo
|
||||||
:: Setup emsdk environment
|
:: SETup emsdk environment
|
||||||
:: --------------------------
|
:: --------------------------
|
||||||
call %EMSDK_PATH%\emsdk_env.bat
|
call %EMSDK_PATH%\emsdk_env.bat
|
||||||
echo on
|
echo on
|
||||||
:: Compile program
|
:: Compile program
|
||||||
:: -----------------------
|
:: -----------------------
|
||||||
C:
|
C:
|
||||||
%CC% -o %FILENAME%.html %FILENAME%.c %CFLAGS% %LDFLAGS% %LDLIBS% %RESOURCES%
|
cd %RAYLIB_PATH%\examples
|
||||||
|
%MAKE% -f Makefile.Web %CATEGORY%/%FILENAME% PLATFORM=PLATFORM_WEB -B
|
||||||
|
::%CC% -o %FILENAME%.html %FILENAME%.c %CFLAGS% %LDFLAGS% %LDLIBS% %RESOURCES%
|
||||||
cd ..
|
cd ..
|
||||||
echo
|
echo
|
||||||
|
|||||||
@ -842,6 +842,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Validate: raylib/examples/<category>/resources/.. -> Example resources available?
|
// Validate: raylib/examples/<category>/resources/.. -> Example resources available?
|
||||||
// Scan resources used in example to check for missing resource files
|
// Scan resources used in example to check for missing resource files
|
||||||
|
// WARNING: Some paths could be for files to save, not files to load, verify it
|
||||||
char **resPaths = ScanExampleResources(TextFormat("%s/%s/%s.c", exBasePath, exInfo->category, exInfo->name), &exInfo->resCount);
|
char **resPaths = ScanExampleResources(TextFormat("%s/%s/%s.c", exBasePath, exInfo->category, exInfo->name), &exInfo->resCount);
|
||||||
if (exInfo->resCount > 0)
|
if (exInfo->resCount > 0)
|
||||||
{
|
{
|
||||||
@ -881,11 +882,14 @@ int main(int argc, char *argv[])
|
|||||||
// Validate: raylib.com/examples/<category>/<category>_example_name.data -> File exists?
|
// Validate: raylib.com/examples/<category>/<category>_example_name.data -> File exists?
|
||||||
// Validate: raylib.com/examples/<category>/<category>_example_name.wasm -> File exists?
|
// Validate: raylib.com/examples/<category>/<category>_example_name.wasm -> File exists?
|
||||||
// Validate: raylib.com/examples/<category>/<category>_example_name.js -> File exists?
|
// Validate: raylib.com/examples/<category>/<category>_example_name.js -> File exists?
|
||||||
if (!FileExists(TextFormat("%s/%s/%s.html", exWebPath, exInfo->category, exInfo->name)) ||
|
if (!TextIsEqual(exInfo->category, "others") &&
|
||||||
!FileExists(TextFormat("%s/%s/%s.wasm", exWebPath, exInfo->category, exInfo->name)) ||
|
(!FileExists(TextFormat("%s/%s/%s.html", exWebPath, exInfo->category, exInfo->name)) ||
|
||||||
!FileExists(TextFormat("%s/%s/%s.js", exWebPath, exInfo->category, exInfo->name)) ||
|
!FileExists(TextFormat("%s/%s/%s.wasm", exWebPath, exInfo->category, exInfo->name)) ||
|
||||||
((exInfo->resCount > 0) && !FileExists(TextFormat("%s/%s/%s.data", exWebPath, exInfo->category, exInfo->name))))
|
!FileExists(TextFormat("%s/%s/%s.js", exWebPath, exInfo->category, exInfo->name)) ||
|
||||||
|
((exInfo->resCount > 0) && !FileExists(TextFormat("%s/%s/%s.data", exWebPath, exInfo->category, exInfo->name)))))
|
||||||
|
{
|
||||||
exInfo->status |= VALID_MISSING_WEB_OUTPUT;
|
exInfo->status |= VALID_MISSING_WEB_OUTPUT;
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: Additional validation elements
|
// NOTE: Additional validation elements
|
||||||
// Validate: Example naming conventions: <category>/<category>_example_name, valid category
|
// Validate: Example naming conventions: <category>/<category>_example_name, valid category
|
||||||
|
|||||||
Reference in New Issue
Block a user