|
| 1 | +project('json-c.wasm', 'c', version: '0.17.0', meson_version: '>=1.3.0', |
| 2 | + default_options: ['buildtype=release']) |
| 3 | + |
| 4 | +fs = import('fs') |
| 5 | + |
| 6 | +if get_option('simd') |
| 7 | + add_project_arguments('-msimd128', language: 'c') |
| 8 | +endif |
| 9 | + |
| 10 | +incs = include_directories('.') |
| 11 | + |
| 12 | +# Collect core sources (exclude tests/apps/bench/examples) |
| 13 | +core_sources = [] |
| 14 | +core_sources += fs.glob('*.c', exclude: ['tests/**', 'bench/**', 'benchmarks/**', 'examples/**', 'apps/**']) |
| 15 | + |
| 16 | +core = static_library('jsonc_core', core_sources, include_directories: incs) |
| 17 | + |
| 18 | +install_dir = get_option('bindir') |
| 19 | + |
| 20 | +if get_option('main_module') |
| 21 | + main_link_args = [ |
| 22 | + '--no-entry', |
| 23 | + '-sMODULARIZE=1', |
| 24 | + '-sEXPORT_ES6=1', |
| 25 | + '-sALLOW_MEMORY_GROWTH=1', |
| 26 | + '-sENVIRONMENT=web,webview,worker', |
| 27 | + '-sNO_FILESYSTEM=1', |
| 28 | + '-sEXPORTED_RUNTIME_METHODS=["cwrap","ccall","UTF8ToString"]', |
| 29 | + '-sEXPORTED_FUNCTIONS=@' + meson.project_source_root() / get_option('exports'), |
| 30 | + ] |
| 31 | + executable('json-c-main', 'src/jsonc_wasm_module.c', |
| 32 | + link_with: core, |
| 33 | + include_directories: incs, |
| 34 | + install: true, |
| 35 | + link_args: main_link_args) |
| 36 | +endif |
| 37 | + |
| 38 | +if get_option('side_module') |
| 39 | + shared_module('json-c-side', 'src/jsonc_wasm_side.c', |
| 40 | + link_whole: core, |
| 41 | + include_directories: incs, |
| 42 | + install: true, |
| 43 | + link_args: ['-sSIDE_MODULE=2', '-fPIC']) |
| 44 | +endif |
| 45 | + |
0 commit comments