Skip to content

Commit d0ff641

Browse files
committed
now it works (locally, i modified some dependencies, these need to be patched in the .wrap files!!)
1 parent 2156705 commit d0ff641

File tree

3 files changed

+95
-95
lines changed

3 files changed

+95
-95
lines changed

.github/workflows/web_build.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Web CI
2+
3+
on:
4+
release:
5+
types: [published]
6+
push:
7+
branches: ["main"]
8+
pull_request:
9+
workflow_dispatch:
10+
11+
jobs:
12+
android-build:
13+
runs-on: ubuntu-22.04
14+
steps:
15+
- uses: actions/checkout@v3
16+
with:
17+
fetch-depth: "0"
18+
19+
- name: Setup Meson
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install meson
23+
24+
- name: Setup ninja
25+
uses: seanmiddleditch/gha-setup-ninja@master
26+
27+
- name: Run all
28+
run: |
29+
bash ./android/run-web.sh
30+
31+
# TODO upload page to gh-pages!
32+
- name: Upload artifacts
33+
uses: actions/upload-artifact@v3
34+
with:
35+
name: oopetris-assets
36+
path: |
37+
build-emcc/oopetris.html
38+
build-emcc/oopetris.js
39+
build-emcc/oopetris.wasm
40+
build-emcc/oopetris.worker.js

android/run-web.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@ export RANLIB=emranlib
2020
export STRIP=emstrip
2121
unset PKG_CONFIG
2222

23-
export BUILD_SYSTEM="cmake"
23+
export BUILD_SYSTEM="meson"
2424

2525
if [ $BUILD_SYSTEM = "meson" ]; then
2626

27+
export COMMON_EMSCRIPTEN_OPTIONS="'-fexceptions', '-sEXCEPTION_CATCHING_ALLOWED=[..]'"
28+
29+
export LINK_EMSCRIPTEN_OPTIONS="$COMMON_EMSCRIPTEN_OPTIONS, '-sEXPORT_ALL=1', '-sUSE_GLFW=3', '-sUSE_WEBGPU=1', '-sWASM=1', '-sALLOW_MEMORY_GROWTH=1', '-sNO_EXIT_RUNTIME=0', '-sASSERTIONS=1'"
30+
export COMPILE_EMSCRIPTEN_OPTIONS="$COMMON_EMSCRIPTEN_OPTIONS"
31+
2732
cat <<EOF >"./android/crossbuilt-web.ini"
2833
[host_machine]
2934
system = 'emscripten'
@@ -38,10 +43,6 @@ strip = 'emstrip'
3843
ar = 'emar'
3944
ranlib = 'emranlib'
4045
41-
pkgconfig = ['emcmake']
42-
cmake = ['emcmake']
43-
sdl2-config = ['emconfigure', 'em-config']
44-
4546
exe_wrapper = 'node'
4647
4748
[properties]
@@ -51,6 +52,10 @@ sys_root = './emsdk/upstream/emscripten/cache/sysroot'
5152
[built-in options]
5253
c_std = 'c11'
5354
cpp_std = 'c++20'
55+
c_args = [$COMPILE_EMSCRIPTEN_OPTIONS]
56+
c_link_args = [$LINK_EMSCRIPTEN_OPTIONS]
57+
cpp_args = [$COMPILE_EMSCRIPTEN_OPTIONS]
58+
cpp_link_args = [$LINK_EMSCRIPTEN_OPTIONS]
5459
5560
5661
EOF

meson.build

Lines changed: 45 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -30,36 +30,6 @@ elif cpp.get_id() == 'clang'
3030
add_project_arguments('-std=c++2b', language: 'cpp')
3131
elif cpp.get_id() == 'emscripten'
3232
add_project_arguments('-std=c++2b', language: 'cpp')
33-
34-
emscripten_args = [
35-
'USE_PTHREADS',
36-
'USE_SDL=2',
37-
'USE_SDL_MIXER=2',
38-
'USE_VORBIS=1',
39-
'USE_LIBPNG',
40-
'USE_MPG123=1',
41-
'USE_ZLIB=1',
42-
'SDL2_MIXER_FORMATS=\'["wav", "flac", "mp3"]\'',
43-
'USE_SDL_TTF=2'
44-
]
45-
46-
47-
foreach emscripten_arg : emscripten_args
48-
49-
#setup esmscripten specific beahviour!
50-
add_global_arguments(
51-
'-s',
52-
emscripten_arg,
53-
language: ['c', 'cpp'],
54-
)
55-
56-
add_global_arguments(
57-
'-pthread',
58-
language: ['c', 'cpp'],
59-
)
60-
61-
62-
endforeach
6333
else
6434
add_project_arguments('-std=c++20', language: 'cpp')
6535
endif
@@ -72,71 +42,65 @@ if meson.is_cross_build()
7242
native = false
7343
endif
7444

