当前位置: 首页>>代码示例>>Python>>正文


Python Utils.destos_to_binfmt方法代码示例

本文整理汇总了Python中waflib.Utils.destos_to_binfmt方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.destos_to_binfmt方法的具体用法?Python Utils.destos_to_binfmt怎么用?Python Utils.destos_to_binfmt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在waflib.Utils的用法示例。


在下文中一共展示了Utils.destos_to_binfmt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_cc_version

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import destos_to_binfmt [as 别名]
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
开发者ID:spo11,项目名称:archlinux,代码行数:60,代码来源:c_config.py

示例2: d_platform_flags

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import destos_to_binfmt [as 别名]
def d_platform_flags(self):
	v=self.env
	if not v.DEST_OS:
		v.DEST_OS=Utils.unversioned_sys_platform()
	if Utils.destos_to_binfmt(self.env.DEST_OS)=='pe':
		v['dprogram_PATTERN']='%s.exe'
		v['dshlib_PATTERN']='lib%s.dll'
		v['dstlib_PATTERN']='lib%s.a'
	else:
		v['dprogram_PATTERN']='%s'
		v['dshlib_PATTERN']='lib%s.so'
		v['dstlib_PATTERN']='lib%s.a'
开发者ID:ETLin,项目名称:ns3-h264-svc,代码行数:14,代码来源:d_config.py

示例3: d_platform_flags

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import destos_to_binfmt [as 别名]
def d_platform_flags(self):
    v = self.env
    if not v.DEST_OS:
        v.DEST_OS = Utils.unversioned_sys_platform()
    if Utils.destos_to_binfmt(self.env.DEST_OS) == "pe":
        v["dprogram_PATTERN"] = "%s.exe"
        v["dshlib_PATTERN"] = "lib%s.dll"
        v["dstlib_PATTERN"] = "lib%s.a"
    else:
        v["dprogram_PATTERN"] = "%s"
        v["dshlib_PATTERN"] = "lib%s.so"
        v["dstlib_PATTERN"] = "lib%s.a"
开发者ID:RONNCC,项目名称:pysoy,代码行数:14,代码来源:d_config.py

示例4: d_platform_flags

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import destos_to_binfmt [as 别名]
def d_platform_flags(self):
	"""
	Set the extensions dll/so for d programs and libraries
	"""
	v = self.env
	if not v.DEST_OS:
		v.DEST_OS = Utils.unversioned_sys_platform()
	if Utils.destos_to_binfmt(self.env.DEST_OS) == 'pe':
		v['dprogram_PATTERN'] = '%s.exe'
		v['dshlib_PATTERN']   = 'lib%s.dll'
		v['dstlib_PATTERN']   = 'lib%s.a'
	else:
		v['dprogram_PATTERN'] = '%s'
		v['dshlib_PATTERN']   = 'lib%s.so'
		v['dstlib_PATTERN']   = 'lib%s.a'
开发者ID:cournape,项目名称:waf,代码行数:17,代码来源:d_config.py

示例5: d_hook

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import destos_to_binfmt [as 别名]
def d_hook(self,node):
	ext=Utils.destos_to_binfmt(self.env.DEST_OS)=='pe'and'obj'or'o'
	out='%s.%d.%s'%(node.name,self.idx,ext)
	def create_compiled_task(self,name,node):
		task=self.create_task(name,node,node.parent.find_or_declare(out))
		try:
			self.compiled_tasks.append(task)
		except AttributeError:
			self.compiled_tasks=[task]
		return task
	if getattr(self,'generate_headers',None):
		tsk=create_compiled_task(self,'d_with_header',node)
		tsk.outputs.append(node.change_ext(self.env['DHEADER_ext']))
	else:
		tsk=create_compiled_task(self,'d',node)
	return tsk
开发者ID:ETLin,项目名称:ns3-h264-svc,代码行数:18,代码来源:d.py

示例6: d_platform_flags

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import destos_to_binfmt [as 别名]
def d_platform_flags(self):
	v=self.env
	if not v.DEST_OS:
		v.DEST_OS=Utils.unversioned_sys_platform()
	binfmt=Utils.destos_to_binfmt(self.env.DEST_OS)
	if binfmt=='pe':
		v.dprogram_PATTERN='%s.exe'
		v.dshlib_PATTERN='lib%s.dll'
		v.dstlib_PATTERN='lib%s.a'
	elif binfmt=='mac-o':
		v.dprogram_PATTERN='%s'
		v.dshlib_PATTERN='lib%s.dylib'
		v.dstlib_PATTERN='lib%s.a'
	else:
		v.dprogram_PATTERN='%s'
		v.dshlib_PATTERN='lib%s.so'
		v.dstlib_PATTERN='lib%s.a'
