waf

FORK: waf with some random patches
git clone https://git.neptards.moe/neptards/waf.git
Log | Files | Refs | README

extpy.py (1559B)


      1 #! /usr/bin/env python
      2 # encoding: utf-8
      3 
      4 import os
      5 from waflib import Errors, Utils
      6 from waflib import Context as mod
      7 
      8 class Context(mod.Context):
      9 	cmd = 'all'
     10 	def recurse(self, dirs, name=None, mandatory=True, once=True):
     11 		try:
     12 			cache = self.recurse_cache
     13 		except:
     14 			cache = self.recurse_cache = {}
     15 
     16 		for d in Utils.to_list(dirs):
     17 
     18 			if not os.path.isabs(d):
     19 				# absolute paths only
     20 				d = os.path.join(self.path.abspath(), d)
     21 
     22 			WSCRIPT     = os.path.join(d, 'wscript.py')
     23 			WSCRIPT_FUN = 'wscript_' + (name or self.fun) + '.py'
     24 
     25 			node = self.root.find_node(WSCRIPT_FUN)
     26 			if node and (not once or node not in cache):
     27 				cache[node] = True
     28 				self.pre_recurse(node)
     29 				try:
     30 					function_code = node.read('r')
     31 					exec(compile(function_code, node.abspath(), 'exec'), self.exec_dict)
     32 				finally:
     33 					self.post_recurse(node)
     34 			elif not node:
     35 				node = self.root.find_node(WSCRIPT)
     36 				if node and (not once or node not in cache):
     37 					cache[node] = True
     38 					self.pre_recurse(node)
     39 					try:
     40 						wscript_module = mod.load_module(node.abspath())
     41 						user_function = getattr(wscript_module, (name or self.fun), None)
     42 						if not user_function:
     43 							if not mandatory:
     44 								continue
     45 							raise Errors.WafError('No function %s defined in %s' % (name or self.fun, node.abspath()))
     46 						user_function(self)
     47 					finally:
     48 						self.post_recurse(node)
     49 				elif not node:
     50 					if not mandatory:
     51 						continue
     52 					raise Errors.WafError('No wscript file in directory %s' % d)
     53 mod.Context = Context
     54 mod.WSCRIPT_FILE = 'wscript.py'