Repository: mesonbuild/meson

Issue:
SIMD module doesn't respect include_directories
This snippet that I'm trying to use in PulseAudio is failing because `topinc` isn't actually added to the list of includes.

```
simd = import('unstable-simd')
libpulsecore_simd = simd.check('libpulsecore_simd',
  sse : ['remap_sse.c', 'sconv_sse.c', 'svolume_sse.c'],
  neon : ['remap_neon.c', 'sconv_neon.c', 'svolume_neon.c'],
  include_directories : topinc,
  compiler : cc)
cdata.merge_from(libpulsecore_simd[1])
```


Discussion:

Resolving patch:
diff --git a/mesonbuild/modules/unstable_simd.py b/mesonbuild/modules/unstable_simd.py
--- a/mesonbuild/modules/unstable_simd.py
+++ b/mesonbuild/modules/unstable_simd.py
@@ -43,6 +43,12 @@ def check(self, interpreter, state, args, kwargs):
             raise mesonlib.MesonException('Argument must be a string.')
         if 'compiler' not in kwargs:
             raise mesonlib.MesonException('Must specify compiler keyword')
+        if 'sources' in kwargs:
+            raise mesonlib.MesonException('SIMD module does not support the "sources" keyword')
+        basic_kwargs = {}
+        for key, value in kwargs.items():
+            if key not in self.isets and key != 'compiler':
+                basic_kwargs[key] = value
         compiler = kwargs['compiler'].compiler
         if not isinstance(compiler, compilers.compilers.Compiler):
             raise mesonlib.MesonException('Compiler argument must be a compiler object.')
@@ -64,7 +70,14 @@ def check(self, interpreter, state, args, kwargs):
             conf.values['HAVE_' + iset.upper()] = ('1', 'Compiler supports %s.' % iset)
             libname = prefix + '_' + iset
             lib_kwargs = {'sources': iset_fname,
-                          compiler.get_language() + '_args': args}
+                          }
+            lib_kwargs.update(basic_kwargs)
+            langarg_key = compiler.get_language() + '_args'
+            old_lang_args = lib_kwargs.get(langarg_key, [])
+            if not isinstance(old_lang_args, list):
+                old_lang_args = [old_lang_args]
+            all_lang_args = old_lang_args + args
+            lib_kwargs[langarg_key] = all_lang_args
             result.append(interpreter.func_static_lib(None, [libname], lib_kwargs))
         return [result, cdata]
 


Test patch:
diff --git a/test cases/common/155 simd/include/simdheader.h b/test cases/common/155 simd/include/simdheader.h
new file mode 100644
--- /dev/null
+++ b/test cases/common/155 simd/include/simdheader.h	
@@ -0,0 +1,3 @@
+#pragma once
+
+#define I_CAN_HAZ_SIMD
diff --git a/test cases/common/155 simd/meson.build b/test cases/common/155 simd/meson.build
--- a/test cases/common/155 simd/meson.build	
+++ b/test cases/common/155 simd/meson.build	
@@ -28,7 +28,8 @@ rval = simd.check('mysimds',
   avx : 'simd_avx.c',
   avx2 : 'simd_avx2.c',
   neon : 'simd_neon.c',
-  compiler : cc)
+  compiler : cc,
+  include_directories : include_directories('include'))
 
 simdlibs = rval[0]
 cdata.merge_from(rval[1])
diff --git a/test cases/common/155 simd/simd_avx.c b/test cases/common/155 simd/simd_avx.c
--- a/test cases/common/155 simd/simd_avx.c	
+++ b/test cases/common/155 simd/simd_avx.c	
@@ -1,3 +1,9 @@
+#include<simdheader.h>
+
+#ifndef I_CAN_HAZ_SIMD
+#error The correct internal header was not used
+#endif
+
 #include<simdconfig.h>
 #include<simdfuncs.h>
 #include<stdint.h>