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


Python Utils.quote_define_name方法代码示例

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


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

示例1: write_config_header

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import quote_define_name [as 别名]
def write_config_header(self, configfile='', guard='', top=False, env=None, defines=True, headers=False, remove=True):
	"""
	save the defines into a file
	with configfile=foo/bar.h and a script in folder xyz
	top -> build/foo/bar.h
	!top -> build/xyz/foo/bar.h

	defines: add the defines or not (yes by default)
	headers: add #include in the file (if headers are defined by env.INCKEYS)
	remove: remove the defines added to the configuration header (yes by default)
	"""
	if not configfile: configfile = WAF_CONFIG_H
	waf_guard = guard or '_%s_WAF' % Utils.quote_define_name(configfile)

	node = top and self.bldnode or self.path.get_bld()
	node = node.make_node(configfile)
	node.parent.mkdir()

	lst = ['/* WARNING! All changes made to this file will be lost! */\n']
	lst.append('#ifndef %s\n#define %s\n' % (waf_guard, waf_guard))
	lst.append(self.get_config_header(defines, headers))
	lst.append('\n#endif /* %s */\n' % waf_guard)

	node.write('\n'.join(lst))

	env = env or self.env

	# config files are not removed on "waf clean"
	env.append_unique(Build.CFG_FILES, [node.abspath()])

	if remove:
		for key in self.env[DEFKEYS]:
			self.undefine(key)
		self.env[DEFKEYS] = []
开发者ID:RunarFreyr,项目名称:waz,代码行数:36,代码来源:c_config.py

示例2: exec_cfg

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import quote_define_name [as 别名]
def exec_cfg(self, kw):

	# pkg-config version
	if 'atleast_pkgconfig_version' in kw:
		cmd = [kw['path'], '--atleast-pkgconfig-version=%s' % kw['atleast_pkgconfig_version']]
		self.cmd_and_log(cmd)
		if not 'okmsg' in kw:
			kw['okmsg'] = 'yes'
		return

	# checking for the version of a module
	for x in cfg_ver:
		y = x.replace('-', '_')
		if y in kw:
			self.cmd_and_log([kw['path'], '--%s=%s' % (x, kw[y]), kw['package']])
			if not 'okmsg' in kw:
				kw['okmsg'] = 'yes'
			self.define(self.have_define(kw.get('uselib_store', kw['package'])), 1, 0)
			break

	# retrieving the version of a module
	if 'modversion' in kw:
		version = self.cmd_and_log([kw['path'], '--modversion', kw['modversion']]).strip()
		self.define('%s_VERSION' % Utils.quote_define_name(kw.get('uselib_store', kw['modversion'])), version)
		return version

	lst = [kw['path']]

	defi = kw.get('define_variable', None)
	if not defi:
		defi = self.env.PKG_CONFIG_DEFINES or {}
	for key, val in defi.items():
		lst.append('--define-variable=%s=%s' % (key, val))

	if kw['package']:
		lst.extend(Utils.to_list(kw['package']))

	# retrieving variables of a module
	if 'variables' in kw:
		env = kw.get('env', self.env)
		uselib = kw.get('uselib_store', kw['package'].upper())
		vars = Utils.to_list(kw['variables'])
		for v in vars:
			val = self.cmd_and_log(lst + ['--variable=' + v]).strip()
			var = '%s_%s' % (uselib, v)
			env[var] = val
		if not 'okmsg' in kw:
			kw['okmsg'] = 'yes'
		return

	if 'args' in kw:
		lst += Utils.to_list(kw['args'])
	# so we assume the command-line will output flags to be parsed afterwards
	ret = self.cmd_and_log(lst)
	if not 'okmsg' in kw:
		kw['okmsg'] = 'yes'

	self.define(self.have_define(kw.get('uselib_store', kw['package'])), 1, 0)
	self.parse_flags(ret, kw.get('uselib_store', kw['package'].upper()), kw.get('env', self.env))
	return ret
开发者ID:RunarFreyr,项目名称:waz,代码行数:62,代码来源:c_config.py

