From 9263c3d6b2b6142a1ab3958e2edc5de385d329c0 Mon Sep 17 00:00:00 2001 From: T0b1 Date: Fri, 28 Apr 2023 20:41:17 +0200 Subject: [PATCH] wasm support --- meson.build | 18 +++++++++++++----- meson_options.txt | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 8a2481c..a088ba8 100644 --- a/meson.build +++ b/meson.build @@ -11,6 +11,12 @@ if not py_version.version_compare('>=3.6') endif cc = meson.get_compiler('c') +if get_option('wasm_build') + add_project_arguments('--target=wasm32', language: 'c') + add_project_arguments(['-nostdlib', '-fvisibility=default'], language: 'c') + +endif + if cc.has_argument('-fstrict-aliasing') add_project_arguments('-fstrict-aliasing', language: 'c') endif @@ -99,11 +105,13 @@ fadec = declare_dependency(link_with: libfadec, sources: tables) install_headers(headers) -foreach component : components - test(component, executable('@0@-test'.format(component), - '@0@-test.c'.format(component), - dependencies: fadec)) -endforeach +if get_option('wasm_build') == false + foreach component : components + test(component, executable('@0@-test'.format(component), + '@0@-test.c'.format(component), + dependencies: fadec)) + endforeach +endif if meson.version().version_compare('>=0.54.0') meson.override_dependency('fadec', fadec) diff --git a/meson_options.txt b/meson_options.txt index 3e8dd68..c9b63cc 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -4,3 +4,4 @@ option('with_decode', type: 'boolean', value: true) option('with_encode', type: 'boolean', value: true) # encode2 is off-by-default to reduce size and compile-time option('with_encode2', type: 'boolean', value: false) +option('wasm_build', type: 'boolean', value: false) \ No newline at end of file