2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-26 20:01:13 +01:00
waf/demos/wscript

150 lines
4.7 KiB
Plaintext
Raw Normal View History

2011-09-10 11:13:51 +02:00
#! /usr/bin/env python
# encoding: utf-8
# J. Carretero, 2010 (zougloub)
# Thomas Nagy, 2010 (ita)
"""
https://launchpad.net/subunit/
"""
import sys, os
if "uname" in dir(os): machine = os.uname()[1]
elif sys.platform == "win32": machine = os.environ["COMPUTERNAME"]
else: raise Exception("Unknown platform, cannot get machine name")
from waflib import Logs, Errors
2011-09-10 11:13:51 +02:00
# python 2.3 tends to hang for whatever reason :-/
PYTHONS = "2.5 2.6 2.7 3.0 3.1 3.2 3.3 3.4 3.5".split()
2011-09-10 11:13:51 +02:00
2012-06-16 01:53:06 +02:00
DIRS = ['c', 'python']
2016-04-19 22:00:21 +02:00
if os.environ.get('BUILDFARM'):
2015-09-20 11:42:20 +02:00
DIRS = [x for x in os.listdir('.') if os.path.isdir(x) and x not in ('variants', 'build', 'mac_app', 'precious') and x.find('waf-') < 0]
2011-09-10 11:13:51 +02:00
def options(opt):
for d in opt.path.ant_glob(DIRS, excl=['build', 'variants'], src=False, dir=True):
2011-09-10 11:13:51 +02:00
if d.name[0] == '.' or d.name == 'variants' or d.name == 'build':
continue
try:
opt.recurse(d.name)
except Exception:
2011-09-10 11:13:51 +02:00
pass
# one sub-project uses autoconfig, but i do not want it here
from waflib import Configure
Configure.autoconfig = False
def configure(conf):
#Logs.info('Running action configure') # build farm
try:
sub = conf.find_file('subprocess.py', ['/usr/lib64/python', '/usr/lib/python', '/usr/local/lib64/python', '/usr/local/lib/python'])
except:
sub = ''
2012-07-09 12:28:37 +02:00
curwaf = os.path.abspath(sys.argv[0])
conf.exec_command('%s %s configure build --zip-type=gz --tools=doxygen,fluid,ocaml,swig,compiler_fc,fc_config,fc,fc_scan,g95,ifort,gfortran,batched_cc,%s --prelude='' && /bin/cp waf demos/' % (sys.executable, curwaf, sub),
cwd=conf.path.parent.abspath())
2011-09-10 11:13:51 +02:00
node = conf.path.find_resource('waf')
if not node:
conf.fatal('Could not find Waf')
2011-09-10 11:13:51 +02:00
#if conf.exec_command([node.abspath(), '--help'], shell=False, env={}, cwd=node.parent.abspath()):
# conf.fatal('the waf file cannot be executed')
conf.env.WAF = node.abspath()
conf.in_msg += 1
for d in conf.path.ant_glob(DIRS, excl=['build', 'variants', 'precious'], src=False, dir=True):
2011-09-10 11:13:51 +02:00
if d.name[0] == '.':
continue
conf.env.stash()
2011-09-10 11:13:51 +02:00
try:
conf.recurse(d.name)
except Exception:
conf.env.revert()
2012-08-04 02:48:01 +02:00
node = conf.path.find_node('%s/build/config.log' % d.name)
if node:
Logs.info('-- BEGIN %s config.log --\n%s-- END %s config.log --', d.name, node.read(), d.name)
2012-07-11 18:44:16 +02:00
try:
e = sys.exc_info()[1]
print(e)
2011-09-10 11:13:51 +02:00
print(e.stdout, e.stderr)
2012-07-11 18:44:16 +02:00
except Exception:
2011-09-10 11:13:51 +02:00
pass
else:
conf.env.revert()
2011-09-10 11:13:51 +02:00
conf.env.append_value('CFG', [d.name])
2012-07-11 18:44:16 +02:00
print("The configurations enabled are %r" % conf.env.CFG)
2011-09-10 11:13:51 +02:00
# now remove the cache folders and re-create them
2015-09-20 11:42:20 +02:00
#conf.cmd_and_log('rm -rf .waf*')
2011-09-10 11:13:51 +02:00
for x in PYTHONS:
try:
conf.find_program('python'+x, var=x)
# unpacking the waf directory concurrently can lead to a race condition, we'll need to take care of this (thanks, build farm!)
conf.cmd_and_log(conf.env[x] + ['./waf', '--version'], env={})
except Exception as e:
2011-09-10 11:13:51 +02:00
pass
else:
conf.env.append_value('PYTHONS', x)
Logs.info('executing the build for folders %r and with pythons %r', conf.env.CFG, conf.env.PYTHONS)
2011-09-10 11:13:51 +02:00
Logs.info("contents of config.log:")
Logs.info(conf.path.find_node('build/config.log').read())
def build(bld):
print('Note: call "waf installcheck" (the default build does not do anything)')
from waflib.Build import BuildContext
class abc(BuildContext):
cmd = "installcheck"
fun = "installcheck"
def installcheck(bld):
bld.jobs = 1
2011-09-10 11:13:51 +02:00
#if bld.cmd == 'build':
# Logs.info('Running action build') # build farm
#print('testsuite: waflib')
def waf_cmd(self):
cmd = self.env[self.generator.python] + [self.env.WAF, 'distclean', 'configure', 'build', 'clean', 'build', '-o', 'build' + self.generator.python]
2011-09-10 11:13:51 +02:00
cwd = self.generator.cwd
env = dict(os.environ)
env['WAFDIR'] = ''
env['WAFLOCK'] = '.lock-wscript' + self.generator.python # use a different build directory for each build
try:
bld.cmd_and_log(cmd, cwd=cwd, env=env, quiet=0, )
except Errors.WafError as e:
2011-09-10 11:13:51 +02:00
e = sys.exc_info()[1]
s = "testsuite: %s\ntestsuite-xfail: %s [ %s \n %s ]\n" % (self.generator.name, self.generator.name, e.stderr, e.stdout)
Logs.info(s)
else:
s = "testsuite: %s\ntestsuite-success: %s\n" % (self.generator.name, self.generator.name)
Logs.info(s)
for x in bld.env.PYTHONS:
for dirname in bld.env.CFG:
bld(rule = waf_cmd,
cwd = dirname,
always = 1,
python = x,
name = '%s_%s' % (dirname, x))
#if bld.cmd == 'build':
# Logs.info('BUILD STATUS: 0\nACTION PASSED: build') # build farm
# Logs.info('Running action test') # build farm
#Logs.info('testsuite: abc')
#def end(bld):
# Logs.info('testsuite-success: abc')
# Logs.info('TEST STATUS: 0\nACTION FAILED: test')
#bld.add_post_fun(end)
#elif bld.cmd == 'install':
# Logs.info('Running action install') # build farm
# Logs.info('INSTALL STATUS: 0\nACTION PASSED: install') # build farm