示例3: write_config_header

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import quote_define_name [as 别名]
def write_config_header(self, configfile='', guard='', top=False, env=None, remove=True):
	"""
	save the defines into a file
	with configfile=foo/bar.h and a script in folder xyz
	top -> build/foo/bar.h
	!top -> build/xyz/foo/bar.h

	by default, reset env.DEFINES to []
	"""
	if not configfile: configfile = WAF_CONFIG_H
	waf_guard = guard or '_%s_WAF' % Utils.quote_define_name(configfile)

	node = top and self.bldnode or self.path.get_bld()
	node = node.make_node(configfile)
	node.parent.mkdir()

	lst = []
	lst.append('/* Configuration header created by Waf - do not edit */\n')
	lst.append('#ifndef %s\n#define %s\n' % (waf_guard, waf_guard))
	lst.append(self.get_config_header())
	lst.append('\n#endif /* %s */\n' % waf_guard)

	node.write('\n'.join(lst))

	env = env or self.env

	# config files are not removed on "waf clean"
	env.append_unique(Build.CFG_FILES, [node.path_from(self.bldnode)])

	if remove:
		for key in self.env[DEFKEYS]:
			self.undefine(key)
		self.env[DEFKEYS] = []
开发者ID:zsx,项目名称:waf,代码行数:35,代码来源:c_config.py

示例4: have_define

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import quote_define_name [as 别名]
def have_define(self, key):
	"""
	:param key: define name
	:type key: string
	:return: the input key prefixed by *HAVE_* and substitute any invalid characters.
	:rtype: string
	"""
	return self.__dict__.get('HAVE_PAT', 'HAVE_%s') % Utils.quote_define_name(key)
开发者ID:GrahamDennis,项目名称:xpdeint,代码行数:10,代码来源:c_config.py

示例5: have_define

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import quote_define_name [as 别名]
def have_define(self, key):
    """
	:param key: define name
	:type key: string
	:return: the input key prefixed by *HAVE_* and substitute any invalid characters.
	:rtype: string
	"""
    return (self.env.HAVE_PAT or "HAVE_%s") % Utils.quote_define_name(key)
开发者ID:kenmasumitsu,项目名称:waf,代码行数:10,代码来源:c_config.py

示例6: exec_cfg

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import quote_define_name [as 别名]
def exec_cfg(self,kw):
	path=Utils.to_list(kw['path'])
	env=self.env.env or None
	def define_it():
		pkgname=kw.get('uselib_store',kw['package'].upper())
		if kw.get('global_define'):
			self.define(self.have_define(kw['package']),1,False)
		else:
			self.env.append_unique('DEFINES_%s'%pkgname,"%s=1"%self.have_define(pkgname))
		self.env[self.have_define(pkgname)]=1
	if'atleast_pkgconfig_version'in kw:
		cmd=path+['--atleast-pkgconfig-version=%s'%kw['atleast_pkgconfig_version']]
		self.cmd_and_log(cmd,env=env)
		if not'okmsg'in kw:
			kw['okmsg']='yes'
		return
	for x in cfg_ver:
		y=x.replace('-','_')
		if y in kw:
			self.cmd_and_log(path+['--%s=%s'%(x,kw[y]),kw['package']],env=env)
			if not'okmsg'in kw:
				kw['okmsg']='yes'
			define_it()
			break
	if'modversion'in kw:
		version=self.cmd_and_log(path+['--modversion',kw['modversion']],env=env).strip()
		self.define('%s_VERSION'%Utils.quote_define_name(kw.get('uselib_store',kw['modversion'])),version)
		return version
	lst=[]+path
	defi=kw.get('define_variable',None)
	if not defi:
		defi=self.env.PKG_CONFIG_DEFINES or{}
	for key,val in defi.items():
		lst.append('--define-variable=%s=%s'%(key,val))
	static=kw.get('force_static',False)
	if'args'in kw:
		args=Utils.to_list(kw['args'])
		if'--static'in args or'--static-libs'in args:
			static=True
		lst+=args
	lst.extend(Utils.to_list(kw['package']))
	if'variables'in kw:
		v_env=kw.get('env',self.env)
		uselib=kw.get('uselib_store',kw['package'].upper())
		vars=Utils.to_list(kw['variables'])
		for v in vars:
			val=self.cmd_and_log(lst+['--variable='+v],env=env).strip()
			var='%s_%s'%(uselib,v)
			v_env[var]=val
		if not'okmsg'in kw:
			kw['okmsg']='yes'
		return
	ret=self.cmd_and_log(lst,env=env)
	if not'okmsg'in kw:
		kw['okmsg']='yes'
	define_it()
	self.parse_flags(ret,kw.get('uselib_store',kw['package'].upper()),kw.get('env',self.env),force_static=static,posix=kw.get('posix',None))
	return ret
开发者ID:AliZafar120,项目名称:ns3,代码行数:60,代码来源:c_config.py

示例7: have_define

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import quote_define_name [as 别名]
def have_define(self, key):
	"""
	Returns a variable suitable for command-line or header use by removing invalid characters
	and prefixing it with ``HAVE_``

	:param key: define name
	:type key: string
	:return: the input key prefixed by *HAVE_* and substitute any invalid characters.
	:rtype: string
	"""
	return (self.env.HAVE_PAT or 'HAVE_%s') % Utils.quote_define_name(key)
