Skip to content

Commit

Permalink
Rename "web" to "emscripten", simplify the build, add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-derevenetz committed Jan 3, 2025
1 parent 214fe9a commit 82ef673
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 184 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,38 @@ jobs:
artifactErrorsFailBuild: true
prerelease: true
replacesArtifacts: true
make-emscripten:
name: Make (Emscripten)
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- name: Build
run: |
docker run --rm -v "$(pwd):/src" -e FHEROES2_STRICT_COMPILATION=ON emscripten/emsdk:3.1.74 \
sh -c "apt-get -y update && apt-get -y install gettext && emmake make -f Makefile.emscripten -j \"$(nproc)\""
- name: Create package
run: |
# Translations and H2D files are already included in fheroes2.data
7z a -bb1 -tzip -- fheroes2_emscripten.zip LICENSE changelog.txt fheroes2.data fheroes2.js fheroes2.wasm ./docs/README.txt ./files/emscripten/*
- uses: actions/upload-artifact@v4
if: ${{ github.event_name == 'pull_request' }}
with:
name: fheroes2_emscripten.zip
path: fheroes2_emscripten.zip
if-no-files-found: error
- uses: ncipollo/release-action@v1
if: ${{ github.event_name == 'push' }}
with:
artifacts: fheroes2_emscripten.zip
body: ${{ github.event.head_commit.message }}
token: ${{ secrets.GITHUB_TOKEN }}
name: Emscripten build (latest commit)
tag: fheroes2-emscripten-sdl2_dev
allowUpdates: true
artifactErrorsFailBuild: true
prerelease: true
replacesArtifacts: true
18 changes: 12 additions & 6 deletions Makefile.web → Makefile.emscripten
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,20 @@
# FHEROES2_WITH_DEBUG: build in debug mode
# FHEROES2_DATA: set the built-in path to the fheroes2 data directory (e.g. /usr/share/fheroes2)

PROJECT_NAME := fheroes2
PROJECT_VERSION := $(file < version.txt)
.PHONY: all clean translations

.PHONY: all clean
all: fheroes2.js

all:
$(MAKE) -C src/dist PLATFORM=web
fheroes2.js: translations
$(MAKE) -C src/dist PLATFORM=emscripten
cp src/dist/fheroes2-ems/fheroes2.data .
cp src/dist/fheroes2-ems/fheroes2.js .
cp src/dist/fheroes2-ems/fheroes2.wasm .

translations:
$(MAKE) -C files/lang

clean:
$(MAKE) -C src/dist PLATFORM=web clean
$(MAKE) -C src/dist clean
$(MAKE) -C files/lang clean
rm -f fheroes2.data fheroes2.js fheroes2.wasm
4 changes: 2 additions & 2 deletions Makefile.vita
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###########################################################################
# fheroes2: https://github.com/ihhub/fheroes2 #
# Copyright (C) 2021 - 2024 #
# Copyright (C) 2021 - 2025 #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
Expand Down Expand Up @@ -40,7 +40,7 @@ fheroes2.vpk: eboot.bin param.sfo translations
--add files/images/platform/psv/sce_sys/livearea/contents/template.xml=sce_sys/livearea/contents/template.xml \
--add files/data=files/data \
--add files/lang/vita_temp=files/lang \
fheroes2.vpk
fheroes2.vpk
rm -r files/lang/vita_temp

translations: fheroes2.elf
Expand Down
File renamed without changes
File renamed without changes.
14 changes: 0 additions & 14 deletions files/web/readme

This file was deleted.

143 changes: 0 additions & 143 deletions files/web/sdl2_mixer.py

This file was deleted.

8 changes: 4 additions & 4 deletions src/dist/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ ifndef FHEROES2_WITH_SYSTEM_SMACKER
$(MAKE) -C thirdparty/libsmacker CCFLAGS="$(CCFLAGS_TP)" CFLAGS="$(CFLAGS_TP)" CXXFLAGS="$(CXXFLAGS_TP)" CPPFLAGS="$(CPPFLAGS_TP)"
endif
$(MAKE) -C engine
ifeq ($(PLATFORM),web)
$(MAKE) -C web
ifeq ($(PLATFORM),emscripten)
$(MAKE) -C fheroes2-ems
else
$(MAKE) -C fheroes2
endif
Expand All @@ -173,8 +173,8 @@ ifndef FHEROES2_WITH_SYSTEM_SMACKER
$(MAKE) -C thirdparty/libsmacker clean
endif
$(MAKE) -C engine clean
ifeq ($(PLATFORM),web)
$(MAKE) -C web clean
ifeq ($(PLATFORM),emscripten)
$(MAKE) -C fheroes2-ems clean
else
$(MAKE) -C fheroes2 clean
endif
Expand Down
16 changes: 9 additions & 7 deletions src/dist/Makefile.web → src/dist/Makefile.emscripten
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,22 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
###########################################################################

CCFLAGS := $(filter-out -pthread,$(CCFLAGS)) --use-port=sdl2_mixer \
CCFLAGS := $(filter-out -pthread,$(CCFLAGS)) \
--use-port=sdl2 \
--use-port=zlib
--use-port=sdl2_mixer \
--use-port=zlib \
-Wno-variadic-macro-arguments-omitted

LDFLAGS := $(filter-out -pthread,$(LDFLAGS)) -sENVIRONMENT=web \
LDFLAGS := $(filter-out -pthread,$(LDFLAGS)) \
--preload-file ../../../files/data/resurrection.h2d@/files/data/resurrection.h2d \
--preload-file ../../../files/lang/@/files/lang/ \
--preload-file ../../../files/soundfonts/fheroes2.sf3@/files/soundfonts/fheroes2.sf3 \
-sNO_DISABLE_EXCEPTION_CATCHING \
-sSTACK_SIZE=262144 \
-sINITIAL_MEMORY=128mb \
-sENVIRONMENT=web \
-sASYNCIFY \
-sASYNCIFY_STACK_SIZE=20480 \
-sENVIRONMENT=web \
-sINITIAL_MEMORY=128mb \
-sNO_DISABLE_EXCEPTION_CATCHING \
-sSTACK_SIZE=262144 \
-lidbfs.js

ifdef FHEROES2_WITH_DEBUG
Expand Down
9 changes: 1 addition & 8 deletions src/dist/web/Makefile → src/dist/fheroes2-ems/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,12 @@ VPATH := $(SOURCEDIRS)
all: fheroes2.js

fheroes2.js: $(notdir $(patsubst %.cpp, %.o, $(SOURCES))) $(DEPLIBS)
xgettext -d fheroes2.js --language=JavaScript -F -k_ -k_n:1,2 -o fheroes2.pot $(sort $(SOURCES))
$(MAKE) -C ../../../files/lang
$(CXX) -o $@ $^ $(LIBS) $(LDFLAGS)
rm -f *.d *.o *.tmp *.pot~ *.pot
mkdir -p dist
mv -f fheroes2.* dist
cp ../../../files/web/dist/* dist

%.o: %.cpp
$(CXX) -c -MD $< $(addprefix -I, $(SOURCEDIRS)) $(CCFLAGS) $(CXXFLAGS) $(CPPFLAGS)

include $(wildcard *.d)

clean:
rm -f *.d *.o fheroes2.js fheroes2.wasm fheroes2.wasm.* fheroes2.data fheroes2.pot fheroes2.pot~
rm -rf dist
rm -f *.d *.o fheroes2.data fheroes2.js fheroes2.wasm

0 comments on commit 82ef673

Please sign in to comment.