wscript 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #! /usr/bin/env python
  2. top = '.'
  3. out = 'build'
  4. from waflib import Node, Build, Utils, Logs
  5. def tt(msg, expected, result):
  6. color = 'RED'
  7. if result == expected:
  8. color = 'GREEN'
  9. Logs.pprint(color, msg.ljust(20) + " %r" % result)
  10. FRAG1 = '''#include <stdio.h>\nint main() { printf(somestring); return 0; }\n'''
  11. FRAG2 = '''#ifdef MMM\nint main() { return 0; }\n#endif\n'''
  12. def options(opt):
  13. opt.load('compiler_c')
  14. def configure(conf):
  15. """the configuration should not raise any assert"""
  16. conf.load('compiler_c')
  17. conf.define('AAA', 1)
  18. tt('define AAA', "['AAA=1']", repr(conf.env.DEFINES))
  19. conf.undefine('AAA')
  20. tt('undefine AAA', [], conf.env.DEFINES)
  21. conf.define('BB', 32)
  22. conf.define('CC', 'test')
  23. conf.define('inline', 'inline', quote=False)
  24. conf.write_config_header()
  25. tt('empty config header', [], conf.env.DEFINES)
  26. conf.define('somestring', 'test')
  27. conf.check(fragment=FRAG1, define_name='MMM', mandatory=False)
  28. tt('is_defined(MMM)', True, conf.is_defined('MMM'))
  29. conf.check(fragment=FRAG2, define_name='NNN', mandatory=False)
  30. tt('defines are propagated to tests', True, conf.is_defined('NNN'))
  31. conf.undefine('AAA')
  32. conf.write_config_header('config.2.h', remove=False)
  33. tt('defines are not removed', 3, len(conf.env.DEFINES))
  34. tt('have_define', 'HAVE_FOO', conf.have_define('FOO'))
  35. conf.env.DEFINES = []
  36. conf.define('AAA', 1)
  37. conf.define('AAA', 2)
  38. tt('AAA', '2', conf.get_define('AAA'))
  39. tt('defines count', 1, len(conf.env.DEFINES))
  40. def build(bld):
  41. pass