add web build

This commit is contained in:
2026-11-03 14:19:16 +03:00
parent 6003acd40c
commit f6efe2956e
3 changed files with 139 additions and 17 deletions

View File

@@ -4,8 +4,7 @@
SEXC ?= sexc
CC ?= cc
BUILD_DIR := build
RAYLIB_LIB := $(BUILD_DIR)/libraylib.a
RAYLIB_LIB := build/libraylib.a
RAYLIB_PLATFORM ?= PLATFORM_DESKTOP
RAYLIB_BUILD_MODE ?= RELEASE
@@ -33,23 +32,55 @@ all: catch-phase
catch-phase: $(OBJECTS) $(RAYLIB_LIB)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(RAYLIB_LIB) $(RAYLIB_LIBS)
$(BUILD_DIR):
mkdir -p $@
main.o: main.sex | $(OBJ_DIR)
$(SEXC) $< -c -o $@ -- $(CFLAGS) $(INCLUDES)
# raylib ------------------------------------------------------------
$(RAYLIB_LIB):
mkdir -p build
$(MAKE) -C $(RAYLIB_SRC) \
PLATFORM=$(RAYLIB_PLATFORM) \
RAYLIB_LIBTYPE=STATIC \
RAYLIB_BUILD_MODE=$(RAYLIB_BUILD_MODE) \
RAYLIB_RELEASE_PATH=$(abspath $(BUILD_DIR))
RAYLIB_RELEASE_PATH=$(abspath ./build)
# web build ---------------------------------------------------------
EMCC ?= emcc
EMAR ?= emar
WEB_SEXC := $(SEXC) --c-compiler=$(EMCC) --no-platform-features --features=emscripten
EMFLAGS := -O2 -DPLATFORM_WEB \
-sUSE_GLFW=3 \
-sTOTAL_MEMORY=134217728 \
-sFORCE_FILESYSTEM=1 \
--shell-file shell.html \
--preload-file ./res@/res
web/libraylib.web.a:
mkdir -p web
$(MAKE) -C $(RAYLIB_SRC) \
PLATFORM=PLATFORM_WEB \
RAYLIB_LIBTYPE=STATIC \
RAYLIB_BUILD_MODE=RELEASE \
GRAPHICS=GRAPHICS_API_OPENGL_ES2 \
RAYLIB_RELEASE_PATH=$(abspath ./web)
web/index.html: main.sex shell.html web/libraylib.web.a
$(WEB_SEXC) main.sex -o $@ -- \
-I$(RAYLIB_SRC) \
./web/libraylib.web.a \
$(EMFLAGS)
web: web/index.html
serve: web
python3 -m http.server -d web 8000
# ------------------------------------------------------------
clean:
$(MAKE) -C $(RAYLIB_SRC) clean
rm -rf $(BUILD_DIR)
rm -rf ./build ./web
rm -f catch-phase
.PHONY: all clean