diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2023-06-21 12:15:07 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2023-06-27 11:53:18 -0700 |
commit | c5b16ab8b957d53b75c73bb24144a4f61c86234d (patch) | |
tree | d4ada77ecd56f09ea3996a39a60cae4dd6b156f4 /mesonbuild | |
parent | 43f24060f3e0065b44b1909d88bcc8e2882e9e5e (diff) | |
download | meson-c5b16ab8b957d53b75c73bb24144a4f61c86234d.zip meson-c5b16ab8b957d53b75c73bb24144a4f61c86234d.tar.gz meson-c5b16ab8b957d53b75c73bb24144a4f61c86234d.tar.bz2 |
modules/rust: Add a machine file property for extra clang args with bindgen
It's currently impossible to inject extra clang arguments when using
bindgen, which is problematic when cross compiling since you may need
critical arguments like `--target=...`. Because such arguments must be
passed after the `--` it's impossible to inject them currently without
going to something like a wrapper script.
Fixes: #11805
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/envconfig.py | 6 | ||||
-rw-r--r-- | mesonbuild/modules/rust.py | 5 |
2 files changed, 10 insertions, 1 deletions
diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py index 1bf6ab9..11821fb 100644 --- a/mesonbuild/envconfig.py +++ b/mesonbuild/envconfig.py @@ -237,6 +237,12 @@ class Properties: value = T.cast('T.Optional[str]', self.properties.get('java_home')) return Path(value) if value else None + def get_bindgen_clang_args(self) -> T.List[str]: + value = mesonlib.listify(self.properties.get('bindgen_clang_arguments', [])) + if not all(isinstance(v, str) for v in value): + raise EnvironmentException('bindgen_clang_arguments must be a string or an array of strings') + return T.cast('T.List[str]', value) + def __eq__(self, other: object) -> bool: if isinstance(other, type(self)): return self.properties == other.properties diff --git a/mesonbuild/modules/rust.py b/mesonbuild/modules/rust.py index 4153630..faca9c0 100644 --- a/mesonbuild/modules/rust.py +++ b/mesonbuild/modules/rust.py @@ -201,7 +201,10 @@ class RustModule(ExtensionModule): else: depends.append(d) - clang_args: T.List[str] = [] + # Copy to avoid subsequent calls mutating the original + # TODO: if we want this to be per-machine we'll need a native kwarg + clang_args = state.environment.properties.host.get_bindgen_clang_args().copy() + for i in state.process_include_dirs(kwargs['include_directories']): # bindgen always uses clang, so it's safe to hardcode -I here clang_args.extend([f'-I{x}' for x in i.to_string_list( |