pass
return default
+CCC_LOG = checkenv('CCC_LOG')
CCC_ECHO = checkbool('CCC_ECHO')
CCC_NATIVE = checkbool('CCC_NATIVE','1')
CCC_FALLBACK = checkbool('CCC_FALLBACK')
command = [CLANG,'-E']
run(command + args)
+def syntaxonly(args):
+ command = [CLANG,'-fsyntax-only']
+ run(command + args)
+
def compile_fallback(args):
command = [CC,'-c']
run(command + args)
def checked_compile(args, native, language, save_temps):
if CCC_LANGUAGES and language and language not in CCC_LANGUAGES:
+ log('fallback', args)
print >>sys.stderr, 'NOTE: ccc: Using fallback compiler for: %s'%(' '.join(map(quote, args)),)
compile_fallback(args)
elif CCC_FALLBACK:
try:
compile(args, native, save_temps)
except:
+ log('fallback-on-fail', args)
print >>sys.stderr, 'WARNING: ccc: Using fallback compiler for: %s'%(' '.join(map(quote, args)),)
compile_fallback(args)
else:
else:
return ""
+def log(name, item):
+ if CCC_LOG:
+ f = open(CCC_LOG,'a')
+ print >>f, (name, item)
+ f.close()
+
def inferaction(args):
if '-E' in args:
return 'preprocess'
+ if '-fsyntax-only' in args:
+ return 'syntax-only'
if '-c' in args:
return 'compile'
for arg in args:
return 'link'
def main(args):
+ log('invoke', args)
+
action = inferaction(args)
output = ''
compile_opts = []
i += 1
# Options with no arguments that should pass through
- if (arg in ('-dynamiclib', '-bundle', '-headerpad_max_install_names') or
+ if (arg in ('-dynamiclib', '-bundle', '-headerpad_max_install_names',
+ '-nostdlib', '-static', '-dynamic', '-r') or
arg.startswith('-Wl,')):
link_opts.append(arg)
# Discard the explicit language after used once
language = ''
+ if action == 'syntax-only':
+ for i, file in enumerate(files):
+ if not language:
+ language = inferlanguage(extension(file))
+ args = []
+ if language:
+ args.extend(['-x', language])
+ args += [file] + compile_opts
+ syntaxonly(args)
+ language = ''
+
if action == 'compile' or save_temps:
for i, file in enumerate(files):
if not language: