diff options
Diffstat (limited to 'mesonbuild/compilers/mixins/emscripten.py')
-rw-r--r-- | mesonbuild/compilers/mixins/emscripten.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mesonbuild/compilers/mixins/emscripten.py b/mesonbuild/compilers/mixins/emscripten.py index 36a757ae5..ee86ce4d3 100644 --- a/mesonbuild/compilers/mixins/emscripten.py +++ b/mesonbuild/compilers/mixins/emscripten.py @@ -17,8 +17,13 @@ import os.path import typing as T +from ... import coredata from ...mesonlib import MesonException +if T.TYPE_CHECKING: + from ..environment import Environment + + class EmscriptenMixin: def get_option_link_args(self, options): @@ -45,3 +50,24 @@ class EmscriptenMixin: else: suffix = 'wasm' return os.path.join(dirname, 'output.' + suffix) + + def thread_flags(self, env: 'Environment') -> T.List[str]: + return ['-s', 'USE_PTHREADS=1'] + + def thread_link_flags(self, env: 'Environment') -> T.List[str]: + args = ['-s', 'USE_PTHREADS=1'] + count = env.coredata.compiler_options[self.for_machine]['{}_thread_count'.format(self.language)].value # type: int + if count: + args.extend(['-s', 'PTHREAD_POOL_SIZE={}'.format(count)]) + return args + + def get_options(self): + opts = super().get_options() + opts.update({ + '{}_thread_count'.format(self.language): coredata.UserIntegerOption( + 'Number of threads to use in web assembly, set to 0 to disable', + (0, None, 4), # Default was picked at random + ), + }) + + return opts |