Bug 1264482 - Use the limited string type for the compiler type. r?ted draft
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 06 Apr 2016 09:35:58 +0900
changeset 350673 162b86a8401fc39261fee10b46955926a61bd539
parent 350672 7cd796912c3a6f73b2ec176ee44e7ab68f6ddcdd
child 350674 31d971391da2345d77a794d6a45f5df8ea5fd6dc
push id15385
push userbmo:mh+mozilla@glandium.org
push dateThu, 14 Apr 2016 04:41:28 +0000
reviewersted
bugs1264482
milestone48.0a1
Bug 1264482 - Use the limited string type for the compiler type. r?ted
build/moz.configure/toolchain.configure
--- 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)