aboutsummaryrefslogtreecommitdiff
path: root/run_project_tests.py
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2018-10-08 23:15:55 +0100
committerJon Turney <jon.turney@dronecode.org.uk>2018-11-04 15:42:06 +0000
commit3c38e46774bb477c4d3ad26323a1e4b809d97b40 (patch)
tree15a53c80c617ab6c02af8e1da6da51ad0107e3b2 /run_project_tests.py
parente7bed74ae2a96169d512aba826aeb988d580bb15 (diff)
downloadmeson-3c38e46774bb477c4d3ad26323a1e4b809d97b40.zip
meson-3c38e46774bb477c4d3ad26323a1e4b809d97b40.tar.gz
meson-3c38e46774bb477c4d3ad26323a1e4b809d97b40.tar.bz2
Use compiler detector in detect_system_compiler()
Use the compiler detector in detect_system_compiler(), rather than trying to guess based on what it is the PATH (which could utterly fail e.g when CC env var is set) Note that this detection is only used by platform_fix_name() to interpret installed_files.txt
Diffstat (limited to 'run_project_tests.py')
-rwxr-xr-xrun_project_tests.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/run_project_tests.py b/run_project_tests.py
index 2445dd4..c73567e 100755
--- a/run_project_tests.py
+++ b/run_project_tests.py
@@ -132,17 +132,17 @@ def platform_fix_name(fname, compiler, env):
if fname.startswith('?msvc:'):
fname = fname[6:]
- if compiler != 'cl':
+ if compiler != 'msvc':
return None
if fname.startswith('?gcc:'):
fname = fname[5:]
- if compiler == 'cl':
+ if compiler == 'msvc':
return None
if fname.startswith('?cygwin:'):
fname = fname[8:]
- if compiler == 'cl' or not mesonlib.for_cygwin(env.is_cross_build(), env):
+ if compiler == 'msvc' or not mesonlib.for_cygwin(env.is_cross_build(), env):
return None
return fname
@@ -687,14 +687,18 @@ def check_meson_commands_work():
def detect_system_compiler():
global system_compiler
- if shutil.which('cl'):
- system_compiler = 'cl'
- elif shutil.which('cc'):
- system_compiler = 'cc'
- elif shutil.which('gcc'):
- system_compiler = 'gcc'
- else:
- raise RuntimeError("Could not find C compiler.")
+
+ with AutoDeletedDir(tempfile.mkdtemp(prefix='b ', dir='.')) as build_dir:
+ env = environment.Environment(None, build_dir, get_fake_options('/'))
+ try:
+ comp = env.detect_c_compiler(env.is_cross_build())
+ except:
+ raise RuntimeError("Could not find C compiler.")
+ system_compiler = comp.get_id()
+
+ # canonicalize for platform_fix_name()
+ if system_compiler == 'clang-cl':
+ system_compiler = 'msvc'
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Run the test suite of Meson.")