summaryrefslogtreecommitdiff
path: root/mesonbuild/modules/simd.py
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/modules/simd.py')
-rw-r--r--mesonbuild/modules/simd.py50
1 files changed, 29 insertions, 21 deletions
diff --git a/mesonbuild/modules/simd.py b/mesonbuild/modules/simd.py
index afd3a2af0..bce89dd2d 100644
--- a/mesonbuild/modules/simd.py
+++ b/mesonbuild/modules/simd.py
@@ -19,7 +19,7 @@ from .. import mesonlib, mlog
from .. import build
from ..compilers import Compiler
from ..interpreter.type_checking import BT_SOURCES_KW, STATIC_LIB_KWS
-from ..interpreterbase.decorators import KwargInfo, typed_pos_args, typed_kwargs
+from ..interpreterbase.decorators import KwargInfo, permittedKwargs, typed_pos_args, typed_kwargs
from . import ExtensionModule, ModuleInfo
@@ -74,40 +74,48 @@ class SimdModule(ExtensionModule):
*[BT_SOURCES_KW.evolve(name=iset) for iset in ISETS],
*[a for a in STATIC_LIB_KWS if a.name != 'sources'],
allow_unknown=True) # Because we also accept STATIC_LIB_KWS, but build targets have not been completely ported to typed_pos_args/typed_kwargs.
+ @permittedKwargs({'compiler', *ISETS, *build.known_stlib_kwargs}) # Also remove this, per above comment
def check(self, state: ModuleState, args: T.Tuple[str], kwargs: CheckKw) -> T.List[T.Union[T.List[build.StaticLibrary], build.ConfigurationData]]:
result: T.List[build.StaticLibrary] = []
+
if 'sources' in kwargs:
raise mesonlib.MesonException('SIMD module does not support the "sources" keyword')
+
+ local_kwargs = set((*ISETS, 'compiler'))
+ static_lib_kwargs = T.cast('kwtypes.StaticLibrary', {k: v for k, v in kwargs.items() if k not in local_kwargs})
+
prefix = args[0]
- basic_kwargs = {}
- for key, value in kwargs.items():
- if key not in ISETS and key != 'compiler':
- basic_kwargs[key] = value
compiler = kwargs['compiler']
conf = build.ConfigurationData()
+
for iset in ISETS:
- if iset not in kwargs:
+ sources = kwargs[iset]
+
+ compile_args = compiler.get_instruction_set_args(iset)
+ if compile_args is None:
+ mlog.log(f'Compiler supports {iset}:', mlog.red('NO'))
continue
- iset_fname = kwargs[iset] # Might also be an array or Files. static_library will validate.
- args = compiler.get_instruction_set_args(iset)
- if args is None:
- mlog.log('Compiler supports %s:' % iset, mlog.red('NO'))
+
+ if not compiler.has_multi_arguments(compile_args, state.environment)[0]:
+ mlog.log(f'Compiler supports {iset}:', mlog.red('NO'))
continue
- if args:
- if not compiler.has_multi_arguments(args, state.environment)[0]:
- mlog.log('Compiler supports %s:' % iset, mlog.red('NO'))
- continue
- mlog.log('Compiler supports %s:' % iset, mlog.green('YES'))
- conf.values['HAVE_' + iset.upper()] = ('1', 'Compiler supports %s.' % iset)
+ mlog.log(f'Compiler supports {iset}:', mlog.green('YES'))
+ conf.values['HAVE_' + iset.upper()] = ('1', f'Compiler supports {iset}.')
+
libname = prefix + '_' + iset
- lib_kwargs = {'sources': iset_fname,
- }
- lib_kwargs.update(basic_kwargs)
+ lib_kwargs = static_lib_kwargs.copy()
+ lib_kwargs['sources'] = sources
+
+ # Add compile args we derived above to those the user provided us
langarg_key = compiler.get_language() + '_args'
old_lang_args = mesonlib.extract_as_list(lib_kwargs, langarg_key)
- all_lang_args = old_lang_args + args
+ all_lang_args = old_lang_args + compile_args
lib_kwargs[langarg_key] = all_lang_args
- result.append(self.interpreter.func_static_lib(None, [libname], lib_kwargs))
+
+ lib = self.interpreter.build_target(state.current_node, (libname, []), lib_kwargs, build.StaticLibrary)
+
+ result.append(lib)
+
return [result, conf]
def initialize(interp: Interpreter) -> SimdModule: