Bug 1292046 - Add language to the compiler namespace. r?chmanchester draft
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 04 Aug 2016 16:24:29 +0900
changeset 397069 f0150c7439f1d22dc3ca8e29d9486f9daca3f1bc
parent 397068 50cdf0e6a41a0f7ed9a10528508dc1a8fd0c8cfe
child 397070 ea9e47974d13414cab70a473f0398c08b7c2f3c7
push id25194
push userbmo:mh+mozilla@glandium.org
push dateFri, 05 Aug 2016 05:27:35 +0000
reviewerschmanchester
bugs1292046
milestone51.0a1
Bug 1292046 - Add language to the compiler namespace. r?chmanchester
build/moz.configure/toolchain.configure
python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -692,16 +692,17 @@ def compiler(language, host_or_target, c
                     'Windows_Build_Prerequisites' % info.version)
 
         return namespace(
             wrapper=wrapper,
             compiler=compiler,
             flags=flags,
             type=info.type,
             version=info.version,
+            language=language,
         )
 
     @depends(valid_compiler)
     @checking('%s version' % what)
     def compiler_version(compiler):
         return compiler.version
 
     if language == 'C++':
--- a/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
+++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
@@ -306,53 +306,60 @@ class LinuxToolchainTest(BaseToolchainTe
     GCC_4_7_RESULT = ('Only GCC 4.8 or newer is supported '
                       '(found version 4.7.3).')
     GXX_4_7_RESULT = GCC_4_7_RESULT
     GCC_4_9_RESULT = CompilerResult(
         flags=['-std=gnu99'],
         version='4.9.3',
         type='gcc',
         compiler='/usr/bin/gcc',
+        language='C',
     )
     GXX_4_9_RESULT = CompilerResult(
         flags=['-std=gnu++11'],
         version='4.9.3',
         type='gcc',
         compiler='/usr/bin/g++',
+        language='C++',
     )
     GCC_5_RESULT = CompilerResult(
         flags=['-std=gnu99'],
         version='5.2.1',
         type='gcc',
         compiler='/usr/bin/gcc-5',
+        language='C',
     )
     GXX_5_RESULT = CompilerResult(
         flags=['-std=gnu++11'],
         version='5.2.1',
         type='gcc',
         compiler='/usr/bin/g++-5',
+        language='C++',
     )
     CLANG_3_3_RESULT = CompilerResult(
         flags=[],
         version='3.3.0',
         type='clang',
         compiler='/usr/bin/clang-3.3',
+        language='C',
     )
     CLANGXX_3_3_RESULT = 'Only clang/llvm 3.6 or newer is supported.'
     CLANG_3_6_RESULT = CompilerResult(
         flags=['-std=gnu99'],
         version='3.6.2',
         type='clang',
         compiler='/usr/bin/clang',
+        language='C',
     )
     CLANGXX_3_6_RESULT = CompilerResult(
         flags=['-std=gnu++11'],
         version='3.6.2',
         type='clang',
         compiler='/usr/bin/clang++',
+        language='C++',
     )
 
     def test_gcc(self):
         # We'll try gcc and clang, and find gcc first.
         self.do_toolchain_test(self.PATHS, {
             'c_compiler': self.GCC_4_9_RESULT,
             'cxx_compiler': self.GXX_4_9_RESULT,
         })
@@ -748,45 +755,55 @@ class WindowsToolchainTest(BaseToolchain
         'This version (19.00.23506) of the MSVC compiler is not supported.\n'
         'You must install Visual C++ 2015 Update 2 or newer in order to build.\n'
         'See https://developer.mozilla.org/en/Windows_Build_Prerequisites')
     VS_2015u2_RESULT = CompilerResult(
         flags=[],
         version='19.00.23918',
         type='msvc',
         compiler='/usr/bin/cl',
+        language='C',
+    )
+    VSXX_2015u2_RESULT = CompilerResult(
+        flags=[],
+        version='19.00.23918',
+        type='msvc',
+        compiler='/usr/bin/cl',
+        language='C++',
     )
     CLANG_CL_3_9_RESULT = CompilerResult(
         flags=['-Xclang', '-std=gnu99',
                '-fms-compatibility-version=18.00.30723', '-fallback'],
         version='18.00.30723',
         type='clang-cl',
         compiler='/usr/bin/clang-cl',
+        language='C',
     )
     CLANGXX_CL_3_9_RESULT = CompilerResult(
         flags=['-fms-compatibility-version=18.00.30723', '-fallback'],
         version='18.00.30723',
         type='clang-cl',
         compiler='/usr/bin/clang-cl',
+        language='C++',
     )
     CLANG_3_3_RESULT = LinuxToolchainTest.CLANG_3_3_RESULT
     CLANGXX_3_3_RESULT = LinuxToolchainTest.CLANGXX_3_3_RESULT
     CLANG_3_6_RESULT = LinuxToolchainTest.CLANG_3_6_RESULT
     CLANGXX_3_6_RESULT = LinuxToolchainTest.CLANGXX_3_6_RESULT
     GCC_4_7_RESULT = LinuxToolchainTest.GCC_4_7_RESULT
     GCC_4_9_RESULT = LinuxToolchainTest.GCC_4_9_RESULT
     GXX_4_9_RESULT = LinuxToolchainTest.GXX_4_9_RESULT
     GCC_5_RESULT = LinuxToolchainTest.GCC_5_RESULT
     GXX_5_RESULT = LinuxToolchainTest.GXX_5_RESULT
 
     # VS2015u2 or greater is required.
     def test_msvc(self):
         self.do_toolchain_test(self.PATHS, {
             'c_compiler': self.VS_2015u2_RESULT,
-            'cxx_compiler': self.VS_2015u2_RESULT,
+            'cxx_compiler': self.VSXX_2015u2_RESULT,
         })
 
     def test_unsupported_msvc(self):
         self.do_toolchain_test(self.PATHS, {
             'c_compiler': self.VS_2015u1_RESULT,
         }, environ={
             'CC': '/opt/VS_2015u1/bin/cl',
         })
--- a/python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py
+++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py
@@ -343,27 +343,28 @@ class CompilerResult(ReadOnlyNamespace):
     '''Helper of convenience to manipulate toolchain results in unit tests
 
     When adding a dict, the result is a new CompilerResult with the values
     from the dict replacing those from the CompilerResult, except for `flags`,
     where the value from the dict extends the `flags` in `self`.
     '''
 
     def __init__(self, wrapper=None, compiler='', version='', type='',
-                 flags=None):
+                 language='', flags=None):
         if flags is None:
             flags = []
         if wrapper is None:
             wrapper = []
         super(CompilerResult, self).__init__(
             flags=flags,
             version=version,
             type=type,
             compiler=mozpath.abspath(compiler),
             wrapper=wrapper,
+            language=language,
         )
 
     def __add__(self, other):
         assert isinstance(other, dict)
         result = copy.deepcopy(self.__dict__)
         for k, v in other.iteritems():
             if k == 'flags':
                 result.setdefault(k, []).extend(v)
