wscript 904 B

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