diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2022-11-10 11:00:23 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2022-12-05 12:23:55 -0800 |
commit | d49e6bc0384a4a01754f13edb793cb1d6ce0b836 (patch) | |
tree | 4f36246b8918d267c0086239eac4d1b174030d75 /mesonbuild/modules | |
parent | 24b00240650c41b98c51764b6d2f4754bc04dae1 (diff) | |
download | meson-d49e6bc0384a4a01754f13edb793cb1d6ce0b836.zip meson-d49e6bc0384a4a01754f13edb793cb1d6ce0b836.tar.gz meson-d49e6bc0384a4a01754f13edb793cb1d6ce0b836.tar.bz2 |
modules/rust: Add support for dependencies in bindgen
This is needed for cases where we need external C headers, which are
passed to clang.
Diffstat (limited to 'mesonbuild/modules')
-rw-r--r-- | mesonbuild/modules/rust.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/mesonbuild/modules/rust.py b/mesonbuild/modules/rust.py index 078dedf..d41b99c 100644 --- a/mesonbuild/modules/rust.py +++ b/mesonbuild/modules/rust.py @@ -45,6 +45,7 @@ if T.TYPE_CHECKING: include_directories: T.List[IncludeDirs] input: T.List[SourceInputs] output: str + dependencies: T.List[T.Union[Dependency, ExternalLibrary]] class RustModule(ExtensionModule): @@ -173,6 +174,7 @@ class RustModule(ExtensionModule): ), INCLUDE_DIRECTORIES.evolve(feature_validator=include_dir_string_new), OUTPUT_KW, + DEPENDENCIES_KW.evolve(since='1.0.0'), ) def bindgen(self, state: ModuleState, args: T.List, kwargs: FuncBindgen) -> ModuleReturnValue: """Wrapper around bindgen to simplify it's use. @@ -191,12 +193,23 @@ class RustModule(ExtensionModule): else: depends.append(d) - inc_strs: T.List[str] = [] + clang_args: T.List[str] = [] for i in state.process_include_dirs(kwargs['include_directories']): # bindgen always uses clang, so it's safe to hardcode -I here - inc_strs.extend([f'-I{x}' for x in i.to_string_list( + clang_args.extend([f'-I{x}' for x in i.to_string_list( state.environment.get_source_dir(), state.environment.get_build_dir())]) + for de in kwargs['dependencies']: + for i in de.get_include_dirs(): + clang_args.extend([f'-I{x}' for x in i.to_string_list( + state.environment.get_source_dir(), state.environment.get_build_dir())]) + clang_args.extend(de.get_all_compile_args()) + for s in de.get_sources(): + if isinstance(s, File): + depend_files.append(s) + elif isinstance(s, CustomTarget): + depends.append(s) + if self._bindgen_bin is None: self._bindgen_bin = state.find_program('bindgen') @@ -213,7 +226,7 @@ class RustModule(ExtensionModule): '@INPUT@', '--output', os.path.join(state.environment.build_dir, '@OUTPUT@') ] + \ - kwargs['args'] + ['--'] + kwargs['c_args'] + inc_strs + \ + kwargs['args'] + ['--'] + kwargs['c_args'] + clang_args + \ ['-MD', '-MQ', '@INPUT@', '-MF', '@DEPFILE@'] target = CustomTarget( |