Bug 1262155 - Allow specifying a custom suffix for the test program generated by try_invoke_compiler. draft
authorChris Manchester <cmanchester@mozilla.com>
Wed, 24 Aug 2016 14:43:17 -0700
changeset 405143 7530b6c23256b9fcb5f1130368d4e241eebf3bce
parent 405142 2289fdf8067f9201a02f70728a7e4a85edbc6698
child 405144 64775de51fa0474dc5ef56035f8d89b2d81939e7
push id27409
push usercmanchester@mozilla.com
push dateWed, 24 Aug 2016 22:28:07 +0000
bugs1262155
milestone51.0a1
Bug 1262155 - Allow specifying a custom suffix for the test program generated by try_invoke_compiler. MozReview-Commit-ID: K6tl28r360b
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)