Bug 1264482 - Use the limited string type for the compiler type. r?ted
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -147,19 +147,23 @@ add_old_configure_assignment('TOOLCHAIN_
# Compilers
# ==============================================================
@imports('os')
@imports('subprocess')
@imports(_from='mozbuild.configure.util', _import='LineIO')
@imports(_from='mozbuild.shellutil', _import='quote')
+@imports(_from='mozbuild.util', _import='LimitedString')
@imports(_from='tempfile', _import='mkstemp')
@imports(_from='textwrap', _import='dedent')
def check_compiler(compiler, language):
+ class CompilerType(LimitedString):
+ POSSIBLE_VALUES = ('msvc', 'clang-cl', 'clang', 'gcc')
+
check = dedent('''\
#if defined(_MSC_VER)
#if defined(__clang__)
COMPILER clang-cl _MSC_VER
#else
COMPILER msvc _MSC_FULL_VER
#endif
#elif defined(__clang__)
@@ -191,17 +195,17 @@ def check_compiler(compiler, language):
stderr=subprocess.PIPE)
stdout, stderr = proc.communicate()
retcode = proc.wait()
if retcode == 0:
for line in stdout.splitlines():
if line.startswith('COMPILER '):
_, type, version = line.split(None, 2)
version = version.replace(' ', '')
- return type, version
+ return CompilerType(type), version
return
log.debug('The command returned non-zero exit status %d.', retcode)
for out, desc in ((stdout, 'output'), (stderr, 'error output')):
if out:
log.debug('Its %s was:', desc)
with LineIO(lambda l: log.debug('| %s', l)) as o:
o.write(out)