#!/usr/bin/env python
#
#                     The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This script attempts to be a drop-in replacement for gcc.
#
##===----------------------------------------------------------------------===##

import sys
import subprocess

def error(message):
    print 'ccc: ' + message
    sys.exit(1)

def run(args):
    print ' '.join(args)
    code = subprocess.call(args)
    if code:
        sys.exit(code)

def preprocess(args):
    command = 'clang -E'.split()
    run(command + args)

def compile(args):
    command = 'clang -emit-llvm-bc'.split()
    run(command + args)

def link(args):
    command = 'llvm-ld -native'.split()
    run(command + args)

def main(args):
    action = 'link'
    output = ''
    compile_opts = ['-U__GNUC__']
    link_opts = []
    files = []

    i = 0
    while i < len(args):
        arg = args[i]
        if arg == '-E':
            action = 'preprocess'
        if arg == '-c':
            action = 'compile'
        if arg == '-o':
            output = args[i+1]
            i += 1
        if arg[:2] in ['-D', '-I', '-U']:
            if not arg[2:]:
                arg += args[i+1]
                i += 1
            compile_opts.append(arg)
        if arg[:2] in ['-l', '-L', '-O']:
            if arg == '-O': arg = '-O1'
            if arg == '-Os': arg = '-O2'
            link_opts.append(arg)
        if arg[0] != '-':
            files.append(arg)
        i += 1

    if not files:
        error('no input files')

    if action == 'preprocess':
        args = compile_opts + files
        preprocess(args)

    if action == 'compile':
        if not output:
            output = files[0].replace('.c', '.o')
        args = ['-o', output] + compile_opts + files
        compile(args)

    if action == 'link':
        for i, file in enumerate(files):
            if '.c' in file:
                out = file.replace('.c', '.o')
                args = ['-o', out] + compile_opts + [file]
                compile(args)
                files[i] = out
        if not output:
            output = 'a.out'
        args = ['-o', output] + link_opts + files
        link(args)

if __name__ == '__main__':
    main(sys.argv[1:])
