diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2021-02-23 10:39:06 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2021-02-23 16:22:56 -0800 |
commit | 6544f151db7a04993ff75540ed6a0cb2a4573b02 (patch) | |
tree | cb0f27981c35d869081f067b7f9b4aa864e8726a /mesonbuild | |
parent | 5edbc0acd717bd3bd4268c5d3a43fb07d6593f54 (diff) | |
download | meson-6544f151db7a04993ff75540ed6a0cb2a4573b02.zip meson-6544f151db7a04993ff75540ed6a0cb2a4573b02.tar.gz meson-6544f151db7a04993ff75540ed6a0cb2a4573b02.tar.bz2 |
rust: fix linking with external dependencies
Rust can link with any dependency that uses c linkage, which is pretty
much what we assume across the board anyway.
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 58fd5c6..a0a34b3 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1598,6 +1598,7 @@ int dummy; args += rustc.get_output_args(os.path.join(target.subdir, target.get_filename())) args += self.environment.coredata.get_external_args(target.for_machine, rustc.language) linkdirs = mesonlib.OrderedSet() + external_deps = target.external_deps.copy() for d in target.link_targets: linkdirs.add(d.subdir) if d.uses_rust(): @@ -1609,6 +1610,22 @@ int dummy; # Rust uses -l for non rust dependencies, but we still need to add (shared|static)=foo _type = 'static' if d.typename == 'static library' else 'shared' args += ['-l', f'{_type}={d.name}'] + if d.typename == 'static library': + external_deps.extend(d.external_deps) + for e in external_deps: + for a in e.get_link_args(): + if a.endswith(('.dll', '.so', '.dylib')): + dir_, lib = os.path.split(a) + linkdirs.add(dir_) + lib, ext = os.path.splitext(lib) + if lib.startswith('lib'): + lib = lib[3:] + args.extend(['-l', f'dylib={lib}']) + elif a.startswith('-L'): + args.append(a) + elif a.startswith('-l'): + # This should always be a static lib, I think + args.extend(['-l', f'static={a[2:]}']) for d in linkdirs: if d == '': d = '.' |