开发者ID:Gnurou,项目名称:glmark2,代码行数:19,代码来源:d_config.py

示例7: d_hook

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import destos_to_binfmt [as 别名]
def d_hook(self, node):
    ext = Utils.destos_to_binfmt(self.env.DEST_OS) == "pe" and "obj" or "o"
    out = "%s.%d.%s" % (node.name, self.idx, ext)

    def create_compiled_task(self, name, node):
        task = self.create_task(name, node, node.parent.find_or_declare(out))
        try:
            self.compiled_tasks.append(task)
        except AttributeError:
            self.compiled_tasks = [task]
        return task

    if getattr(self, "generate_headers", None):
        tsk = create_compiled_task(self, "d_with_header", node)
        tsk.outputs.append(node.change_ext(self.env["DHEADER_ext"]))
    else:
        tsk = create_compiled_task(self, "d", node)
    return tsk
开发者ID:hlyes,项目名称:ns-3-dev,代码行数:20,代码来源:d.py

示例8: d_hook

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import destos_to_binfmt [as 别名]
def d_hook(self, node):
	"""
	Compile *D* files. To get .di files as well as .o files, set the following::

		def build(bld):
			bld.program(source='foo.d', target='app', generate_headers=True)

	"""
	ext = Utils.destos_to_binfmt(self.env.DEST_OS) == 'pe' and 'obj' or 'o'
	out = '%s.%d.%s' % (node.name, self.idx, ext)
	def create_compiled_task(self, name, node):
		task = self.create_task(name, node, node.parent.find_or_declare(out))
		try:
			self.compiled_tasks.append(task)
		except AttributeError:
			self.compiled_tasks = [task]
		return task

	if getattr(self, 'generate_headers', None):
		tsk = create_compiled_task(self, 'd_with_header', node)
		tsk.outputs.append(node.change_ext(self.env['DHEADER_ext']))
	else:
		tsk = create_compiled_task(self, 'd', node)
	return tsk
开发者ID:RedHatter,项目名称:diodon-plugins,代码行数:26,代码来源:d.py

示例9: get_cc_version

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import destos_to_binfmt [as 别名]
def get_cc_version(conf,cc,gcc=False,icc=False,clang=False):
	cmd=cc+['-dM','-E','-']
	env=conf.env.env or None
	try:
		p=Utils.subprocess.Popen(cmd,stdin=Utils.subprocess.PIPE,stdout=Utils.subprocess.PIPE,stderr=Utils.subprocess.PIPE,env=env)
		p.stdin.write('\n')
		out=p.communicate()[0]
	except Exception:
		conf.fatal('Could not determine the compiler version %r'%cmd)
	if not isinstance(out,str):
		out=out.decode(sys.stdout.encoding or'iso8859-1')
	if gcc:
		if out.find('__INTEL_COMPILER')>=0:
			conf.fatal('The intel compiler pretends to be gcc')
		if out.find('__GNUC__')<0 and out.find('__clang__')<0:
			conf.fatal('Could not determine the compiler type')
	if icc and out.find('__INTEL_COMPILER')<0:
		conf.fatal('Not icc/icpc')
	if clang and out.find('__clang__')<0:
		conf.fatal('Not clang/clang++')
	k={}
	if icc or gcc or clang:
		out=out.splitlines()
		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__')or isD('_WIN32'):
			conf.env.DEST_BINFMT='pe'
			conf.env.LIBDIR=conf.env.BINDIR
		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')]))
		if icc:
			ver=k['__INTEL_COMPILER']
			conf.env['CC_VERSION']=(ver[:-2],ver[-2],ver[-1])
		else:
			if isD('__clang__'):
				conf.env['CC_VERSION']=(k['__clang_major__'],k['__clang_minor__'],k['__clang_patchlevel__'])
			else:
				try:
					conf.env['CC_VERSION']=(k['__GNUC__'],k['__GNUC_MINOR__'],k['__GNUC_PATCHLEVEL__'])
				except KeyError:
					conf.env['CC_VERSION']=(k['__GNUC__'],k['__GNUC_MINOR__'],0)
	return k
