2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-12-11 11:20:21 +01:00
waf/tests/config/wscript

156 lines
4.6 KiB
Plaintext
Raw Normal View History

2016-03-28 22:01:33 +02:00
#! /usr/bin/env python
# encoding: utf-8
from waflib.Logs import pprint
top = '.'
out = 'build'
def options(opt):
opt.load('compiler_c')
def configure(conf):
conf.load('compiler_c')
conf.failure = 0
def disp(color, result):
pprint(color, result)
if color == 'RED':
conf.failure=1
def test(*funs):
conf.env.stash()
conf.in_msg = 1 # suppress outputs
for f in funs:
ret = f()
if not ret:
color = "GREEN"
else:
color = "RED"
2016-04-03 13:41:24 +02:00
if ret:
ret = '\t\t' + ret
else:
ret = ''
disp(color, "%s%s" % (f.__doc__, ret))
2016-03-28 22:01:33 +02:00
conf.env.revert()
conf.in_msg = 0
return None
@test
def fun1():
"global_define=1 by default -> no DEFINES_X anywhere"
conf.check_cfg(package='libpng')
conf.check_cc(header_name='unistd.h')
2016-04-22 21:10:22 +02:00
for x in conf.env:
2016-03-28 22:01:33 +02:00
if x.startswith('DEFINES_') and x != 'DEFINES_ST':
return 'conf.env.%s = %r' % (x, conf.env[x])
@test
def fun2():
"global_define=1 -> no DEFINES_X anywhere"
conf.check_cfg(package='libpng', global_define=1)
conf.check_cc(header_name='unistd.h', global_define=1)
2016-04-22 21:10:22 +02:00
for x in conf.env:
2016-03-28 22:01:33 +02:00
if x.startswith('DEFINES_') and x != 'DEFINES_ST':
return 'conf.env.%s = %r' % (x, conf.env[x])
@test
def fun3():
"global_define=0 -> DEFINES=[]"
conf.check_cfg(package='libpng', global_define=0)
conf.check_cc(header_name='unistd.h', global_define=0)
if conf.env.DEFINES:
return 'conf.env.DEFINES = %r' % conf.env.DEFINES
@test
def fun4():
"global_define=0 -> DEFINES_LIBPNG=['HAVE_LIBPNG=1']"
conf.check_cfg(package='libpng', global_define=0)
val = conf.env.DEFINES_LIBPNG
if not isinstance(val, list) or not "HAVE_LIBPNG=1" in val:
return 'conf.env.DEFINES_LIBPNG = %r' % val
@test
def fun5():
"global_defines=0, uselib_store=UNISTD -> DEFINES_UNISTD=['HAVE_UNISTD_H=1']"
conf.check_cc(header_name='unistd.h', uselib_store='UNISTD', global_define=0)
val = conf.env.DEFINES_UNISTD
if not isinstance(val, list) or not 'HAVE_UNISTD_H=1' in val:
return 'conf.env.DEFINES_UNISTD = %r' % val
@test
2016-04-03 13:41:24 +02:00
def fun6():
2016-03-28 22:01:33 +02:00
"global_defines=0, uselib_store=UNISTD, define_name=FOO -> DEFINES_UNISTD=['FOO=1']"
conf.check_cc(header_name='unistd.h', uselib_store='UNISTD', global_define=0, define_name='FOO')
val = conf.env.DEFINES_UNISTD
if not isinstance(val, list) or not 'FOO=1' in val:
return 'conf.env.DEFINES_UNISTD = %r' % val
@test
2016-04-03 13:41:24 +02:00
def fun7():
2016-04-06 21:58:09 +02:00
"uselib_store=UNISTD -> HAVE_UNISTD=1"
conf.check_cc(header_name='unistd.h', uselib_store='UNISTD')
val = conf.env.HAVE_UNISTD
if val != 1:
return 'conf.env.HAVE_UNISTD = %r' % val
@test
def fun8():
2016-04-03 13:41:24 +02:00
"global_defines=0, define_name=HAVE_FOO -> DEFINES_LIBPNG=['HAVE_FOO=1']"
conf.check_cfg(package='libpng', global_define=0, define_name='HAVE_FOO')
val = conf.env.DEFINES_LIBPNG
if not isinstance(val, list) or not "HAVE_FOO=1" in val:
return 'conf.env.DEFINES_LIBPNG = %r' % val
@test
2016-04-03 13:30:03 +02:00
def modversion1():
"modversion=libpng -> DEFINES=['LIBPNG_VERSION=X']"
conf.check_cfg(modversion='libpng')
val = conf.env.DEFINES
# automatic uppercase
if not isinstance(val, list) or not val[0].startswith("LIBPNG_VERSION="):
return 'conf.env.DEFINES = %r' % val
@test
2016-04-03 13:30:03 +02:00
def modversion2():
2016-04-03 13:41:24 +02:00
"modversion=libpng, uselib_store=foo -> DEFINES=['FOO_VERSION=X']"
conf.check_cfg(modversion='libpng', uselib_store='foo')
val = conf.env.DEFINES
# automatic uppercase
if not isinstance(val, list) or not val[0].startswith("FOO_VERSION="):
return 'conf.env.DEFINES = %r' % val
@test
2016-04-03 13:30:03 +02:00
def modversion3():
2016-04-03 13:41:24 +02:00
"modversion=libpng, uselib_store=foo, define_name=bar -> DEFINES=['bar=X']"
conf.check_cfg(modversion='libpng', uselib_store='foo', define_name='bar')
val = conf.env.DEFINES
if not isinstance(val, list) or not val[0].startswith("bar="):
return 'conf.env.DEFINES = %r' % val
2016-04-03 13:30:03 +02:00
@test
2016-04-03 13:41:24 +02:00
def atleast_version1():
"atleast_version=1.0, global_define=1 -> DEFINES=['HAVE_LIBPNG=1']"
# same in waf 1.8 and 1.9
conf.check_cfg(package='libpng', atleast_version='1.0', global_define=1, args='--libs --cflags')
val = conf.env.DEFINES
if not isinstance(val, list) or not 'HAVE_LIBPNG=1' in val:
return 'conf.env.DEFINES = %r' % val
if not conf.env.LIB_LIBPNG:
return 'expected conf.env.LIB_LIBPNG to be defined :-/'
@test
def atleast_version2():
"atleast_version=1.0, uselib_store=foo -> DEFINES=['HAVE_FOO=1']"
2016-04-03 13:30:03 +02:00
conf.check_cfg(package='libpng', uselib_store='foo', atleast_version='1.0', args='--libs --cflags')
val = conf.env.DEFINES
if not isinstance(val, list) or not 'HAVE_FOO=1' in val:
return 'conf.env.DEFINES = %r' % val
if not conf.env.LIB_foo:
return 'expected conf.env.LIB_foo to be defined :-/'
2016-04-03 13:41:24 +02:00
2016-03-28 22:01:33 +02:00
if conf.failure:
conf.fatal('One or several test failed, check the outputs above')