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
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
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
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
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)
def pprint(color, str): _OUTPUT.write('%s%s%s\n' % (COLORS(color), str, COLORS('NORMAL')))
def end_message(self, msg): _OUTPUT.write("%s\n" % msg)
def start_message(self, msg): _OUTPUT.write(msg + "... ") self.log.write("=" * 79 + "\n") self.log.write("%s\n" % msg)