diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-12-09 12:47:14 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-12-13 09:20:34 +0530 |
commit | 7b3d00fee4bc76e9b6492321572db7ddd6d7f674 (patch) | |
tree | 85fb646e08a8ea9be1a6fde507bb721011047d7c /mesonbuild/backend/ninjabackend.py | |
parent | ec47db6c0c6511d249b6d57fd24ca288e00eb9a3 (diff) | |
download | meson-7b3d00fee4bc76e9b6492321572db7ddd6d7f674.zip meson-7b3d00fee4bc76e9b6492321572db7ddd6d7f674.tar.gz meson-7b3d00fee4bc76e9b6492321572db7ddd6d7f674.tar.bz2 |
Use dict for self.build.compilers instead of list
Everywhere we use this object, we end up iterating over it and comparing
compiler.get_language() with something. Using a dict is the obvious
choice and simplifies a lot of code.
Diffstat (limited to 'mesonbuild/backend/ninjabackend.py')
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index d8dc333..f39f361 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1210,7 +1210,7 @@ int dummy; raise MesonException('Swift supports only executable and static library targets.') def generate_static_link_rules(self, is_cross, outfile): - if self.build.has_language('java'): + if 'java' in self.build.compilers: if not is_cross: self.generate_java_link(outfile) if is_cross: @@ -1251,8 +1251,7 @@ int dummy; else: ctypes.append((self.build.cross_compilers, True)) for (complist, is_cross) in ctypes: - for compiler in complist: - langname = compiler.get_language() + for langname, compiler in complist.items(): if langname == 'java' or langname == 'vala' or\ langname == 'rust' or langname == 'cs': continue @@ -1511,8 +1510,7 @@ rule FORTRAN_DEP_HACK def generate_compile_rules(self, outfile): qstr = quote_char + "%s" + quote_char - for compiler in self.build.compilers: - langname = compiler.get_language() + for langname, compiler in self.build.compilers.items(): if compiler.get_id() == 'clang': self.generate_llvm_ir_compile_rule(compiler, False, outfile) self.generate_compile_rule_for(langname, compiler, qstr, False, outfile) @@ -1524,8 +1522,7 @@ rule FORTRAN_DEP_HACK cclist = self.build.cross_compilers else: cclist = self.build.compilers - for compiler in cclist: - langname = compiler.get_language() + for langname, compiler in cclist.items(): if compiler.get_id() == 'clang': self.generate_llvm_ir_compile_rule(compiler, True, outfile) self.generate_compile_rule_for(langname, compiler, qstr, True, outfile) @@ -1588,8 +1585,8 @@ rule FORTRAN_DEP_HACK def scan_fortran_module_outputs(self, target): compiler = None - for c in self.build.compilers: - if c.get_language() == 'fortran': + for lang, c in self.build.compilers.items(): + if lang == 'fortran': compiler = c break if compiler is None: |