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


Python waflib.Context类代码示例

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


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

示例1: start

def start(cwd, version, wafdir):
	# this is the entry point of our small build system

	Logs.init_log()
	Context.waf_dir = wafdir
	Context.out_dir = Context.top_dir = Context.run_dir = cwd
	Context.g_module = Context.load_module(cwd + os.sep + 'wscript')
	Context.g_module.configure = configure
	Context.g_module.root_path = cwd
	Context.Context.recurse = recurse_rep

	Context.g_module.top = Context.g_module.out = '.' # no build directory

	# just parse the options and execute a build
	Options.OptionsContext().execute()

	conf = Context.create_context('configure')
	conf.options = Options.options
	conf.execute()

	bld = Context.create_context('build')
	bld.env = conf.env
	bld.options = Options.options
	bld.environ = os.environ
	bld.execute()
开发者ID:afeldman,项目名称:waf,代码行数:25,代码来源:ebdlib.py

示例2: parse_options

def parse_options():
	"""
	Parse the command-line options and initialize the logging system.
	Called by :py:func:`waflib.Scripting.waf_entry_point` during the initialization.
	"""
	Context.create_context('options').execute()

	if not Options.commands:
		Options.commands = [default_cmd]
	Options.commands = [x for x in Options.commands if x != 'options'] # issue 1076

	# process some internal Waf options
	Logs.verbose = Options.options.verbose
	Logs.init_log()

	if Options.options.zones:
		Logs.zones = Options.options.zones.split(',')
		if not Logs.verbose:
			Logs.verbose = 1
	elif Logs.verbose > 0:
		Logs.zones = ['runner']

	if Logs.verbose > 2:
		Logs.zones = ['*']
		
	# Force console mode for SSH connections
	if getattr(Options.options, 'console_mode', None):
		if os.environ.get('SSH_CLIENT') != None or os.environ.get('SSH_TTY') != None:
			Logs.info("[INFO] - SSH Connection detected. Forcing 'console_mode'")
			Options.options.console_mode = str(True)
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:30,代码来源:Scripting.py

示例3: parse_options

def parse_options():
	"""
	Parse the command-line options and initialize the logging system.
	Called by :py:func:`waflib.Scripting.waf_entry_point` during the initialization.
	"""
	Context.create_context('options').execute()

	for var in Options.envvars:
		(name, value) = var.split('=', 1)
		os.environ[name.strip()] = value

	if not Options.commands:
		Options.commands = [default_cmd]
	Options.commands = [x for x in Options.commands if x != 'options'] # issue 1076

	# process some internal Waf options
	Logs.verbose = Options.options.verbose
	#Logs.init_log()

	if Options.options.zones:
		Logs.zones = Options.options.zones.split(',')
		if not Logs.verbose:
			Logs.verbose = 1
	elif Logs.verbose > 0:
		Logs.zones = ['runner']

	if Logs.verbose > 2:
		Logs.zones = ['*']
开发者ID:XNerv,项目名称:waf,代码行数:28,代码来源:Scripting.py

示例4: parse_options

def parse_options():
	Context.create_context('options').execute()
	if not Options.commands:
		Options.commands=[default_cmd]
	Logs.verbose=Options.options.verbose
	Logs.init_log()
	if Options.options.zones:
		Logs.zones=Options.options.zones.split(',')
		if not Logs.verbose:
			Logs.verbose=1
	elif Logs.verbose>0:
		Logs.zones=['runner']
	if Logs.verbose>2:
		Logs.zones=['*']
开发者ID:dproc,项目名称:trex_odp_porting_integration,代码行数:14,代码来源:Scripting.py

示例5: build

def build(bld):
	subdirs = getattr(bld, 'subdirs', None)

	if subdirs:
		bld.recurse(subdirs)
		return

	maxdepth = getattr(Context.g_module, 'maxdepth', 1)
	subdirs = [ x.parent.nice_path() for x in bld.path.ant_glob('**/wscript_build', maxdepth=maxdepth ) ]
	what = Options.options.variant or ''
	variants = what.split(',')

	success = False
	for opt in variants:
		for variant in bld.env.variants:
			if opt not in variant:
				continue

			ctx = Context.create_context(bld.cmd)
			ctx.cmd = bld.cmd
			ctx.fun = 'build'
			ctx.subdirs = subdirs
			ctx.options = Options.options
			ctx.variant = variant
			ctx.execute()
			success = True

	if not success:
		raise Errors.WafError('"%s" is not a supported variant' % what)

	# Suppress missing target warnings
	bld.targets = '*'
开发者ID:loverszhaokai,项目名称:peach-bupt-paper,代码行数:32,代码来源:wscript.py

示例6: run_command

def run_command(cmd_name):
	"""run a single command (usually given on the command line)"""
	ctx = Context.create_context(cmd_name)
	ctx.options = Options.options # provided for convenience
	ctx.cmd = cmd_name
	ctx.execute()
	return ctx
