mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.64k stars 1.64k forks source link

rust.bindgen fails in subprojects #12526

Open notpeelz opened 1 year ago

notpeelz commented 1 year ago

Describe the bug I get this error when I use rust.bindgen() from within a subproject:

subprojects/foo/meson.build:14:17: ERROR: Tried to get unknown builtin option foo:c_args

To Reproduce

git clone https://github.com/notpeelz/bug-repro-meson-subproject-bindgen
cd bug-repro-meson-subproject-bindgen
meson setup build
meson compile -C build

This doesn't reproduce on meson 1.2.3. I believe this bug was introduced by #12283

system parameters

fvalette commented 1 year ago

Hi, I've got the exact same issue, the following fixes the issue but i am not sure it's the correct answer. E.g setting from top level project -D<subproject>:c_args="whatever" does not have any effect w/ meson 1.3.0 (i.e. whatever does not appear on c compile argument while compile in verbose) ! Is this the expected behavior ?

--- a/mesonbuild/modules/rust.py
+++ b/mesonbuild/modules/rust.py
@@ -241,7 +241,7 @@ class RustModule(ExtensionModule):
                     depends.append(s)

         # We only want include directories and defines, other things may not be valid
-        cargs = state.get_option('args', state.subproject, lang='c')
+        cargs = state.get_option('args', lang='c')
         assert isinstance(cargs, list), 'for mypy'
         for a in itertools.chain(state.global_args.get('c', []), state.project_args.get('c', []), cargs):
             if a.startswith(('-I', '/I', '-D', '/D', '-U', '/U')):
Marc-Pierre-Barbier commented 6 months ago

can confirm the issue still exist (meson 1.3.2)

ndufresne commented 3 weeks ago

I just hit that issue when trying to build mesa as a subproject, meson 1.4.1