aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/ast/introspection.py2
-rw-r--r--mesonbuild/compilers/detect.py12
-rw-r--r--mesonbuild/coredata.py1
-rw-r--r--mesonbuild/interpreter/interpreter.py9
-rw-r--r--mesonbuild/modules/java.py2
5 files changed, 14 insertions, 12 deletions
diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py
index 3158aa2..4d6cd0c 100644
--- a/mesonbuild/ast/introspection.py
+++ b/mesonbuild/ast/introspection.py
@@ -181,7 +181,7 @@ class IntrospectionInterpreter(AstInterpreter):
lang = lang.lower()
if lang not in self.coredata.compilers[for_machine]:
try:
- comp = detect_compiler_for(self.environment, lang, for_machine)
+ comp = detect_compiler_for(self.environment, lang, for_machine, True)
except mesonlib.MesonException:
# do we even care about introspecting this language?
if required:
diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
index 1237cac..c6d6ae3 100644
--- a/mesonbuild/compilers/detect.py
+++ b/mesonbuild/compilers/detect.py
@@ -111,11 +111,15 @@ def compiler_from_language(env: 'Environment', lang: str, for_machine: MachineCh
}
return lang_map[lang](env, for_machine) if lang in lang_map else None
-def detect_compiler_for(env: 'Environment', lang: str, for_machine: MachineChoice) -> T.Optional[Compiler]:
+def detect_compiler_for(env: 'Environment', lang: str, for_machine: MachineChoice, skip_sanity_check: bool) -> T.Optional[Compiler]:
comp = compiler_from_language(env, lang, for_machine)
- if comp is not None:
- assert comp.for_machine == for_machine
- env.coredata.process_new_compiler(lang, comp, env)
+ if comp is None:
+ return comp
+ assert comp.for_machine == for_machine
+ env.coredata.process_new_compiler(lang, comp, env)
+ if not skip_sanity_check:
+ comp.sanity_check(env.get_scratch_dir(), env)
+ env.coredata.compilers[comp.for_machine][lang] = comp
return comp
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index 6ce30c9..5365f6d 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -918,7 +918,6 @@ class CoreData:
def process_new_compiler(self, lang: str, comp: 'Compiler', env: 'Environment') -> None:
from . import compilers
- self.compilers[comp.for_machine][lang] = comp
self.add_compiler_options(comp.get_options(), lang, comp.for_machine, env)
enabled_opts: T.List[OptionKey] = []
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index e51910e..2da966c 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -1491,13 +1491,12 @@ class Interpreter(InterpreterBase, HoldableObject):
comp = self.coredata.compilers[for_machine].get(lang)
if not comp:
try:
- comp = compilers.detect_compiler_for(self.environment, lang, for_machine)
+ skip_sanity_check = self.should_skip_sanity_check(for_machine)
+ if skip_sanity_check:
+ mlog.log_once('Cross compiler sanity tests disabled via the cross file.')
+ comp = compilers.detect_compiler_for(self.environment, lang, for_machine, skip_sanity_check)
if comp is None:
raise InvalidArguments(f'Tried to use unknown language "{lang}".')
- if self.should_skip_sanity_check(for_machine):
- mlog.log_once('Cross compiler sanity tests disabled via the cross file.')
- else:
- comp.sanity_check(self.environment.get_scratch_dir(), self.environment)
except mesonlib.MesonException:
if not required:
mlog.log('Compiler for language',
diff --git a/mesonbuild/modules/java.py b/mesonbuild/modules/java.py
index 6861ee0..f6e4484 100644
--- a/mesonbuild/modules/java.py
+++ b/mesonbuild/modules/java.py
@@ -42,7 +42,7 @@ class JavaModule(NewExtensionModule):
def __get_java_compiler(self, state: ModuleState) -> Compiler:
if 'java' not in state.environment.coredata.compilers[MachineChoice.BUILD]:
- detect_compiler_for(state.environment, 'java', MachineChoice.BUILD)
+ detect_compiler_for(state.environment, 'java', MachineChoice.BUILD, False)
return state.environment.coredata.compilers[MachineChoice.BUILD]['java']
@FeatureNew('java.generate_native_headers', '0.62.0')