开发者ID:RunarFreyr,项目名称:waz,代码行数:7,代码来源:Scripting.py

示例7: download_tool

def download_tool(tool, force=False):
	"""downloads a tool from the waf repository"""
	for x in Utils.to_list(Context.remote_repo):
		for sub in Utils.to_list(Context.remote_locs):
			url = '/'.join((x, sub, tool + '.py'))
			try:
				web = urlopen(url)
				if web.getcode() != 200:
					continue
			except Exception as e:
				# on python3 urlopen throws an exception
				continue
			else:
				tmp = self.root.make_node(os.sep.join((Context.waf_dir, 'waflib', 'extras', tool + '.py')))
				tmp.write(web.read())
				Logs.warn('downloaded %s from %s' % (tool, url))
				download_check(tmp)
				try:
					module = Context.load_tool(tool)
				except:
					Logs.warn('module %s from %s is unusable' % (tool, url))
					try:
						tmp.delete()
					except:
						pass
					continue
				return module
		else:
				break
		raise Errors.WafError('Could not load the Waf tool')
开发者ID:RunarFreyr,项目名称:waz,代码行数:30,代码来源:Configure.py

示例8: run_command

def run_command(cmd_name):
	ctx=Context.create_context(cmd_name)
	ctx.log_timer=Utils.Timer()
	ctx.options=Options.options
	ctx.cmd=cmd_name
	ctx.execute()
	return ctx
开发者ID:Cactuslegs,项目名称:audacity-of-nope,代码行数:7,代码来源:Scripting.py

示例9: load

	def load(self,input,tooldir=None,funs=None,download=True):
		tools=Utils.to_list(input)
		if tooldir:tooldir=Utils.to_list(tooldir)
		for tool in tools:
			mag=(tool,id(self.env),funs)
			if mag in self.tool_cache:
				self.to_log('(tool %s is already loaded, skipping)'%tool)
				continue
			self.tool_cache.append(mag)
			module=None
			try:
				module=Context.load_tool(tool,tooldir)
			except ImportError as e:
				if Options.options.download:
					module=download_tool(tool,ctx=self)
					if not module:
						self.fatal('Could not load the Waf tool %r or download a suitable replacement from the repository (sys.path %r)\n%s'%(tool,sys.path,e))
				else:
					self.fatal('Could not load the Waf tool %r from %r (try the --download option?):\n%s'%(tool,sys.path,e))
			except Exception as e:
				self.to_log('imp %r (%r & %r)'%(tool,tooldir,funs))
				self.to_log(Utils.ex_stack())
				raise
			if funs is not None:
				self.eval_rules(funs)
			else:
				func=getattr(module,'configure',None)
				if func:
					if type(func)is type(Utils.readf):func(self)
					else:self.eval_rules(func)
			self.tools.append({'tool':tool,'tooldir':tooldir,'funs':funs})
开发者ID:adrwtr,项目名称:BDJogosChip8,代码行数:31,代码来源:Configure.py

示例10: load

	def load(self,input,tooldir=None,funs=None,with_sys_path=True,cache=False):
		tools=Utils.to_list(input)
		if tooldir:tooldir=Utils.to_list(tooldir)
		for tool in tools:
			if cache:
				mag=(tool,id(self.env),tooldir,funs)
				if mag in self.tool_cache:
					self.to_log('(tool %s is already loaded, skipping)'%tool)
					continue
				self.tool_cache.append(mag)
			module=None
			try:
				module=Context.load_tool(tool,tooldir,ctx=self,with_sys_path=with_sys_path)
			except ImportError as e:
				self.fatal('Could not load the Waf tool %r from %r\n%s'%(tool,sys.path,e))
			except Exception as e:
				self.to_log('imp %r (%r & %r)'%(tool,tooldir,funs))
				self.to_log(Utils.ex_stack())
				raise
			if funs is not None:
				self.eval_rules(funs)
			else:
				func=getattr(module,'configure',None)
				if func:
					if type(func)is type(Utils.readf):func(self)
					else:self.eval_rules(func)
			self.tools.append({'tool':tool,'tooldir':tooldir,'funs':funs})
开发者ID:Gnurou,项目名称:glmark2,代码行数:27,代码来源:Configure.py

示例11: download_tool

def download_tool(tool,force=False,ctx=None):
	for x in Utils.to_list(Context.remote_repo):
		for sub in Utils.to_list(Context.remote_locs):
			url='/'.join((x,sub,tool+'.py'))
			try:
				web=urlopen(url)
				try:
					if web.getcode()!=200:
						continue
				except AttributeError:
					pass
			except Exception:
				continue
			else:
				tmp=ctx.root.make_node(os.sep.join((Context.waf_dir,'waflib','extras',tool+'.py')))
				tmp.write(web.read(),'wb')
				Logs.warn('Downloaded %s from %s'%(tool,url))
				download_check(tmp)
				try:
					module=Context.load_tool(tool)
				except Exception:
					Logs.warn('The tool %s from %s is unusable'%(tool,url))
					try:
						tmp.delete()
					except Exception:
						pass
					continue
				return module
	raise Errors.WafError('Could not load the Waf tool')