@@ -375,52 +376,57 @@ class CompilerResult(ReadOnlyNamespace):
 class TestCompilerResult(unittest.TestCase):
     def test_compiler_result(self):
         result = CompilerResult()
         self.assertEquals(result.__dict__, {
             'wrapper': [],
             'compiler': mozpath.abspath(''),
             'version': '',
             'type': '',
+            'language': '',
             'flags': [],
         })
 
         result = CompilerResult(
             compiler='/usr/bin/gcc',
             version='4.2.1',
             type='gcc',
+            language='C',
             flags=['-std=gnu99'],
         )
         self.assertEquals(result.__dict__, {
             'wrapper': [],
             'compiler': mozpath.abspath('/usr/bin/gcc'),
             'version': '4.2.1',
             'type': 'gcc',
+            'language': 'C',
             'flags': ['-std=gnu99'],
         })
 
         result2 = result + {'flags': ['-m32']}
         self.assertEquals(result2.__dict__, {
             'wrapper': [],
             'compiler': mozpath.abspath('/usr/bin/gcc'),
             'version': '4.2.1',
             'type': 'gcc',
+            'language': 'C',
             'flags': ['-std=gnu99', '-m32'],
         })
         # Original flags are untouched.
         self.assertEquals(result.flags, ['-std=gnu99'])
 
         result3 = result + {
             'compiler': '/usr/bin/gcc-4.7',
             'version': '4.7.3',
             'flags': ['-m32'],
         }
         self.assertEquals(result3.__dict__, {
             'wrapper': [],
             'compiler': mozpath.abspath('/usr/bin/gcc-4.7'),
             'version': '4.7.3',
             'type': 'gcc',
+            'language': 'C',
             'flags': ['-std=gnu99', '-m32'],
         })
 
 
 if __name__ == '__main__':
     main()