waf

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

bbdlib.py (1115B)


      1 #! /usr/bin/env python
      2 
      3 import os, sys, imp
      4 from waflib import Context, Options, Configure, Utils, Logs
      5 
      6 def start(cwd, version, wafdir):
      7 	# simple example, the file main.c is hard-coded
      8 	try:
      9 		os.stat(cwd + os.sep + 'bbit')
     10 	except:
     11 		print('call from a folder containing a file named "bbit"')
     12 		sys.exit(1)
     13 
     14 	Logs.init_log()
     15 	Context.waf_dir = wafdir
     16 	Context.top_dir = Context.run_dir = cwd
     17 	Context.out_dir = os.path.join(cwd, 'build')
     18 	Context.g_module = imp.new_module('wscript')
     19 	Context.g_module.root_path = os.path.join(cwd, 'bbit')
     20 	Context.Context.recurse = \
     21 		lambda x, y: getattr(Context.g_module, x.cmd or x.fun, Utils.nada)(x)
     22 
     23 	Context.g_module.configure = lambda ctx: ctx.load('g++')
     24 	Context.g_module.build = lambda bld: bld.objects(source='main.c')
     25 
     26 	Options.OptionsContext().execute()
     27 
     28 	do_config = 'configure' in sys.argv
     29 	try:
     30 		os.stat(cwd + os.sep + 'build')
     31 	except:
     32 		do_config = True
     33 	if do_config:
     34 		Context.create_context('configure').execute()
     35 
     36 	if 'clean' in sys.argv:
     37 		Context.create_context('clean').execute()
     38 	if 'build' in sys.argv:
     39 		Context.create_context('build').execute()