waf

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

wscript (1537B)


      1 #! /usr/bin/env waf
      2 
      3 top = '.'
      4 out = 'tmp_out'
      5 
      6 import os, random, time
      7 from waflib import ConfigSet, Context, Build, Configure, Utils
      8 
      9 Configure.autoconfig='clobber'
     10 
     11 def options(opt):
     12 	opt.add_option('--based', action='store', default='foo', help='base directory', dest='based')
     13 	opt.add_option('--dumpf', action='store', default='foo', help='dump config to this file', dest='dumpf')
     14 	opt.add_option('--force-autoconfig', action='store', default=False, dest='force_autoconfig')
     15 
     16 def configure(ctx):
     17 	# force autoconfig to depend on an always-changing file - once
     18 	if ctx.options.force_autoconfig:
     19 		fname = ctx.options.dumpf + '_autoconfig'
     20 		s = "%f%d" % (time.time(), random.randint(0, 10**9))
     21 		Utils.writef(fname, s)
     22 		ctx.files.append(fname)
     23 		Configure.autoconfig = False
     24 
     25 def build(ctx):
     26 	pass
     27 
     28 def write_conf(ctx):
     29 	if not ctx.options.dumpf:
     30 		raise ValueError('Missing --dumpf option')
     31 	if not ctx.options.based:
     32 		raise ValueError('Missing --based option')
     33 
     34 	def g(x):
     35 		# path from conf.options.based
     36 		based = ctx.root.find_node(ctx.options.based)
     37 		node = ctx.root.find_node(x)
     38 		return node.path_from(based)
     39 
     40 	env = ConfigSet.ConfigSet()
     41 	env.cwd_dir = g(os.getcwd())
     42 	env.top_dir = g(Context.top_dir)
     43 	env.out_dir = g(Context.out_dir)
     44 	env.run_dir = g(Context.run_dir)
     45 	env.launch_dir = g(Context.launch_dir)
     46 
     47 	env.store(ctx.options.dumpf)
     48 
     49 for y in (Build.BuildContext, Configure.ConfigurationContext):
     50 	class tmp(y):
     51 		def execute(self, *k, **kw):
     52 			super(self.__class__, self).execute(*k, **kw)
     53 			write_conf(self)
     54