Exemple #1
0
def run(cmd, reg):
    check = False

    if cmd[1] is None:
        cmd = [cmd[0]]

    print("running: ", " ".join(cmd), end="")

    if not exists("build/%s" % cmd[0]):
        pprint("YELLOW", " SKIPPING (does not exist)")
        return False

    p = subprocess.Popen(cmd,
                         stdin=subprocess.PIPE,
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE,
                         env=None,
                         cwd="build")

    stdout, stderr = p.communicate()

    regex = re.compile(reg)

    if regex.match(stdout) or regex.match(stderr):
        check = True

    if check:
        pprint("GREEN", "  OK")
        return False
    else:
        pprint("RED", "  FAILED")
        return True
Exemple #2
0
def check_emscripten_version(conf, emscripten_cc, major, minor, minimum):
    try:
        p = subprocess.Popen(
            emscripten_cc + ["--version"],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )
        out = p.communicate()[0]
        cc_major, cc_minor, _ = [int(v) for v in out.split()[4].split(".")]
    except Exception as e:
        conf.fatal("Could not determine the compiler version: {}".format(e))

    cc_version = "{}.{}".format(cc_major, cc_minor)

    if minimum:
        if cc_major < major or (cc_major == major and cc_minor < minor):
            conf.fatal(
                "Compiler version: {0}, "
                "required minimum version: {1}.{2}".format(cc_version, major, minor)
            )
    else:
        if cc_major != major or cc_minor != minor:
            conf.fatal(
                "Wrong compiler version: {0}, "
                "expected version: {1}.{2}".format(cc_version, major, minor)
            )
Exemple #3
0
def get_cc_version(conf,cc,gcc=False,icc=False):
	cmd=cc+['-dM','-E','-']
	try:
		p=subprocess.Popen(cmd,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
		p.stdin.write('\n')
		out=p.communicate()[0]
	except:
		conf.fatal('could not determine the compiler version %r'%cmd)
	if not isinstance(out,str):
		out=out
	if gcc:
		if out.find('__INTEL_COMPILER')>=0:
			conf.fatal('The intel compiler pretends to be gcc')
		if out.find('__GNUC__')<0:
			conf.fatal('Could not determine the compiler type')
	if icc and out.find('__INTEL_COMPILER')<0:
		conf.fatal('Not icc/icpc')
	k={}
	if icc or gcc:
		out=out.split('\n')
		import shlex
		for line in out:
			lst=shlex.split(line)
			if len(lst)>2:
				key=lst[1]
				val=lst[2]
				k[key]=val
		def isD(var):
			return var in k
		def isT(var):
			return var in k and k[var]!='0'
		if not conf.env.DEST_OS:
			conf.env.DEST_OS=''
		for i in MACRO_TO_DESTOS:
			if isD(i):
				conf.env.DEST_OS=MACRO_TO_DESTOS[i]
				break
		else:
			if isD('__APPLE__')and isD('__MACH__'):
				conf.env.DEST_OS='darwin'
			elif isD('__unix__'):
				conf.env.DEST_OS='generic'
		if isD('__ELF__'):
			conf.env.DEST_BINFMT='elf'
		elif isD('__WINNT__')or isD('__CYGWIN__'):
			conf.env.DEST_BINFMT='pe'
			conf.env.LIBDIR=conf.env['PREFIX']+'/bin'
		elif isD('__APPLE__'):
			conf.env.DEST_BINFMT='mac-o'
		if not conf.env.DEST_BINFMT:
			conf.env.DEST_BINFMT=Utils.destos_to_binfmt(conf.env.DEST_OS)
		for i in MACRO_TO_DEST_CPU:
			if isD(i):
				conf.env.DEST_CPU=MACRO_TO_DEST_CPU[i]
				break
		Logs.debug('ccroot: dest platform: '+' '.join([conf.env[x]or'?'for x in('DEST_OS','DEST_BINFMT','DEST_CPU')]))
		conf.env['CC_VERSION']=(k['__GNUC__'],k['__GNUC_MINOR__'],k['__GNUC_PATCHLEVEL__'])
	return k
Exemple #4
0
def getoutput(conf, cmd, stdin=False):
    try:
        if stdin:
            stdin = subprocess.PIPE
        else:
            stdin = None
        p = subprocess.Popen(cmd,
                             stdin=stdin,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
        if stdin:
            p.stdin.write('\n')
        stdout, stderr = p.communicate()
    except:
        conf.fatal('could not determine the compiler version %r' % cmd)
    else:
        if not isinstance(stdout, str):
            stdout = stdout
        if not isinstance(stderr, str):
            stderr = stderr
        return stdout, stderr