diff options
author | Alyssa Ross <hi@alyssa.is> | 2022-02-08 10:25:36 +0000 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2022-02-10 15:05:37 -0800 |
commit | 3596b6b19a0e5bf6ce65a640448d459c85180184 (patch) | |
tree | 678e67f9d8c5c375465549e5e24293cffaa2a294 | |
parent | 755b2ab6dae0b4ea5addeac70008d58b1900e9aa (diff) | |
download | meson-3596b6b19a0e5bf6ce65a640448d459c85180184.zip meson-3596b6b19a0e5bf6ce65a640448d459c85180184.tar.gz meson-3596b6b19a0e5bf6ce65a640448d459c85180184.tar.bz2 |
ninjabackend: fix rust program names with dashes
This substitution matches the behaviour of rustc[1] when inferring
crate name based on file name.
[1]: https://github.com/rust-lang/rust/tree/4e8fb743ccbec27344b2dd42de7057f41d4ebfdd/compiler/rustc_session/src/output.rs#L88
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 3 | ||||
-rw-r--r-- | test cases/rust/1 basic/meson.build | 2 | ||||
-rw-r--r-- | test cases/rust/1 basic/subdir/meson.build | 2 | ||||
-rw-r--r-- | test cases/rust/1 basic/test.json | 8 |
4 files changed, 8 insertions, 7 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 080d009..f4df789 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1709,7 +1709,8 @@ class NinjaBackend(backends.Backend): args.extend(rustc.get_linker_always_args()) args += self.generate_basic_compiler_args(target, rustc, False) - args += ['--crate-name', target.name] + # This matches rustc's default behavior. + args += ['--crate-name', target.name.replace('-', '_')] depfile = os.path.join(target.subdir, target.name + '.d') args += ['--emit', f'dep-info={depfile}', '--emit', 'link'] args += target.get_extra_args('rust') diff --git a/test cases/rust/1 basic/meson.build b/test cases/rust/1 basic/meson.build index 3919279..63ad375 100644 --- a/test cases/rust/1 basic/meson.build +++ b/test cases/rust/1 basic/meson.build @@ -1,6 +1,6 @@ project('rustprog', 'rust') -e = executable('program', 'prog.rs', +e = executable('rust-program', 'prog.rs', rust_args : ['-C', 'lto'], # Just a test install : true ) diff --git a/test cases/rust/1 basic/subdir/meson.build b/test cases/rust/1 basic/subdir/meson.build index 51b385b..36a3d4a 100644 --- a/test cases/rust/1 basic/subdir/meson.build +++ b/test cases/rust/1 basic/subdir/meson.build @@ -1,2 +1,2 @@ -e = executable('program2', 'prog.rs', install : true) +e = executable('rust-program2', 'prog.rs', install : true) test('rusttest2', e) diff --git a/test cases/rust/1 basic/test.json b/test cases/rust/1 basic/test.json index 94c995b..95e6ced 100644 --- a/test cases/rust/1 basic/test.json +++ b/test cases/rust/1 basic/test.json @@ -1,8 +1,8 @@ { "installed": [ - {"type": "exe", "file": "usr/bin/program"}, - {"type": "pdb", "file": "usr/bin/program"}, - {"type": "exe", "file": "usr/bin/program2"}, - {"type": "pdb", "file": "usr/bin/program2"} + {"type": "exe", "file": "usr/bin/rust-program"}, + {"type": "pdb", "file": "usr/bin/rust-program"}, + {"type": "exe", "file": "usr/bin/rust-program2"}, + {"type": "pdb", "file": "usr/bin/rust-program2"} ] } |