开发者ID:WU-ARL,项目名称:ndn-ops,代码行数:72,代码来源:c_config.py

示例10: get_cc_version

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import destos_to_binfmt [as 别名]
def get_cc_version(conf, cc, gcc=False, icc=False, clang=False):
	"""
	Runs the preprocessor to determine the gcc/icc/clang version

	The variables CC_VERSION, DEST_OS, DEST_BINFMT and DEST_CPU will be set in *conf.env*

	:raise: :py:class:`waflib.Errors.ConfigurationError`
	"""
	cmd = cc + ['-dM', '-E', '-']
	env = conf.env.env or None
	try:
		out, err = conf.cmd_and_log(cmd, output=0, input='\n'.encode(), env=env)
	except Errors.WafError:
		conf.fatal('Could not determine the compiler version %r' % cmd)

	if gcc:
		if out.find('__INTEL_COMPILER') >= 0:
			conf.fatal('The intel compiler pretends to be gcc')
		if out.find('__GNUC__') < 0 and out.find('__clang__') < 0:
			conf.fatal('Could not determine the compiler type')

	if icc and out.find('__INTEL_COMPILER') < 0:
		conf.fatal('Not icc/icpc')

	if clang and out.find('__clang__') < 0:
		conf.fatal('Not clang/clang++')
	if not clang and out.find('__clang__') >= 0:
		conf.fatal('Could not find gcc/g++ (only Clang), if renamed try eg: CC=gcc48 CXX=g++48 waf configure')

	k = {}
	if icc or gcc or clang:
		out = out.splitlines()
		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

		# Some documentation is available at http://predef.sourceforge.net
		# The names given to DEST_OS must match what Utils.unversioned_sys_platform() returns.
		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__'): # unix must be tested last as it's a generic fallback
				conf.env.DEST_OS = 'generic'

		if isD('__ELF__'):
			conf.env.DEST_BINFMT = 'elf'
		elif isD('__WINNT__') or isD('__CYGWIN__') or isD('_WIN32'):
			conf.env.DEST_BINFMT = 'pe'
			if not conf.env.IMPLIBDIR:
				conf.env.IMPLIBDIR = conf.env.LIBDIR # for .lib or .dll.a files
			conf.env.LIBDIR = conf.env.BINDIR
		elif isD('__APPLE__'):
			conf.env.DEST_BINFMT = 'mac-o'

		if not conf.env.DEST_BINFMT:
			# Infer the binary format from the os name.
			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')]))
		if icc:
			ver = k['__INTEL_COMPILER']
			conf.env.CC_VERSION = (ver[:-2], ver[-2], ver[-1])
		else:
			if isD('__clang__') and isD('__clang_major__'):
				conf.env.CC_VERSION = (k['__clang_major__'], k['__clang_minor__'], k['__clang_patchlevel__'])
			else:
				# older clang versions and gcc
				conf.env.CC_VERSION = (k['__GNUC__'], k['__GNUC_MINOR__'], k.get('__GNUC_PATCHLEVEL__', '0'))
	return k
开发者ID:blablack,项目名称:ams-lv2,代码行数:88,代码来源:c_config.py

示例11: get_cc_version

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import destos_to_binfmt [as 别名]
def get_cc_version(conf, cc, gcc=False, icc=False):
	"""
	Run the preprocessor to determine the compiler version

	The variables CC_VERSION, DEST_OS, DEST_BINFMT and DEST_CPU will be set in *conf.env*
	"""
	cmd = cc + ['-dM', '-E', '-']
	try:
		p = Utils.subprocess.Popen(cmd, stdin=Utils.subprocess.PIPE, stdout=Utils.subprocess.PIPE, stderr=Utils.subprocess.PIPE)
		p.stdin.write('\n'.encode())
		out = p.communicate()[0]
	except:
		conf.fatal('could not determine the compiler version %r' % cmd)

	if not isinstance(out, str):
		out = out.decode(sys.stdout.encoding)

	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'

		# Some documentation is available at http://predef.sourceforge.net
		# The names given to DEST_OS must match what Utils.unversioned_sys_platform() returns.
		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__'): # unix must be tested last as it's a generic fallback
				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:
			# Infer the binary format from the os name.
			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')]))
		if icc:
			ver = k['__INTEL_COMPILER']
			conf.env['CC_VERSION'] = (ver[:-2], ver[-2], ver[-1])
		else:
			conf.env['CC_VERSION'] = (k['__GNUC__'], k['__GNUC_MINOR__'], k['__GNUC_PATCHLEVEL__'])
	return k