开发者ID:blablack,项目名称:ams-lv2,代码行数:13,代码来源:c_config.py

示例8: check_assembly

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import quote_define_name [as 别名]
def check_assembly(self, *k, **kw):
    path_list = []
    if "path_list" in kw:
        for path in kw['path_list']:
            if path:
                path_list.append(path)
        kw['path_list'] = path_list
    ret = self.find_file(*k, **kw)

    self.msg("Checking for %s" % k[0], ret, "GREEN")
    self.env.append_value(Utils.quote_define_name(k[0]), os.path.dirname(ret))
    self.define(self.have_define(k[0]), 1, 0)
开发者ID:SjB,项目名称:sdb-cli,代码行数:14,代码来源:cs_extra.py

示例9: exec_cfg

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import quote_define_name [as 别名]
def exec_cfg(self,kw):
	def define_it():
		self.define(self.have_define(kw.get('uselib_store',kw['package'])),1,0)
	env=kw.get('env',self.env)
	run_env=env.env or os.environ
	if'atleast_pkgconfig_version'in kw:
		cmd=[kw['path'],'--atleast-pkgconfig-version=%s'%kw['atleast_pkgconfig_version']]
		self.cmd_and_log(cmd,env=run_env)
		if not'okmsg'in kw:
			kw['okmsg']='yes'
		return
	for x in cfg_ver:
		y=x.replace('-','_')
		if y in kw:
			self.cmd_and_log([kw['path'],'--%s=%s'%(x,kw[y]),kw['package']],env=run_env)
			if not'okmsg'in kw:
				kw['okmsg']='yes'
			define_it()
			break
	if'modversion'in kw:
		version=self.cmd_and_log([kw['path'],'--modversion',kw['modversion']],env=run_env).strip()
		self.define('%s_VERSION'%Utils.quote_define_name(kw.get('uselib_store',kw['modversion'])),version)
		return version
	lst=[kw['path']]
	defi=kw.get('define_variable',None)
	if not defi:
		defi=self.env.PKG_CONFIG_DEFINES or{}
	for key,val in defi.items():
		lst.append('--define-variable=%s=%s'%(key,val))
	if'variables'in kw:
		uselib=kw.get('uselib_store',kw['package'].upper())
		vars=Utils.to_list(kw['variables'])
		for v in vars:
			val=self.cmd_and_log(lst+['--variable='+v],env=run_env).strip()
			var='%s_%s'%(uselib,v)
			env[var]=val
		if not'okmsg'in kw:
			kw['okmsg']='yes'
		return
	static=False
	if'args'in kw:
		args=Utils.to_list(kw['args'])
		if'--static'in args or'--static-libs'in args:
			static=True
		lst+=args
	lst.extend(Utils.to_list(kw['package']))
	ret=self.cmd_and_log(lst,env=run_env)
	if not'okmsg'in kw:
		kw['okmsg']='yes'
	define_it()
	self.parse_flags(ret,kw.get('uselib_store',kw['package'].upper()),kw.get('env',self.env),force_static=static)
	return ret
开发者ID:Easylovexjl,项目名称:ndn,代码行数:54,代码来源:c_config.py

示例10: validate_cfg

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import quote_define_name [as 别名]
def validate_cfg(self, kw):
	"""
	Searches for the program *pkg-config* if missing, and validates the
	parameters to pass to :py:func:`waflib.Tools.c_config.exec_cfg`.

	:param path: the **-config program to use** (default is *pkg-config*)
	:type path: list of string
	:param msg: message to display to describe the test executed
	:type msg: string
	:param okmsg: message to display when the test is successful
	:type okmsg: string
	:param errmsg: message to display in case of error
	:type errmsg: string
	"""
	if not 'path' in kw:
		if not self.env.PKGCONFIG:
			self.find_program('pkg-config', var='PKGCONFIG')
		kw['path'] = self.env.PKGCONFIG

	# verify that exactly one action is requested
	s = ('atleast_pkgconfig_version' in kw) + ('modversion' in kw) + ('package' in kw)
	if s != 1:
		raise ValueError('exactly one of atleast_pkgconfig_version, modversion and package must be set')
	if not 'msg' in kw:
		if 'atleast_pkgconfig_version' in kw:
			kw['msg'] = 'Checking for pkg-config version >= %r' % kw['atleast_pkgconfig_version']
		elif 'modversion' in kw:
			kw['msg'] = 'Checking for %r version' % kw['modversion']
		else:
			kw['msg'] = 'Checking for %r' %(kw['package'])

	# let the modversion check set the okmsg to the detected version
	if not 'okmsg' in kw and not 'modversion' in kw:
		kw['okmsg'] = 'yes'
	if not 'errmsg' in kw:
		kw['errmsg'] = 'not found'

	# pkg-config version
	if 'atleast_pkgconfig_version' in kw:
		pass
	elif 'modversion' in kw:
		if not 'uselib_store' in kw:
			kw['uselib_store'] = kw['modversion']
		if not 'define_name' in kw:
			kw['define_name'] = '%s_VERSION' % Utils.quote_define_name(kw['uselib_store'])
	else:
		if not 'uselib_store' in kw:
			kw['uselib_store'] = Utils.to_list(kw['package'])[0].upper()
		if not 'define_name' in kw:
			kw['define_name'] = self.have_define(kw['uselib_store'])
