Bug 1262155 - Allow specifying a custom suffix for the test program generated by try_invoke_compiler.
MozReview-Commit-ID: K6tl28r360b
--- 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)