コード例 #1
0
ファイル: compile_lcc.py プロジェクト: vpoulailleau/ppci
def do_compile(filename, include_paths, arch, reporter):
    coptions = COptions()
    coptions.add_include_paths(include_paths)
    coptions.add_define("FPM_DEFAULT", "1")
    with open(filename, "r") as f:
        obj = cc(f, arch, coptions=coptions, reporter=reporter)
    return obj
コード例 #2
0
def do_compile(filename):
    coptions = COptions()
    include_paths = [
        libc_includes,
        src_folder,
    ]
    coptions.add_include_paths(include_paths)
    with open(filename, 'r') as f:
        obj = cc(f, arch, coptions=coptions)
    return obj
コード例 #3
0
def do_compile(filename):
    include_paths = [
        os.path.join(newlib_folder, 'libc', 'include'),
        libc_includes,
    ]
    coptions = COptions()
    coptions.add_include_paths(include_paths)
    coptions.add_define('HAVE_CONFIG_H')
    coptions.add_define('__MSP430__')
    with open(filename, 'r') as f:
        obj = cc(f, arch, coptions=coptions)
    return obj
コード例 #4
0
def do_compile(filename):
    include_paths = [
        os.path.join(musl_folder, 'include'),
        os.path.join(musl_folder, 'src', 'internal'),
        os.path.join(musl_folder, 'obj', 'include'),
        os.path.join(musl_folder, 'arch', 'x86_64'),
        os.path.join(musl_folder, 'arch', 'generic'),
    ]
    coptions = COptions()
    coptions.add_include_paths(include_paths)
    with open(filename, 'r') as f:
        obj = cc(f, 'x86_64', coptions=coptions)
    return obj
コード例 #5
0
ファイル: benchmark.py プロジェクト: ttwj/ppci
def compile_8cc():
    """ Compile the 8cc compiler.

    8cc homepage:
    https://github.com/rui314/8cc
    """

    home = os.environ['HOME']
    _8cc_folder = os.path.join(home, 'GIT', '8cc')
    libc_includes = os.path.join(this_dir, '..', 'librt', 'libc', 'include')
    linux_include_dir = '/usr/include'
    arch = api.get_arch('x86_64')
    coptions = COptions()
    include_paths = [
        libc_includes,
        _8cc_folder,
        linux_include_dir,
    ]
    coptions.add_include_paths(include_paths)
    coptions.add_define('BUILD_DIR', '"{}"'.format(_8cc_folder))

    sources = [
        'cpp.c',
        'debug.c',
        'dict.c',
        'gen.c',
        'lex.c',
        'vector.c',
        'parse.c',
        'buffer.c',
        'map.c',
        'error.c',
        'path.c',
        'file.c',
        'set.c',
        'encoding.c',
    ]
    objs = []
    for filename in sources:
        source_path = os.path.join(_8cc_folder, filename)
        with open(source_path, 'r') as f:
            objs.append(api.cc(f, arch, coptions=coptions))
コード例 #6
0
def main():
    t1 = time.time()
    failed = 0
    passed = 0
    include_paths = [
        # os.path.join(newlib_folder, 'libc', 'include'),
        # TODO: not sure about the include path below for stddef.h:
        # '/usr/lib/gcc/x86_64-pc-linux-gnu/7.1.1/include'
        libc_includes,
        micropython_folder,
        port_folder,
    ]
    coptions = COptions()
    coptions.add_include_paths(include_paths)
    coptions.enable('freestanding')
    coptions.add_define('NO_QSTR', '1')
    file_pattern = os.path.join(micropython_folder, 'py', '*.c')
    objs = []
    for filename in glob.iglob(file_pattern):
        print('==> Compiling', filename)
        try:
            obj = do_compile(filename, coptions)
        except CompilerError as ex:
            print('Error:', ex.msg, ex.loc)
            ex.print()
            print_exc()
            failed += 1
            # break
        except Exception as ex:
            print('General exception:', ex)
            print_exc()
            failed += 1
            # break
        else:
            print('Great success!', obj)
            passed += 1
            objs.append(obj)

    t2 = time.time()
    elapsed = t2 - t1
    print('Passed:', passed, 'failed:', failed, 'in', elapsed, 'seconds')
コード例 #7
0
ファイル: compile_links.py プロジェクト: vpoulailleau/ppci
def main():
    t1 = time.time()
    failed = 0
    passed = 0
    sources = glob.iglob(os.path.join(links_folder, '*.c'))
    objs = []
    coptions = COptions()
    include_paths = [
        libc_includes,
        links_folder,
        '/usr/include',
        ]
    coptions.add_include_paths(include_paths)
    with open(report_filename, 'w') as f, HtmlReportGenerator(f) as reporter:
        for filename in sources:
            filename = os.path.join(links_folder, filename)
            print('      ======================')
            print('    ========================')
            print('  ==> Compiling', filename)
            try:
                obj = do_compile(filename, coptions, reporter)
                objs.append(obj)
            except CompilerError as ex:
                print('Error:', ex.msg, ex.loc)
                ex.print()
                print_exc()
                failed += 1
            except Exception as ex:
                print('General exception:', ex)
                print_exc()
                failed += 1
            else:
                print('Great success!')
                passed += 1

    t2 = time.time()
    elapsed = t2 - t1
    print('Passed:', passed, 'failed:', failed, 'in', elapsed, 'seconds')
    obj = link(objs)
    print(obj)
コード例 #8
0
ファイル: compile_8cc.py プロジェクト: ttwj/ppci
home = os.environ['HOME']
_8cc_folder = os.path.join(home, 'GIT', '8cc')
this_dir = os.path.abspath(os.path.dirname(__file__))
report_filename = os.path.join(this_dir, 'report_8cc.html')
libc_folder = os.path.join(this_dir, '..', 'librt', 'libc')
libc_includes = os.path.join(libc_folder, 'include')
linux_include_dir = '/usr/include'
arch = 'x86_64'
coptions = COptions()
include_paths = [
    libc_includes,
    _8cc_folder,
    linux_include_dir,
]
coptions.add_include_paths(include_paths)
coptions.add_define('BUILD_DIR', '"{}"'.format(_8cc_folder))


def do_compile(filename, reporter):
    with open(filename, 'r') as f:
        obj = api.cc(f, arch, coptions=coptions, reporter=reporter)
    print(filename, 'compiled into', obj)
    return obj


def main():
    t1 = time.time()
    failed = 0
    passed = 0
    sources = [