diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2023-04-13 16:09:03 +0300 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2023-04-14 06:11:44 -0400 |
commit | 49e62877d14fee68baf854fde3c13f58a97384de (patch) | |
tree | 654cfc75d5427202a2a4fac2b02a923e68a0fe45 | |
parent | 93cafe7b14c23ba4b6ef59267c584714afb8f0e8 (diff) | |
download | meson-49e62877d14fee68baf854fde3c13f58a97384de.zip meson-49e62877d14fee68baf854fde3c13f58a97384de.tar.gz meson-49e62877d14fee68baf854fde3c13f58a97384de.tar.bz2 |
rust: Don't pass dependency compile arguments to the compiler
Rust doesn't have a concept of dependency compile arguments, i.e.
something like headers. Dependencies are linked in and all required
metadata is provided by the linker flags.
-rw-r--r-- | mesonbuild/compilers/rust.py | 7 | ||||
-rw-r--r-- | test cases/rust/16 internal c dependencies/meson.build | 8 |
2 files changed, 13 insertions, 2 deletions
diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py index 2d158e3..1c43f7a 100644 --- a/mesonbuild/compilers/rust.py +++ b/mesonbuild/compilers/rust.py @@ -28,6 +28,7 @@ if T.TYPE_CHECKING: from ..linkers import DynamicLinker from ..mesonlib import MachineChoice from ..programs import ExternalProgram + from ..dependencies import Dependency rust_optimization_args = { @@ -153,6 +154,12 @@ class RustCompiler(Compiler): ), } + def get_dependency_compile_args(self, dep: 'Dependency') -> T.List[str]: + # Rust doesn't have dependency compile arguments so simply return + # nothing here. Dependencies are linked and all required metadata is + # provided by the linker flags. + return [] + def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]: args = [] key = OptionKey('std', machine=self.for_machine, lang=self.language) diff --git a/test cases/rust/16 internal c dependencies/meson.build b/test cases/rust/16 internal c dependencies/meson.build index c7476d7..f459828 100644 --- a/test cases/rust/16 internal c dependencies/meson.build +++ b/test cases/rust/16 internal c dependencies/meson.build @@ -3,12 +3,16 @@ project('internal dependencies', 'c', 'rust') test_prog = find_program('test.py') static = static_library('static', 'lib.c', c_args : '-DMODE="static"') -exe = executable('static', 'main.rs', link_with : static) +# Add some -I compiler arguments to make sure they're not passed to the Rust +# compiler when handling the dependency. +static_dep = declare_dependency(link_with : static, compile_args : ['-Idoesnotexist']) +exe = executable('static', 'main.rs', dependencies : static_dep) test('static linkage', test_prog, args : [exe, 'This is a static C library']) # Shared linkage with rust doesn't work on macOS with meson, yet if host_machine.system() != 'darwin' shared = shared_library('shared', 'lib.c', c_args : '-DMODE="shared"') - exe = executable('shared', 'main.rs', link_with : shared) + shared_dep = declare_dependency(link_with : shared, compile_args : ['-Idoesnotexist']) + exe = executable('shared', 'main.rs', dependencies : shared_dep) test('shared linkage', test_prog, args : [exe, 'This is a shared C library']) endif |