ninjabackend: fix rust program names with dashes

This substitution matches the behaviour of rustc[1] when inferring
crate name based on file name.

[1]: 4e8fb743cc/compiler/rustc_session/src/output.rs (L88)
pull/9992/head
Alyssa Ross 3 years ago committed by Dylan Baker
parent 755b2ab6da
commit 3596b6b19a
  1. 3
      mesonbuild/backend/ninjabackend.py
  2. 2
      test cases/rust/1 basic/meson.build
  3. 2
      test cases/rust/1 basic/subdir/meson.build
  4. 8
      test cases/rust/1 basic/test.json

@ -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')

@ -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
)

@ -1,2 +1,2 @@
e = executable('program2', 'prog.rs', install : true)
e = executable('rust-program2', 'prog.rs', install : true)
test('rusttest2', e)

@ -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"}
]
}

Loading…
Cancel
Save