示例#1
0
def find_compiler(c):
    w = Wandbox()
    r = w.get_compiler_list()
    for d in r:
        if d['language'] == 'C++' and d['name'] == c:
            return True
    return False
示例#2
0
def listup_compiler(verbose):
    w = Wandbox()
    r = w.get_compiler_list()
    for d in r:
        if d['language'] == 'C++':
            if verbose:
                print(d['name'] + ' (' + d['version'] + ')')
            else:
                print(d['name'])
示例#3
0
def get_permlink(options):
    w = Wandbox()
    r = w.get_permlink(options.permlink)
    p = r['parameter']
    show_parameter(p)
    print('result:')
    b = show_result(r['result'], options)
    if options.output:
        f = open(options.output, 'w')
        f.write(p['code'])
        f.close()
    sys.exit(b)
示例#4
0
def get_default_options(compiler):
    w = Wandbox()
    r = w.get_compiler_list()
    opt = []
    for d in r:
        if d['name'] == compiler:
            if 'switches' in d:
                switches = d['switches']
                for s in switches:
                    if 'name' in s:
                        if s['default']:
                            opt.append(s['name'])
                    elif 'options' in s:
                        opt.append(s['default'])
    return opt
示例#5
0
def listup_options(compiler):
    w = Wandbox()
    r = w.get_compiler_list()
    for d in r:
        if d['name'] == compiler:
            if 'switches' in d:
                switches = d['switches']
                for s in switches:
                    if 'name' in s:
                        if s['default']:
                            print(s['name'] + ' (default)')
                        else:
                            print(s['name'])
                    elif 'options' in s:
                        print(s['default'] + ' (default)')
                        for o in s['options']:
                            print('  ' + o['name'])
示例#6
0
文件: iuwandbox.py 项目: tei-k/iutest
def get_permlink(options):
    r = Wandbox.GetPermlink(options.permlink)
    p = r['parameter']
    show_parameter(p)
    print('result:')
    b = show_result(r['result'], options)
    if options.output:
        f = open(options.output, 'w')
        f.write(p['code'])
        f.close()
    sys.exit(b)
示例#7
0
文件: iuwandbox.py 项目: dsyoi/iutest
def run_wandbox_make(main_filepath, code, includes, implements, options):
    with Wandbox() as w:
        w.compiler('bash')
        woptions = create_option_list(options)
        if options.stdin:
            w.stdin(options.stdin)
        implements[os.path.basename(main_filepath)] = code

        colist = create_compiler_raw_option_list(options)
        colist.extend(expand_wandbox_options(w, options.compiler, woptions))

        rolist = []
        if options.runtime_option_raw:
            for opt in options.runtime_option_raw:
                rolist.extend(opt.split())

        makefile = '#!/bin/make\n# generate makefile by iuwandbox.py\n'
        cxx = get_compiler_exec(options.compiler)
        if cxx is None:
            print('failed: invalid compiler...')
            sys.exit(1)
        makefile += '\nCXX=/opt/wandbox/' + options.compiler + '/bin/' + cxx
        makefile += '\nCXXFLAGS+='
        for opt in colist:
            makefile += opt + ' '
        makefile += '\nOBJS='
        for filename in implements.keys():
            makefile += os.path.splitext(filename)[0] + '.o '

        makefile += '\n\
prog: $(OBJS)\n\
\t$(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS)\n\
'

        implements['Makefile'] = makefile

        bashscript = 'make -j 4\n'
        bashscript += './prog '
        for opt in rolist:
            bashscript += opt + ' '
        bashscript += '\n'
        w.code(bashscript)

        if options.save:
            w.permanent_link(options.save)
        if options.verbose:
            w.dump()
        add_files(w, implements)
        add_files(w, includes)

        return run_wandbox_impl(w, options)
