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:25:13 -0700
changeset 404736 9013f6ac4595d20e8b558f1d6e9010148bf5f5f4
parent 404735 2445569565c73315c6d300de9cd86294604092ba
child 404737 0d87531a53e606303e42a0a20126a876edc7fd7f
push id27277
push userbmo:cmanchester@mozilla.com
push dateTue, 23 Aug 2016 23:29:10 +0000
bugs1262155
milestone51.0a1
Bug 1262155 - Allow specifying a custom suffix for the test program generated by try_invoke_compiler. MozReview-Commit-ID: 78I4Yvg3HmD
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)