1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #! /usr/bin/env python
- top = '.'
- out = 'build'
- from waflib import Node, Build, Utils, Logs
- def tt(msg, expected, result):
- color = 'RED'
- if result == expected:
- color = 'GREEN'
- Logs.pprint(color, msg.ljust(20) + " %r" % result)
- FRAG1 = '''#include <stdio.h>\nint main() { printf(somestring); return 0; }\n'''
- FRAG2 = '''#ifdef MMM\nint main() { return 0; }\n#endif\n'''
- def options(opt):
- opt.load('compiler_c')
- def configure(conf):
- """the configuration should not raise any assert"""
- conf.load('compiler_c')
- conf.define('AAA', 1)
- tt('define AAA', "['AAA=1']", repr(conf.env.DEFINES))
- conf.undefine('AAA')
- tt('undefine AAA', [], conf.env.DEFINES)
- conf.define('BB', 32)
- conf.define('CC', 'test')
- conf.define('inline', 'inline', quote=False)
- conf.write_config_header()
- tt('empty config header', [], conf.env.DEFINES)
- conf.define('somestring', 'test')
- conf.check(fragment=FRAG1, define_name='MMM', mandatory=False)
- tt('is_defined(MMM)', True, conf.is_defined('MMM'))
- conf.check(fragment=FRAG2, define_name='NNN', mandatory=False)
- tt('defines are propagated to tests', True, conf.is_defined('NNN'))
- conf.undefine('AAA')
- conf.write_config_header('config.2.h', remove=False)
- tt('defines are not removed', 3, len(conf.env.DEFINES))
- tt('have_define', 'HAVE_FOO', conf.have_define('FOO'))
- conf.env.DEFINES = []
- conf.define('AAA', 1)
- conf.define('AAA', 2)
- tt('AAA', '2', conf.get_define('AAA'))
- tt('defines count', 1, len(conf.env.DEFINES))
- def build(bld):
- pass
|