diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 855c0bd7a..8163bca78 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -28,6 +28,8 @@ known_basic_kwargs = {'install': True, 'c_pch': True, 'cpp_pch': True, 'c_args': True, + 'objc_args': True, + 'objcpp_args': True, 'cpp_args': True, 'cs_args': True, 'vala_args': True, @@ -627,6 +629,14 @@ class BuildTarget(Target): if not isinstance(valalist, list): valalist = [valalist] self.add_compiler_args('vala', valalist) + objclist = kwargs.get('objc_args', []) + if not isinstance(objclist, list): + objclist = [objclist] + self.add_compiler_args('objc', objclist) + objcpplist = kwargs.get('objcpp_args', []) + if not isinstance(objcpplist, list): + objcpplist = [objcpplist] + self.add_compiler_args('objcpp', objcpplist) fortranlist = kwargs.get('fortran_args', []) if not isinstance(fortranlist, list): fortranlist = [fortranlist] diff --git a/test cases/objc/4 objc args/meson.build b/test cases/objc/4 objc args/meson.build new file mode 100644 index 000000000..8887d96bc --- /dev/null +++ b/test cases/objc/4 objc args/meson.build @@ -0,0 +1,4 @@ +project('objective c args', 'objc') + +exe = executable('prog', 'prog.m', objc_args : ['-DMESON_TEST']) +test('objective c args', exe) diff --git a/test cases/objc/4 objc args/prog.m b/test cases/objc/4 objc args/prog.m new file mode 100644 index 000000000..bfd686a86 --- /dev/null +++ b/test cases/objc/4 objc args/prog.m @@ -0,0 +1,11 @@ +#import + +int main(int argc, char **argv) +{ +#ifdef MESON_TEST + int x = 3; +#endif + + printf("x = %d\n", x); + return 0; +} diff --git a/test cases/objc/5 objc++ args/meson.build b/test cases/objc/5 objc++ args/meson.build new file mode 100644 index 000000000..e0e34b0f1 --- /dev/null +++ b/test cases/objc/5 objc++ args/meson.build @@ -0,0 +1,4 @@ +project('objective c++ args', 'objcpp') + +exe = executable('prog', 'prog.mm', objcpp_args : ['-DMESON_OBJCPP_TEST']) +test('objective c++ args', exe) diff --git a/test cases/objc/5 objc++ args/prog.mm b/test cases/objc/5 objc++ args/prog.mm new file mode 100644 index 000000000..3decaf230 --- /dev/null +++ b/test cases/objc/5 objc++ args/prog.mm @@ -0,0 +1,16 @@ +#import + +class TestClass +{ +}; + +int main(int argc, char **argv) +{ +#ifdef MESON_OBJCPP_TEST +int x = 1; +#endif + + printf("x = %x\n", x); + + return 0; +}