开发者ID:GrahamDennis,项目名称:xpdeint,代码行数:84,代码来源:c_config.py

示例12: get_cc_version

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import destos_to_binfmt [as 别名]
def get_cc_version(conf, cc, gcc=False, icc=False, clang=False):
    """
	Runs the preprocessor to determine the gcc/icc/clang version

	The variables CC_VERSION, DEST_OS, DEST_BINFMT and DEST_CPU will be set in *conf.env*

	:raise: :py:class:`waflib.Errors.ConfigurationError`
	"""
    cmd = cc + ["-dM", "-E", "-"]
    env = conf.env.env or None
    try:
        out, err = conf.cmd_and_log(cmd, output=0, input="\n".encode(), env=env)
    except Exception:
        conf.fatal("Could not determine the compiler version %r" % cmd)

    if gcc:
        if out.find("__INTEL_COMPILER") >= 0:
            conf.fatal("The intel compiler pretends to be gcc")
        if out.find("__GNUC__") < 0 and out.find("__clang__") < 0:
            conf.fatal("Could not determine the compiler type")

    if icc and out.find("__INTEL_COMPILER") < 0:
        conf.fatal("Not icc/icpc")

    if clang and out.find("__clang__") < 0:
        conf.fatal("Not clang/clang++")
    if not clang and out.find("__clang__") >= 0:
        conf.fatal("Could not find gcc/g++ (only Clang), if renamed try eg: CC=gcc48 CXX=g++48 waf configure")

    k = {}
    if icc or gcc or clang:
        out = out.splitlines()
        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

            # Some documentation is available at http://predef.sourceforge.net
            # The names given to DEST_OS must match what Utils.unversioned_sys_platform() returns.

        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__"):  # unix must be tested last as it's a generic fallback
                conf.env.DEST_OS = "generic"

        if isD("__ELF__"):
            conf.env.DEST_BINFMT = "elf"
        elif isD("__WINNT__") or isD("__CYGWIN__") or isD("_WIN32"):
            conf.env.DEST_BINFMT = "pe"
            conf.env.LIBDIR = conf.env.BINDIR
        elif isD("__APPLE__"):
            conf.env.DEST_BINFMT = "mac-o"

        if not conf.env.DEST_BINFMT:
            # Infer the binary format from the os name.
            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")])
        )
        if icc:
            ver = k["__INTEL_COMPILER"]
            conf.env.CC_VERSION = (ver[:-2], ver[-2], ver[-1])
        else:
            if isD("__clang__") and isD("__clang_major__"):
                conf.env.CC_VERSION = (k["__clang_major__"], k["__clang_minor__"], k["__clang_patchlevel__"])
            else:
                # older clang versions and gcc
                conf.env.CC_VERSION = (k["__GNUC__"], k["__GNUC_MINOR__"], k.get("__GNUC_PATCHLEVEL__", "0"))
    return k
开发者ID:ArduPilot,项目名称:waf,代码行数:89,代码来源:c_config.py

