Bug 1262155 - Allow specifying a custom suffix for the test program generated by try_invoke_compiler. draft
authorChris Manchester <cmanchester@mozilla.com>
Tue, 23 Aug 2016 16:37:21 -0700
changeset 404745 e7abd002e1ea543d77310d463e173d7c6c7a85e8
parent 404744 6d641a92b2957b599f9ba440517832325abe195a
child 404746 6bcb4022e34619776392cc105ccf5f37e4648efa
push id27280
push userbmo:cmanchester@mozilla.com
push dateTue, 23 Aug 2016 23:37:43 +0000
bugs1262155
milestone51.0a1
Bug 1262155 - Allow specifying a custom suffix for the test program generated by try_invoke_compiler. MozReview-Commit-ID: 6OAyg6b6kPB
build/moz.configure/util.configure
--- a/build/moz.configure/util.configure
+++ b/build/moz.configure/util.configure
@@ -153,27 +153,29 @@ def find_program(file, paths=None):
     except WhichError:
         return None
 
 
 @imports('os')
 @imports('subprocess')
 @imports(_from='mozbuild.configure.util', _import='LineIO')
 @imports(_from='tempfile', _import='mkstemp')
-def try_invoke_compiler(compiler, language, source, flags=None, onerror=None):
+def try_invoke_compiler(compiler, language, source, flags=None, onerror=None,
+                        suffix=None):
     flags = flags or []
 
     if not isinstance(flags, (list, tuple)):
         die("Flags provided to try_compile must be a list of strings, "
             "not %r", paths)
 
-    suffix = {
-        'C': '.c',
-        'C++': '.cpp',
-    }[language]
+    if not suffix:
+        suffix = {
+            'C': '.c',
+            'C++': '.cpp',
+        }[language]
 
     fd, path = mkstemp(prefix='conftest.', suffix=suffix)
     try:
         source = source.encode('ascii', 'replace')
 
         log.debug('Creating `%s` with content:', path)
         with LineIO(lambda l: log.debug('| %s', l)) as out:
             out.write(source)