rust: Support executable name differing from source name

pull/1541/head
Patrick Griffis 8 years ago committed by Jussi Pakkanen
parent 65377ff16a
commit 9929e0efac
  1. 6
      mesonbuild/backend/ninjabackend.py
  2. 8
      mesonbuild/build.py
  3. 3
      test cases/rust/1 basic/installed_files.txt
  4. 4
      test cases/rust/1 basic/meson.build
  5. 2
      test cases/rust/1 basic/subdir/meson.build
  6. 3
      test cases/rust/1 basic/subdir/prog.rs

@ -1089,9 +1089,9 @@ int dummy;
raise InvalidArguments('Unknown target type for rustc.')
args.append(cratetype)
args += rustc.get_buildtype_args(self.environment.coredata.get_builtin_option('buildtype'))
depfile = target.name + '.d'
args += ['--out-dir', target.subdir]
args += ['--emit', 'dep-info', '--emit', 'link']
depfile = os.path.join(target.subdir, target.name + '.d')
args += ['--emit', 'dep-info={}'.format(depfile), '--emit', 'link']
args += ['-o', os.path.join(target.subdir, target.get_filename())]
orderdeps = [os.path.join(t.subdir, t.get_filename()) for t in target.link_targets]
linkdirs = OrderedDict()
for d in target.link_targets:

@ -479,14 +479,6 @@ class BuildTarget(Target):
# CSharp and Java targets can't contain any other file types
assert(len(self.compilers) == 1)
return
if 'rust' in self.compilers:
firstname = self.sources[0]
if isinstance(firstname, File):
firstname = firstname.fname
first = os.path.split(firstname)[1]
(base, suffix) = os.path.splitext(first)
if suffix != '.rs' or self.name != base:
raise InvalidArguments('In Rust targets, the first source file must be named projectname.rs.')
def get_original_kwargs(self):
return self.kwargs

@ -1 +1,2 @@
usr/bin/prog?exe
usr/bin/program?exe
usr/bin/program2?exe

@ -1,4 +1,6 @@
project('rustprog', 'rust')
e = executable('prog', 'prog.rs', install : true)
e = executable('program', 'prog.rs', install : true)
test('rusttest', e)
subdir('subdir')

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

@ -0,0 +1,3 @@
fn main() {
println!("rust compiler is working");
}
Loading…
Cancel
Save