Skip to content

Commit 275ff4c

Browse files
committed
feat: meson build
1 parent 122533c commit 275ff4c

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

meson.options

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
option('main_module', type: 'boolean', value: true)
2+
option('side_module', type: 'boolean', value: true)
3+
option('simd', type: 'boolean', value: true)

scripts/emscripten.cross

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[binaries]
2+
c = 'emcc'
3+
cpp = 'em++'
4+
ar = 'emar'
5+
ranlib = 'emranlib'
6+
strip = 'llvm-strip'
7+
pkgconfig = 'em-pkg-config'
8+
9+
[built-in options]
10+
c_args = []
11+
c_link_args = []
12+
13+
[host_machine]
14+
system = 'emscripten'
15+
cpu_family = 'wasm32'
16+
cpu = 'wasm32'
17+
endian = 'little'

scripts/postinstall.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python3
2+
import os, sys, shutil
3+
4+
def main():
5+
prefix = os.environ.get('MESON_INSTALL_DESTDIR_PREFIX') or (sys.argv[1] if len(sys.argv) > 1 else None)
6+
if not prefix:
7+
prefix = os.getcwd()
8+
wasm_dir = os.path.join(prefix, 'wasm')
9+
if not os.path.isdir(wasm_dir):
10+
return 0
11+
target = os.path.join(wasm_dir, 'libjpeg-turbo-side.wasm')
12+
if os.path.exists(target):
13+
return 0
14+
for f in os.listdir(wasm_dir):
15+
if f.endswith('.wasm'):
16+
shutil.copy2(os.path.join(wasm_dir,f), target)
17+
break
18+
return 0
19+
20+
if __name__ == '__main__':
21+
raise SystemExit(main())
22+

wasm/wasm_compat_side.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* wasm_compat_side.c - SIDE_MODULE compatibility layer for libjpeg-turbo
3+
* Copyright (c) 2025 Superstruct Ltd, New Zealand
4+
* Licensed under same license as libjpeg-turbo
5+
*/
6+
7+
#include <emscripten.h>
8+
9+
/* SIDE_MODULE export declarations for libjpeg-turbo */
10+
EMSCRIPTEN_KEEPALIVE int wasm_side_module_init(void) {
11+
return 1; /* Success */
12+
}
13+
14+
EMSCRIPTEN_KEEPALIVE const char* wasm_side_module_version(void) {
15+
return "3.1.2-wasm-native";
16+
}
17+
18+
/* Forward declarations for SIDE_MODULE exports */
19+
extern int jpeg_wasm_init(void);
20+
extern void jpeg_wasm_cleanup(void);
21+
22+
EMSCRIPTEN_KEEPALIVE int libjpeg_turbo_side_init(void) {
23+
return jpeg_wasm_init();
24+
}
25+
26+
EMSCRIPTEN_KEEPALIVE void libjpeg_turbo_side_cleanup(void) {
27+
jpeg_wasm_cleanup();
28+
}

0 commit comments

Comments
 (0)