diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-09-25 11:25:02 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-09-27 00:27:38 +0530 |
commit | 89753ecc27c9857be2554b1af7fe1f5162b8e761 (patch) | |
tree | 5e71a72d145911080741879dcfaec3405b15a879 /mesonbuild/build.py | |
parent | f85415f0d4617a5f176c4b7f27f04568027184fe (diff) | |
download | meson-89753ecc27c9857be2554b1af7fe1f5162b8e761.zip meson-89753ecc27c9857be2554b1af7fe1f5162b8e761.tar.gz meson-89753ecc27c9857be2554b1af7fe1f5162b8e761.tar.bz2 |
Use per-target compilers while generating targets
This is definitely more correct since it takes into account the
cross-compilation status. We also now do the Java and CSharp sanity
checks on the BuildTarget level instead of in the Ninja backend.
Diffstat (limited to 'mesonbuild/build.py')
-rw-r--r-- | mesonbuild/build.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index b30021f..1ef183b 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -325,15 +325,30 @@ class BuildTarget(): self.compilers[lang] = compiler def validate_sources(self): - if len(self.sources) > 0: + if len(self.sources) == 0: + return + for lang in ('cs', 'java'): + if lang in self.compilers: + check_sources = list(self.sources) + compiler = self.compilers[lang] + if not self.can_compile_remove_sources(compiler, check_sources): + m = 'No {} sources found in target {!r}'.format(lang, self.name) + raise InvalidArguments(m) + if check_sources: + m = '{0} targets can only contain {0} files:\n'.format(lang.capitalize()) + m += '\n'.join([repr(c) for c in check_sources]) + raise InvalidArguments(m) + # 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': - if self.name != base: - raise InvalidArguments('In Rust targets, the first source file must be named projectname.rs.') + 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 |