开发者ID:blablack,项目名称:ams-lv2,代码行数:52,代码来源:c_config.py

示例11: write_config_header

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import quote_define_name [as 别名]
def write_config_header(
    self, configfile="", guard="", top=False, defines=True, headers=False, remove=True, define_prefix=""
):
    """
	Writes a configuration header containing defines and includes::

		def configure(cnf):
			cnf.define('A', 1)
			cnf.write_config_header('config.h')

	This function only adds include guards (if necessary), consult
	:py:func:`waflib.Tools.c_config.get_config_header` for details on the body.

	:param configfile: path to the file to create (relative or absolute)
	:type configfile: string
	:param guard: include guard name to add, by default it is computed from the file name
	:type guard: string
	:param top: write the configuration header from the build directory (default is from the current path)
	:type top: bool
	:param defines: add the defines (yes by default)
	:type defines: bool
	:param headers: add #include in the file
	:type headers: bool
	:param remove: remove the defines after they are added (yes by default, works like in autoconf)
	:type remove: bool
	:type define_prefix: string
	:param define_prefix: prefix all the defines in the file with a particular prefix
	"""
    if not configfile:
        configfile = WAF_CONFIG_H
    waf_guard = guard or "W_%s_WAF" % Utils.quote_define_name(configfile)

    node = top and self.bldnode or self.path.get_bld()
    node = node.make_node(configfile)
    node.parent.mkdir()

    lst = ["/* WARNING! All changes made to this file will be lost! */\n"]
    lst.append("#ifndef %s\n#define %s\n" % (waf_guard, waf_guard))
    lst.append(self.get_config_header(defines, headers, define_prefix=define_prefix))
    lst.append("\n#endif /* %s */\n" % waf_guard)

    node.write("\n".join(lst))

    # config files must not be removed on "waf clean"
    self.env.append_unique(Build.CFG_FILES, [node.abspath()])

    if remove:
        for key in self.env[DEFKEYS]:
            self.undefine(key)
        self.env[DEFKEYS] = []
开发者ID:ArduPilot,项目名称:waf,代码行数:52,代码来源:c_config.py

示例12: check_header

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import quote_define_name [as 别名]
def check_header(self, h, **kw):

	if isinstance(h, str):
		code = '#include <%s>' % h
	else:
		code = '\n'.join(map(lambda x: '#include <%s>' % x, h))

	if 'msg' not in kw:
		kw['msg'] = 'Checking for %r' % h
	if 'errmsg' not in kw:
		kw['errmsg'] = 'not found'
	if 'define_name' not in kw:
		kw['define_name'] = 'HAVE_%s' % Utils.quote_define_name(h)
	self.check_cpp(fragment = code, **kw)
开发者ID:zsx,项目名称:waflib,代码行数:16,代码来源:misc.py

