wscript (904B)
1 #! /usr/bin/env python 2 3 """ 4 Run: "waf configure clean build" 5 6 The program "app" writes to both stdout and stderr, it is executed 7 directly or through another python process 8 """ 9 10 top = '.' 11 out = 'build' 12 13 def options(opt): 14 opt.load('compiler_c') 15 16 def configure(conf): 17 conf.load('compiler_c') 18 19 def build(bld): 20 21 def write(task): 22 task.outputs[0].write(''' 23 #include <stdio.h> 24 #include <stdlib.h> 25 int main() { 26 printf("hi\\n"); 27 perror("hello\\n"); 28 return 0; 29 }''') 30 31 bld(rule=write, target='main.c') 32 bld.program(source='main.c', target='app') 33 bld(rule='${SRC[0].abspath()}', source='app') 34 35 import sys 36 bld( 37 rule = '${tsk.generator.template % (tsk.generator.python, tsk.inputs[0].abspath())}', 38 template = """%s -c "import subprocess;subprocess.Popen(%r).wait()" """, 39 python = sys.executable, 40 source = 'app') 41