diff options
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 15 | ||||
-rw-r--r-- | mesonbuild/build.py | 23 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 12 | ||||
-rw-r--r-- | mesonbuild/modules/gnome.py | 10 | ||||
-rw-r--r-- | mesonbuild/modules/rpm.py | 2 | ||||
-rw-r--r-- | mesonbuild/modules/windows.py | 6 |
6 files changed, 28 insertions, 40 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: diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 79759ee..50436d4 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -88,8 +88,8 @@ class Build: self.environment = environment self.projects = {} self.targets = {} - self.compilers = [] - self.cross_compilers = [] + self.compilers = {} + self.cross_compilers = {} self.global_args = {} self.projects_args = {} self.global_link_args = {} @@ -109,26 +109,19 @@ class Build: self.dep_manifest = {} self.cross_stdlibs = {} - def has_language(self, language): - for i in self.compilers: - if i.get_language() == language: - return True - return False - def add_compiler(self, compiler): if self.static_linker is None and compiler.needs_static_linker(): self.static_linker = self.environment.detect_static_linker(compiler) - if self.has_language(compiler.get_language()): - return - self.compilers.append(compiler) + lang = compiler.get_language() + if lang not in self.compilers: + self.compilers[lang] = compiler def add_cross_compiler(self, compiler): if len(self.cross_compilers) == 0: self.static_cross_linker = self.environment.detect_static_linker(compiler) - for i in self.cross_compilers: - if i.get_language() == compiler.get_language(): - return - self.cross_compilers.append(compiler) + lang = compiler.get_language() + if lang not in self.cross_compilers: + self.cross_compilers[lang] = compiler def get_project(self): return self.projects[''] diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 47b8ae6..4a5436b 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1074,9 +1074,8 @@ class MesonMain(InterpreterObject): clist = self.build.compilers else: clist = self.build.cross_compilers - for c in clist: - if c.get_language() == cname: - return CompilerHolder(c, self.build.environment) + if cname in clist: + return CompilerHolder(clist[cname], self.build.environment) raise InterpreterException('Tried to access compiler for unspecified language "%s".' % cname) def is_unity_method(self, args, kwargs): @@ -1254,8 +1253,7 @@ class Interpreter(InterpreterBase): def check_cross_stdlibs(self): if self.build.environment.is_cross_build(): cross_info = self.build.environment.cross_info - for c in self.build.cross_compilers: - l = c.language + for l, c in self.build.cross_compilers.items(): try: di = mesonlib.stringlistify(cross_info.get_stdlib(l)) if len(di) != 2: @@ -2287,9 +2285,9 @@ requirements use the version keyword argument instead.''') def get_used_languages(self, target): result = {} for i in target.sources: - for c in self.build.compilers: + for lang, c in self.build.compilers.items(): if c.can_compile(i): - result[c.language] = True + result[lang] = True break return result diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 1912fc1..6d05b4e 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -433,11 +433,11 @@ can not be used with the current version of glib-compiled-resources, due to cflags += state.global_args['c'] if state.project_args.get('c'): cflags += state.project_args['c'] - for compiler in state.compilers: - if compiler.get_language() == 'c': - sanitize = compiler.get_options().get('b_sanitize') - if sanitize: - cflags += compilers.sanitizer_compile_args(sanitize) + if 'c' in state.compilers: + compiler = state.compilers['c'] + sanitize = compiler.get_options().get('b_sanitize') + if sanitize: + cflags += compilers.sanitizer_compile_args(sanitize) if cflags: scan_command += ['--cflags-begin'] scan_command += cflags diff --git a/mesonbuild/modules/rpm.py b/mesonbuild/modules/rpm.py index 2c9ed57..dca1ad6 100644 --- a/mesonbuild/modules/rpm.py +++ b/mesonbuild/modules/rpm.py @@ -27,7 +27,7 @@ class RPMModule: def generate_spec_template(self, state, args, kwargs): compiler_deps = set() - for compiler in state.compilers: + for compiler in state.compilers.values(): if isinstance(compiler, compilers.GnuCCompiler): compiler_deps.add('gcc') elif isinstance(compiler, compilers.GnuCPPCompiler): diff --git a/mesonbuild/modules/windows.py b/mesonbuild/modules/windows.py index cd4e343..ad882cb 100644 --- a/mesonbuild/modules/windows.py +++ b/mesonbuild/modules/windows.py @@ -19,9 +19,9 @@ import os class WindowsModule: def detect_compiler(self, compilers): - for c in compilers: - if c.language == 'c' or c.language == 'cpp': - return c + for l in ('c', 'cpp'): + if l in compilers: + return compilers[l] raise MesonException('Resource compilation requires a C or C++ compiler.') def compile_resources(self, state, args, kwargs): |