示例13: write_config_header

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import quote_define_name [as 别名]
def write_config_header(self, configfile='', guard='', top=False, env=None, defines=True, headers=False, remove=True, define_prefix=''):
	"""
	Write a configuration header containing defines and includes::

		def configure(cnf):
			cnf.define('A', 1)
			cnf.write_config_header('config.h')

	:param configfile: relative path to the file to create
	:type configfile: string
	:param guard: include guard name to add, by default it is computed from the file name
	:type guard: string
	:param top: write the configuration header from the build directory (default is from the current path)
	:type top: bool
	:param defines: add the defines (yes by default)
	:type defines: bool
	:param headers: add #include in the file
	:type headers: bool
	:param remove: remove the defines after they are added (yes by default, works like in autoconf)
	:type remove: bool
	:type define_prefix: string
	:param define_prefix: prefix all the defines in the file with a particular prefix
	"""
	# TODO waf 1.8: the parameter env is not used
	if env:
		Logs.warn('Cannot pass env to write_config_header')

	if not configfile: configfile = WAF_CONFIG_H
	waf_guard = guard or 'W_%s_WAF' % Utils.quote_define_name(configfile)

	node = top and self.bldnode or self.path.get_bld()
	node = node.make_node(configfile)
	node.parent.mkdir()

	lst = ['/* WARNING! All changes made to this file will be lost! */\n']
	lst.append('#ifndef %s\n#define %s\n' % (waf_guard, waf_guard))
	lst.append(self.get_config_header(defines, headers, define_prefix=define_prefix))
	lst.append('\n#endif /* %s */\n' % waf_guard)

	node.write('\n'.join(lst))

	# config files are not removed on "waf clean"
	self.env.append_unique(Build.CFG_FILES, [node.abspath()])

	if remove:
		for key in self.env[DEFKEYS]:
			self.undefine(key)
		self.env[DEFKEYS] = []
开发者ID:asudhak,项目名称:peachfuzz-code,代码行数:50,代码来源:c_config.py

示例14: write_config_header

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import quote_define_name [as 别名]
def write_config_header(self,configfile='',guard='',top=False,defines=True,headers=False,remove=True,define_prefix=''):
	if not configfile:configfile=WAF_CONFIG_H
	waf_guard=guard or'W_%s_WAF'%Utils.quote_define_name(configfile)
	node=top and self.bldnode or self.path.get_bld()
	node=node.make_node(configfile)
	node.parent.mkdir()
	lst=['/* WARNING! All changes made to this file will be lost! */\n']
	lst.append('#ifndef %s\n#define %s\n'%(waf_guard,waf_guard))
	lst.append(self.get_config_header(defines,headers,define_prefix=define_prefix))
	lst.append('\n#endif /* %s */\n'%waf_guard)
	node.write('\n'.join(lst))
	self.env.append_unique(Build.CFG_FILES,[node.abspath()])
	if remove:
		for key in self.env[DEFKEYS]:
			self.undefine(key)
		self.env[DEFKEYS]=[]
开发者ID:WU-ARL,项目名称:ndn-ops,代码行数:18,代码来源:c_config.py

示例15: exec_cfg

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import quote_define_name [as 别名]
def exec_cfg(self, kw):
    if "atleast_pkgconfig_version" in kw:
        cmd = [kw["path"], "--atleast-pkgconfig-version=%s" % kw["atleast_pkgconfig_version"]]
        self.cmd_and_log(cmd)
        if not "okmsg" in kw:
            kw["okmsg"] = "yes"
        return
    for x in cfg_ver:
        y = x.replace("-", "_")
        if y in kw:
            self.cmd_and_log([kw["path"], "--%s=%s" % (x, kw[y]), kw["package"]])
            if not "okmsg" in kw:
                kw["okmsg"] = "yes"
            self.define(self.have_define(kw.get("uselib_store", kw["package"])), 1, 0)
            break
    if "modversion" in kw:
        version = self.cmd_and_log([kw["path"], "--modversion", kw["modversion"]]).strip()
        self.define("%s_VERSION" % Utils.quote_define_name(kw.get("uselib_store", kw["modversion"])), version)
        return version
    lst = [kw["path"]]
    defi = kw.get("define_variable", None)
    if not defi:
        defi = self.env.PKG_CONFIG_DEFINES or {}
    for key, val in defi.items():
        lst.append("--define-variable=%s=%s" % (key, val))
    if kw["package"]:
        lst.extend(Utils.to_list(kw["package"]))
    if "variables" in kw:
        env = kw.get("env", self.env)
        uselib = kw.get("uselib_store", kw["package"].upper())
        vars = Utils.to_list(kw["variables"])
        for v in vars:
            val = self.cmd_and_log(lst + ["--variable=" + v]).strip()
            var = "%s_%s" % (uselib, v)
            env[var] = val
        if not "okmsg" in kw:
            kw["okmsg"] = "yes"
        return
    if "args" in kw:
        lst += Utils.to_list(kw["args"])
    ret = self.cmd_and_log(lst)
    if not "okmsg" in kw:
        kw["okmsg"] = "yes"
    self.define(self.have_define(kw.get("uselib_store", kw["package"])), 1, 0)
    self.parse_flags(ret, kw.get("uselib_store", kw["package"].upper()), kw.get("env", self.env))
    return ret
开发者ID:RunarFreyr,项目名称:waz,代码行数:48,代码来源:c_config.py


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