示例#8
0
文件: iuwandbox.py 项目: dsyoi/iutest
def run_wandbox_cxx(code, includes, implements, options):
    with Wandbox() as w:
        w.compiler(options.compiler)
        woptions = ','.join(create_option_list(options))
        w.options(woptions)
        if options.stdin:
            w.stdin(options.stdin)
        colist = create_compiler_raw_option_list(options)

        if workaround:
            if options.compiler in ['clang-3.2']:
                colist.append('-ftemplate-depth=1024')
    #        if options.compiler in ['clang-3.4']:
    #            colist.append('-DIUTEST_HAS_HDR_CXXABI=0')
    #        if options.compiler in ['clang-3.3', 'clang-3.2', 'clang-3.1', 'clang-3.0']:
    #            colist.append('-Qunused-arguments')
            if 'boost-nothing' in woptions:
                if options.compiler in ['clang-3.4', 'clang-3.3']:
                    colist.append('-fno-exceptions')
                    colist.append('-fno-rtti')
            # if 'gcc' in options.compiler:
            #     colist.append('-flarge-source-files')
        if colist:
            co = '\n'.join(colist)
            co = co.replace('\\n', '\n')
            w.compiler_options(co)
        if options.runtime_option_raw:
            rolist = []
            for opt in options.runtime_option_raw:
                rolist.extend(opt.split())
            ro = '\n'.join(rolist)
            ro = ro.replace('\\n', '\n')
            w.runtime_options(ro)
        if options.save:
            w.permanent_link(options.save)
        for filename in implements.keys():
            w.add_compiler_options(filename)
        if options.verbose:
            w.dump()
        w.code(code)
        add_files(w, implements)
        add_files(w, includes)

        return run_wandbox_impl(w, options)
示例#9
0
def run_wandbox(code, includes, impliments, options):
    w = Wandbox()
    w.compiler(options.compiler)
    opt = []
    if options.options:
        opt = options.options.split(',')
    elif options.default:
        opt = get_default_options(options.compiler)
    if options.boost:
        opt = list(filter(lambda s: s.find('boost') == -1, opt))
        opt.append('boost-' + str(options.boost))
    if options.sprout and 'sprout' not in opt:
        opt.append('sprout')
    if options.msgpack and 'msgpack' not in opt:
        opt.append('msgpack')
    w.options(','.join(opt))
    if options.stdin:
        w.stdin(options.stdin)
    if options.compiler_option_raw:
        co = '\n'.join(options.compiler_option_raw)
        co = co.replace('\\n', '\n')
        if options.compiler == "clang-3.5":
            co += "\n-DIUTEST_HAS_HDR_CXXABI=0"
        if options.compiler in ["clang-3.2", "clang-3.1", "clang-3.0"]:
            co += "\n-Qunused-arguments"
        w.compiler_options(co)
    if options.runtime_option_raw:
        ro = ''
        for opt in options.runtime_option_raw:
            ro += opt + '\n'
        ro = ro.replace('\\n', '\n')
        w.runtime_options(ro)
    if options.save:
        w.permanent_link(options.save)
    for filename in impliments.keys():
        w.add_compiler_options(filename)
    if options.verbose:
        w.dump()
    w.code(code)
    add_files(w, impliments)
    add_files(w, includes)
    if options.dryrun:
        sys.exit(0)

    def run(retries):
        try:
            return w.run()
        except HTTPError as e:
            if e.response.status_code == 504 and retries > 0:
                try:
                    print(e.message)
                except:
                    pass
                print("wait 30sec...")
                sleep(30)
                return run(retries - 1)
            else:
                raise
        except:
            raise
    return run(3)
示例#10
0
文件: iuwandbox.py 项目: dsyoi/iutest
def wandbox_api_call(callback, retries, retry_wait):
    return Wandbox.Call(callback, retries, retry_wait)
示例#11
0
#!/usr/bin/env python
#
# wandbox-listup-compiler.py
#

import json

from wandbox import Wandbox

if __name__ == '__main__':
    w = Wandbox()
    r = w.get_compiler_list()
    for d in r:
        print('{0}: {1}'.format(d['language'], d['name']))