开发者ID:AkiraShirase,项目名称:audacity,代码行数:29,代码来源:Configure.py

示例12: download_tool

def download_tool(tool, force=False, ctx=None):
	"""
	Download a Waf tool from the remote repository defined in :py:const:`waflib.Context.remote_repo`::

		$ waf configure --download
	"""
	for x in Utils.to_list(Context.remote_repo):
		for sub in Utils.to_list(Context.remote_locs):
			url = '/'.join((x, sub, tool + '.py'))
			try:
				web = urlopen(url)
				if web.getcode() != 200:
					continue
			except Exception as e:
				# on python3 urlopen throws an exception
				continue
			else:
				tmp = ctx.root.make_node(os.sep.join((Context.waf_dir, 'waflib', 'extras', tool + '.py')))
				tmp.write(web.read())
				Logs.warn('Downloaded %s from %s' % (tool, url))
				download_check(tmp)
				try:
					module = Context.load_tool(tool)
				except:
					Logs.warn('The tool %s from %s is unusable' % (tool, url))
					try:
						tmp.delete()
					except:
						pass
					continue
				return module
	raise Errors.WafError('Could not load the Waf tool')
开发者ID:ita1024,项目名称:node,代码行数:32,代码来源:Configure.py

示例13: load

 def load(self, input, tooldir=None, funs=None, download=True):
     tools = Utils.to_list(input)
     if tooldir:
         tooldir = Utils.to_list(tooldir)
     for tool in tools:
         mag = (tool, id(self.env), funs)
         if mag in self.tool_cache:
             self.to_log("(tool %s is already loaded, skipping)" % tool)
             continue
         self.tool_cache.append(mag)
         module = None
         try:
             module = Context.load_tool(tool, tooldir)
         except ImportError, e:
             if Options.options.download:
                 module = download_tool(tool, ctx=self)
                 if not module:
                     self.fatal(
                         "Could not load the Waf tool %r or download a suitable replacement from the repository (sys.path %r)\n%s"
                         % (tool, sys.path, e)
                     )
             else:
                 self.fatal(
                     "Could not load the Waf tool %r from %r (try the --download option?):\n%s" % (tool, sys.path, e)
                 )
         except Exception, e:
             self.to_log("imp %r (%r & %r)" % (tool, tooldir, funs))
             self.to_log(Utils.ex_stack())
             raise
开发者ID:RONNCC,项目名称:pysoy,代码行数:29,代码来源:Configure.py

示例14: set_main_module

def set_main_module(file_path):
	"""
	Read the main wscript file into :py:const:`waflib.Context.Context.g_module` and
	bind default functions such as ``init``, ``dist``, ``distclean`` if not defined.
	Called by :py:func:`waflib.Scripting.waf_entry_point` during the initialization.

	:param file_path: absolute path representing the top-level wscript file
	:type file_path: string
	"""
	Context.g_module = Context.load_module(file_path)
	Context.g_module.root_path = file_path

	# note: to register the module globally, use the following:
	# sys.modules['wscript_main'] = g_module

	def set_def(obj):
		name = obj.__name__
		if not name in Context.g_module.__dict__:
			setattr(Context.g_module, name, obj)
	for k in (update, dist, distclean, distcheck):
		set_def(k)
	# add dummy init and shutdown functions if they're not defined
	if not 'init' in Context.g_module.__dict__:
		Context.g_module.init = Utils.nada
	if not 'shutdown' in Context.g_module.__dict__:
		Context.g_module.shutdown = Utils.nada
	if not 'options' in Context.g_module.__dict__:
		Context.g_module.options = Utils.nada
开发者ID:XNerv,项目名称:waf,代码行数:28,代码来源:Scripting.py

示例15: parse_options

def parse_options():
	Context.create_context('options').execute()
	for var in Options.envvars:
		(name,value)=var.split('=',1)
		os.environ[name.strip()]=value
	if not Options.commands:
		Options.commands=[default_cmd]
	Options.commands=[x for x in Options.commands if x!='options']
	Logs.verbose=Options.options.verbose
	if Options.options.zones:
		Logs.zones=Options.options.zones.split(',')
		if not Logs.verbose:
			Logs.verbose=1
	elif Logs.verbose>0:
		Logs.zones=['runner']
	if Logs.verbose>2:
		Logs.zones=['*']
开发者ID:Gnurou,项目名称:glmark2,代码行数:17,代码来源:Scripting.py


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