aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend/ninjabackend.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-02-23 11:05:47 -0800
committerDylan Baker <dylan@pnwbakers.com>2021-05-18 09:34:36 -0700
commite7e04c814ba8f513deb7b67d298277e083cd1514 (patch)
tree5a58980d3ff05380f5ebcca9f3ec44319e44ca26 /mesonbuild/backend/ninjabackend.py
parent11d123332d5242c419b4cc3ae0e0df4102ab189a (diff)
downloadmeson-e7e04c814ba8f513deb7b67d298277e083cd1514.zip
meson-e7e04c814ba8f513deb7b67d298277e083cd1514.tar.gz
meson-e7e04c814ba8f513deb7b67d298277e083cd1514.tar.bz2
Add a rust test for internal c linkage
We have code to support this, but no tests. That seems pretty bad. And better yet, it doesn't work on MSVC in some cases.
Diffstat (limited to 'mesonbuild/backend/ninjabackend.py')
-rw-r--r--mesonbuild/backend/ninjabackend.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index cd7f450..3749ff7 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1608,12 +1608,19 @@ int dummy;
# dependency, so that collisions with libraries in rustc's
# sysroot don't cause ambiguity
args += ['--extern', '{}={}'.format(d.name, os.path.join(d.subdir, d.filename))]
+ elif d.typename == 'static library':
+ # Rustc doesn't follow Meson's convention that static libraries
+ # are called .a, and implementation libraries are .lib, so we
+ # have to manually handle that.
+ if rustc.linker.id == 'link':
+ args += ['-C', f'link-arg={self.get_target_filename_for_linking(d)}']
+ else:
+ args += ['-l', f'static={d.name}']
+ external_deps.extend(d.external_deps)
else:
- # Rust uses -l for non rust dependencies, but we still need to add (shared|static)=foo
- _type = 'static' if d.typename == 'static library' else 'dylib'
- args += ['-l', f'{_type}={d.name}']
- if d.typename == 'static library':
- external_deps.extend(d.external_deps)
+ # Rust uses -l for non rust dependencies, but we still need to
+ # add dylib=foo
+ args += ['-l', f'dylib={d.name}']
for e in external_deps:
for a in e.get_link_args():
if a.endswith(('.dll', '.so', '.dylib')):