示例13: get_cc_version

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import destos_to_binfmt [as 别名]
def get_cc_version(conf, cc, gcc=False, icc=False):
	"""get the compiler version"""
	cmd = cc + ['-dM', '-E', '-']
	try:
		p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
		p.stdin.write('\n'.encode())
		out = p.communicate()[0]
	except:
		conf.fatal('could not determine the compiler version %r' % cmd)

	if not isinstance(out, str):
		out = out.decode('utf-8')

	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'

		# Some documentation is available at http://predef.sourceforge.net
		# The names given to DEST_OS must match what Utils.unversioned_sys_platform() returns.
		mp1 = {
			'__linux__'   : 'linux',
			'__GNU__'     : 'gnu',
			'__FreeBSD__' : 'freebsd',
			'__NetBSD__'  : 'netbsd',
			'__OpenBSD__' : 'openbsd',
			'__sun'       : 'sunos',
			'__hpux'      : 'hpux',
			'__sgi'       : 'irix',
			'_AIX'        : 'aix',
			'__CYGWIN__'  : 'cygwin',
			'__MSYS__'    : 'msys',
			'_UWIN'       : 'uwin',
			'_WIN64'      : 'win32',
			'_WIN32'      : 'win32',
			'__POWERPC__' : 'powerpc',
			}

		for i in mp1:
			if isD(i):
				conf.env.DEST_OS = mp1[i]
				break
		else:
			if isD('__APPLE__') and isD('__MACH__'):
				conf.env.DEST_OS = 'darwin'
			elif isD('__unix__'): # unix must be tested last as it's a generic fallback
				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:
			# Infer the binary format from the os name.
			conf.env.DEST_BINFMT = Utils.destos_to_binfmt(conf.env.DEST_OS)

		mp2 = {
				'__x86_64__'  : 'x86_64',
				'__i386__'    : 'x86',
				'__ia64__'    : 'ia',
				'__mips__'    : 'mips',
				'__sparc__'   : 'sparc',
				'__alpha__'   : 'alpha',
				'__arm__'     : 'arm',
				'__hppa__'    : 'hppa',
				'__powerpc__' : 'powerpc',
				}
		for i in mp2:
			if isD(i):
				conf.env.DEST_CPU = mp2[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__'])
#.........这里部分代码省略.........
开发者ID:RunarFreyr,项目名称:waz,代码行数:103,代码来源:c_config.py

示例14: get_cc_version

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import destos_to_binfmt [as 别名]
def get_cc_version(conf,cc,gcc=False,icc=False,clang=False):
	cmd=cc+['-dM','-E','-']
	env=conf.env.env or None
	try:
		out,err=conf.cmd_and_log(cmd,output=0,input='\n',env=env)
	except Exception:
		conf.fatal('Could not determine the compiler version %r'%cmd)
	if gcc:
		if out.find('__INTEL_COMPILER')>=0:
			conf.fatal('The intel compiler pretends to be gcc')
		if out.find('__GNUC__')<0 and out.find('__clang__')<0:
			conf.fatal('Could not determine the compiler type')
	if icc and out.find('__INTEL_COMPILER')<0:
		conf.fatal('Not icc/icpc')
	if clang and out.find('__clang__')<0:
		conf.fatal('Not clang/clang++')
	if not clang and out.find('__clang__')>=0:
		conf.fatal('Could not find gcc/g++ (only Clang), if renamed try eg: CC=gcc48 CXX=g++48 waf configure')
	k={}
	if icc or gcc or clang:
		out=out.splitlines()
		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
		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__')or isD('_WIN32'):
			conf.env.DEST_BINFMT='pe'
			conf.env.LIBDIR=conf.env.BINDIR
		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')]))
		if icc:
			ver=k['__INTEL_COMPILER']
			conf.env['CC_VERSION']=(ver[:-2],ver[-2],ver[-1])
		else:
			if isD('__clang__')and isD('__clang_major__'):
				conf.env['CC_VERSION']=(k['__clang_major__'],k['__clang_minor__'],k['__clang_patchlevel__'])
			else:
				conf.env['CC_VERSION']=(k['__GNUC__'],k['__GNUC_MINOR__'],k.get('__GNUC_PATCHLEVEL__','0'))
	return k
开发者ID:AliZafar120,项目名称:ns3,代码行数:65,代码来源:c_config.py

示例15: get_cc_version

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import destos_to_binfmt [as 别名]
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"

        mp1 = {
            "__linux__": "linux",
            "__GNU__": "gnu",
            "__FreeBSD__": "freebsd",
            "__NetBSD__": "netbsd",
            "__OpenBSD__": "openbsd",
            "__sun": "sunos",
            "__hpux": "hpux",
            "__sgi": "irix",
            "_AIX": "aix",
            "__CYGWIN__": "cygwin",
            "__MSYS__": "msys",
            "_UWIN": "uwin",
            "_WIN64": "win32",
            "_WIN32": "win32",
            "__POWERPC__": "powerpc",
        }
        for i in mp1:
            if isD(i):
                conf.env.DEST_OS = mp1[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)
        mp2 = {
            "__x86_64__": "x86_64",
            "__i386__": "x86",
            "__ia64__": "ia",
            "__mips__": "mips",
            "__sparc__": "sparc",
            "__alpha__": "alpha",
            "__arm__": "arm",
            "__hppa__": "hppa",
            "__powerpc__": "powerpc",
        }
        for i in mp2:
            if isD(i):
                conf.env.DEST_CPU = mp2[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
开发者ID:RunarFreyr,项目名称:waz,代码行数:92,代码来源:c_config.py


注:本文中的waflib.Utils.destos_to_binfmt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。