75-
sdl2_mixer_flags = []
76-
sdl2_mixer_defines = []
7745

78-
if host_machine.system() != 'emscripten'
46+
sdl2_dep = dependency(
47+
'sdl2',
48+
allow_fallback: false,
49+
required: false,
50+
native: native,
51+
)
7952

80-
sdl2_dep = dependency(
53+
if sdl2_dep.found()
54+
deps += sdl2_dep
55+
else
56+
deps += dependency(
8157
'sdl2',
82-
allow_fallback: false,
83-
required: false,
58+
required: true,
59+
fallback: 'sdl2',
8460
native: native,
61+
default_options: ['test=false'],
8562
)
63+
deps += dependency(
64+
'sdl2main',
65+
required: true,
66+
fallback: 'sdl2',
67+
native: native,
68+
)
69+
endif
8670

87-
if sdl2_dep.found()
88-
deps += sdl2_dep
89-
else
90-
deps += dependency(
91-
'sdl2',
92-
required: true,
93-
fallback: 'sdl2',
94-
native: native,
95-
default_options: ['test=false'],
96-
)
97-
deps += dependency(
98-
'sdl2main',
99-
required: true,
100-
fallback: 'sdl2',
101-
native: native,
102-
)
103-
endif
104-
105-
deps += dependency('sdl2_ttf', 'SDL2_ttf', required: true, native: native)
71+
deps += dependency('sdl2_ttf', 'SDL2_ttf', required: true, native: native)
10672

10773

108-
# a dirty thing atm, until mpg123 is ported to meson (maybe never...)
109-
mpg123_dep = dependency('mgp123', required: false, native: native)
110-
sdl2_mixer_flags += ['flac=enabled']
111-
sdl2_mixer_defines += ['-DAUDIO_WITH_FLAC_SUPPORT']
74+
# a dirty thing atm, until mpg123 is ported to meson (maybe never...)
75+
mpg123_dep = dependency('mgp123', required: false, native: native)
76+
sdl2_mixer_flags = ['flac=enabled']
77+
sdl2_mixer_defines = ['-DAUDIO_WITH_FLAC_SUPPORT']
78+
if mpg123_dep.found()
79+
sdl2_mixer_flags += 'mpg123=enabled'
80+
sdl2_mixer_defines += '-DAUDIO_WITH_MP3_SUPPORT'
81+
else
82+
cpp = meson.get_compiler('cpp')
83+
mpg123_dep = cpp.find_library('mpg123', required: false)
11284
if mpg123_dep.found()
11385
sdl2_mixer_flags += 'mpg123=enabled'
11486
sdl2_mixer_defines += '-DAUDIO_WITH_MP3_SUPPORT'
115-
else
116-
cpp = meson.get_compiler('cpp')
117-
mpg123_dep = cpp.find_library('mpg123', required: false)
118-
if mpg123_dep.found()
119-
sdl2_mixer_flags += 'mpg123=enabled'
120-
sdl2_mixer_defines += '-DAUDIO_WITH_MP3_SUPPORT'
121-
122-
meson.override_dependency(
123-
'mpg123',
124-
mpg123_dep,
125-
native: native,
126-
)
127-
endif
128-
endif
129-
130-
deps += dependency(
131-
'sdl2_mixer',
132-
'SDL2_mixer',
133-
required: true,
134-
native: native,
135-
default_options: sdl2_mixer_flags,
136-
)
13787

88+
meson.override_dependency(
89+
'mpg123',
90+
mpg123_dep,
91+
native: native,
92+
)
93+
endif
13894
endif
13995

96+
deps += dependency(
97+
'sdl2_mixer',
98+
'SDL2_mixer',
99+
required: true,
100+
native: native,
101+
default_options: sdl2_mixer_flags,
102+
)
103+
140104

141105
## HEADER ONLY LIBS
142106
deps += dependency(
@@ -192,15 +156,6 @@ if meson.is_cross_build() and host_machine.system() == 'android'
192156
)
193157
elif meson.is_cross_build() and host_machine.system() == 'emscripten'
194158

195-
196-
197-
sdl2_mixer_defines += [
198-
'-DAUDIO_WITH_FLAC_SUPPORT',
199-
'-DAUDIO_WITH_MP3_SUPPORT',
200-
]
201-
202-
203-
## TODO
204159
executable(
205160
'oopetris',
206161
src_files,

0 commit comments

Comments
 (0)