瀏覽代碼

REXM: Using Makefile.Web for specific web versions generation, only with required resources for every example

pull/5119/head
Ray 1 月之前
父節點
當前提交
6da0a180e6
共有 3 個檔案被更改,包括 32 行新增24 行删除
  1. +2
    -3
      examples/Makefile.Web
  2. +22
    -17
      examples/build_example_web.bat
  3. +8
    -4
      tools/rexm/rexm.c

+ 2
- 3
examples/Makefile.Web 查看文件

@ -104,7 +104,7 @@ USE_WAYLAND_DISPLAY ?= FALSE
BUILD_WEB_ASYNCIFY ?= TRUE
BUILD_WEB_SHELL ?= $(RAYLIB_PATH)/src/shell.html
BUILD_WEB_HEAP_SIZE ?= 134217728
BUILD_WEB_RESOURCES ?= TRUE
BUILD_WEB_RESOURCES ?= FALSE
BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources
# Use WebGL2 backend (OpenGL 3.0)
# 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
textures/textures_mouse_painting: textures/textures_mouse_painting.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file textures/my_amazing_texture_painting.png@my_amazing_texture_painting.png
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
textures/textures_npatch_drawing: textures/textures_npatch_drawing.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \

+ 22
- 17
examples/build_example_web.bat 查看文件

@ -2,26 +2,29 @@
:: .
:: 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
for /f "tokens=1-10 delims=/" %%a in ("%INPUT_FILE%") do (
set CATEGORY=%%a
set FILENAME=%%b
FOR /f "tokens=1-10 delims=/" %%a IN ("%INPUT_FILE%") DO (
SET CATEGORY=%%a
SET FILENAME=%%b
)
:: > Setup required Environment
:: > SETup required Environment
:: -------------------------------------
set RAYLIB_PATH=C:\GitHub\raylib
set EMSDK_PATH=C:\raylib\emsdk
SET RAYLIB_PATH=C:\GitHub\raylib
SET EMSDK_PATH=C:\raylib\emsdk
SET COMPILER_PATH=C:\raylib\w64devkit\bin
ENV_SET PATH=%COMPILER_PATH%
SET MAKE=mingw32-make
echo
:: Set required web compilation options
:: SET required web compilation options
:: -------------------------------------
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 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
:: TODO: If using some resources/assets, set the directory path as shown in the commented line!
k">set RESOURCES=
::set RESOURCES=--preload-file $(RESOURCES_PATH)
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 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
:: TODO: If using some resources/asSETs, SET the directory path as shown in the commented line!
p">::SET RESOURCES=
::SET RESOURCES=--preload-file $(RESOURCES_PATH)
cd %RAYLIB_PATH%\examples\%CATEGORY%
echo
:: 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%.data del /F %FILENAME%.data
echo
:: Setup emsdk environment
:: SETup emsdk environment
:: --------------------------
call %EMSDK_PATH%\emsdk_env.bat
echo on
:: Compile program
:: -----------------------
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 ..
echo

+ 8
- 4
tools/rexm/rexm.c 查看文件

@ -842,6 +842,7 @@ int main(int argc, char *argv[])
// Validate: raylib/examples/<category>/resources/.. -> Example resources available?
// 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);
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.wasm -> 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)) ||
!FileExists(TextFormat("%s/%s/%s.wasm", 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))))
if (!TextIsEqual(exInfo->category, "others") &&
(!FileExists(TextFormat("%s/%s/%s.html", exWebPath, exInfo->category, exInfo->name)) ||
!FileExists(TextFormat("%s/%s/%s.wasm", 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;
}
// NOTE: Additional validation elements
// Validate: Example naming conventions: <category>/<category>_example_name, valid category

Loading…
取消
儲存