示例#1
0
文件: pyext.py 项目: Web5design/Bento
def _detect_cc_type(ctx, cc_cmd):
    cc_type = None

    def detect_type(vflag):
        cmd = cc_cmd + [vflag]
        env = os.environ
        env["LC_ALL"] = env["LANGUAGE"] = "C"
        p = Popen(cmd, stdout=PIPE, stderr=STDOUT, env=env)
        out = p.communicate()[0].decode()
        for k, v in CC_SIGNATURE.items():
            m = v.search(out)
            if m:
                return k
        return None

    _OUTPUT.write("Detecting CC type... ")
    if sys.platform == "win32":
        for v in ["", "-v"]:
            cc_type = detect_type(v)
    else:
        try:
            for v in ["-v", "-V", "-###"]:
                cc_type = detect_type(v)
                if cc_type:
                    break
            if cc_type is None:
                cc_type = "cc"
        except OSError:
            e = extract_exception()
            if e.errno == errno.ENOENT:
                raise ValueError("compiler %r not found" % " ".join(cc_cmd))
            else:
                raise ValueError("Unexpected error %r when testing compiler %r" % (e, cc_cmd))
    _OUTPUT.write("%s\n" % cc_type)
    return cc_type
示例#2
0
文件: pyext.py 项目: pberkes/Bento
def _detect_cc_type(ctx, cc_cmd):
    cc_type = None

    def detect_type(vflag):
        cmd = cc_cmd + [vflag]
        try:
            p = Popen(cmd, stdout=PIPE, stderr=STDOUT)
            out = p.communicate()[0].decode()
            for k, v in CC_SIGNATURE.items():
                m = v.search(out)
                if m:
                    return k
        except OSError:
            pass
        return None

    _OUTPUT.write("Detecting CC type... ")
    if sys.platform == "win32":
        for v in ["", "-v"]:
            cc_type = detect_type(v)
    else:
        for v in ["-v", "-V", "-###"]:
            cc_type = detect_type(v)
            if cc_type:
                break
        if cc_type is None:
            cc_type = "cc"
    _OUTPUT.write("%s\n" % cc_type)
    return cc_type
示例#3
0
文件: pyext.py 项目: pberkes/Bento
def get_distutils_cc_exec(ctx, compiler_type="default"):
    from distutils import ccompiler

    _OUTPUT.write("Detecting distutils CC exec ... ")
    if compiler_type == "default":
        compiler_type = distutils.ccompiler.get_default_compiler()

    compiler = ccompiler.new_compiler(compiler=compiler_type)
    if compiler_type == "msvc":
        compiler.initialize()
        cc = [compiler.cc]
    else:
        cc = compiler.compiler_so
    _OUTPUT.write("%s\n" % " ".join(cc))
    return cc
示例#4
0
文件: pyext.py 项目: Web5design/Bento
def get_distutils_cxx_exec(ctx, compiler_type="default"):
    from distutils import ccompiler
    from distutils.sysconfig import customize_compiler

    _OUTPUT.write("Detecting distutils CXX exec ... ")
    if compiler_type == "default":
        compiler_type = \
                distutils.ccompiler.get_default_compiler()

    compiler = ccompiler.new_compiler(compiler=compiler_type)
    if compiler_type == "msvc":
        compiler.initialize()
        cc = [compiler.cc]
    else:
        customize_compiler(compiler)
        cc = compiler.compiler_cxx
    _OUTPUT.write("%s\n" % " ".join(cc))
    return cc
示例#5
0
def get_distutils_cxx_exec(ctx, compiler_type="default"):
    from distutils import ccompiler
    from distutils.sysconfig import customize_compiler

    _OUTPUT.write("Detecting distutils CXX exec ... ")
    if compiler_type == "default":
        compiler_type = \
                distutils.ccompiler.get_default_compiler()

    compiler = ccompiler.new_compiler(compiler=compiler_type)
    if compiler_type == "msvc":
        compiler.initialize()
        cc = [compiler.cc]
    else:
        customize_compiler(compiler)
        cc = compiler.compiler_cxx
    _OUTPUT.write("%s\n" % " ".join(cc))
    return cc
示例#6
0
def _detect_cc_type(ctx, cc_cmd):
    cc_type = None

    def detect_type(vflag):
        cmd = cc_cmd + [vflag]
        env = os.environ
        env["LC_ALL"] = env["LANGUAGE"] = "C"
        p = Popen(cmd, stdout=PIPE, stderr=STDOUT, env=env)
        out = p.communicate()[0].decode()
        for k, v in list(CC_SIGNATURE.items()):
            m = v.search(out)
            if m:
                return k
        return None

    _OUTPUT.write("Detecting CC type... ")
    if sys.platform == "win32":
        for v in ["", "-v"]:
            cc_type = detect_type(v)
    else:
        try:
            for v in ["-v", "-V", "-###"]:
                cc_type = detect_type(v)
                if cc_type:
                    break
            if cc_type is None:
                cc_type = "cc"
        except OSError:
            e = extract_exception()
            if e.errno == errno.ENOENT:
                raise ValueError("compiler %r not found" % " ".join(cc_cmd))
            else:
                raise ValueError(
                    "Unexpected error %r when testing compiler %r" %
                    (e, cc_cmd))
    _OUTPUT.write("%s\n" % cc_type)
    return cc_type
 def _detect_cc():
     detected = None
     sys.path.insert(0, os.path.dirname(yaku.tools.__file__))
     try:
         for cc_type in candidates:
             _OUTPUT.write("Looking for %s (c compiler) ... " % cc_type)
             try:
                 mod = __import__(cc_type)
                 if mod.detect(ctx):
                     _OUTPUT.write("yes\n")
                     ctx.env["cc_type"] = cc_type
                     detected = cc_type
                     break
             except:
                 pass
             _OUTPUT.write("no!\n")
         return detected
     finally:
         sys.path.pop(0)
示例#8
0
文件: ctasks.py 项目: B-Rich/Bento
 def _detect_cc():
     detected = None
     sys.path.insert(0, os.path.dirname(yaku.tools.__file__))
     try:
         for cc_type in candidates:
             _OUTPUT.write("Looking for %s (c compiler) ... " % cc_type)
             try:
                 mod = __import__(cc_type)
                 if mod.detect(ctx):
                     _OUTPUT.write("yes\n")
                     ctx.env["cc_type"] = cc_type
                     detected = cc_type
                     break
             except:
                 pass
             _OUTPUT.write("no!\n")
         return detected
     finally:
         sys.path.pop(0)
示例#9
0
文件: pprint.py 项目: B-Rich/Bento
def pprint(color, str):
    _OUTPUT.write('%s%s%s\n' % (COLORS(color), str, COLORS('NORMAL')))
示例#10
0
文件: context.py 项目: abadger/Bento
 def end_message(self, msg):
     _OUTPUT.write("%s\n" % msg)
示例#11
0
文件: context.py 项目: abadger/Bento
 def start_message(self, msg):
     _OUTPUT.write(msg + "... ")
     self.log.write("=" * 79 + "\n")
     self.log.write("%s\n" % msg)
示例#12
0
 def end_message(self, msg):
     _OUTPUT.write("%s\n" % msg)
示例#13
0
 def start_message(self, msg):
     _OUTPUT.write(msg + "... ")
     self.log.write("=" * 79 + "\n")
     self.log.write("%s\n" % msg)
def pprint(color, str):
    _OUTPUT.write('%s%s%s\n' % (COLORS(color), str, COLORS('NORMAL')))