aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend/ninjabackend.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2018-06-05 00:53:08 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2018-06-17 15:39:59 +0300
commitcd63ca9c194c328e9a05b1c81898657c3acfe498 (patch)
tree1fa1198323c28cf2fc15f84fe34c427df62e582c /mesonbuild/backend/ninjabackend.py
parentc5cb65eb7c876dee64df5e516953b839afe273f7 (diff)
downloadmeson-cd63ca9c194c328e9a05b1c81898657c3acfe498.zip
meson-cd63ca9c194c328e9a05b1c81898657c3acfe498.tar.gz
meson-cd63ca9c194c328e9a05b1c81898657c3acfe498.tar.bz2
Support Rust targets with more than one source file. Closes #3632.
Diffstat (limited to 'mesonbuild/backend/ninjabackend.py')
-rw-r--r--mesonbuild/backend/ninjabackend.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 401ad19..a773439 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1258,11 +1258,17 @@ int dummy;
def generate_rust_target(self, target, outfile):
rustc = target.compilers['rust']
- relsrc = []
+ # Rust compiler takes only the main file as input and
+ # figures out what other files are needed via import
+ # statements and magic.
+ main_rust_file = None
for i in target.get_sources():
if not rustc.can_compile(i):
raise InvalidArguments('Rust target %s contains a non-rust source file.' % target.get_basename())
- relsrc.append(i.rel_to_builddir(self.build_to_src))
+ if main_rust_file is None:
+ main_rust_file = i.rel_to_builddir(self.build_to_src)
+ if main_rust_file is None:
+ raise RuntimeError('A Rust target has no Rust sources. This is weird. Also a bug. Please report')
target_name = os.path.join(target.subdir, target.get_filename())
args = ['--crate-type']
if isinstance(target, build.Executable):
@@ -1329,7 +1335,7 @@ int dummy;
if target.is_cross:
crstr = '_CROSS'
compiler_name = 'rust%s_COMPILER' % crstr
- element = NinjaBuildElement(self.all_outputs, target_name, compiler_name, relsrc)
+ element = NinjaBuildElement(self.all_outputs, target_name, compiler_name, main_rust_file)
if len(orderdeps) > 0:
element.add_orderdep(orderdeps)
element.add_item('ARGS', args)