wscript 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #! /usr/bin/env python
  2. # encoding: utf-8
  3. # J. Carretero, 2010 (zougloub)
  4. # Thomas Nagy, 2010 (ita)
  5. """
  6. https://launchpad.net/subunit/
  7. """
  8. import sys, os
  9. if "uname" in dir(os): machine = os.uname()[1]
  10. elif sys.platform == "win32": machine = os.environ["COMPUTERNAME"]
  11. else: raise Exception("Unknown platform, cannot get machine name")
  12. from waflib import Logs, Errors
  13. # python 2.3 tends to hang for whatever reason :-/
  14. PYTHONS = "2.5 2.6 2.7 3.0 3.1 3.2 3.3 3.4 3.5".split()
  15. DIRS = ['c', 'python']
  16. if os.environ.get('BUILDFARM'):
  17. 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]
  18. def options(opt):
  19. for d in opt.path.ant_glob(DIRS, excl=['build', 'variants'], src=False, dir=True):
  20. if d.name[0] == '.' or d.name == 'variants' or d.name == 'build':
  21. continue
  22. try:
  23. opt.recurse(d.name)
  24. except Exception:
  25. pass
  26. # one sub-project uses autoconfig, but i do not want it here
  27. from waflib import Configure
  28. Configure.autoconfig = False
  29. def configure(conf):
  30. #Logs.info('Running action configure') # build farm
  31. try:
  32. sub = conf.find_file('subprocess.py', ['/usr/lib64/python', '/usr/lib/python', '/usr/local/lib64/python', '/usr/local/lib/python'])
  33. except:
  34. sub = ''
  35. curwaf = os.path.abspath(sys.argv[0])
  36. 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),
  37. cwd=conf.path.parent.abspath())
  38. node = conf.path.find_resource('waf')
  39. if not node:
  40. conf.fatal('Could not find Waf')
  41. #if conf.exec_command([node.abspath(), '--help'], shell=False, env={}, cwd=node.parent.abspath()):
  42. # conf.fatal('the waf file cannot be executed')
  43. conf.env.WAF = node.abspath()
  44. conf.in_msg += 1
  45. for d in conf.path.ant_glob(DIRS, excl=['build', 'variants', 'precious'], src=False, dir=True):
  46. if d.name[0] == '.':
  47. continue
  48. conf.env.stash()
  49. try:
  50. conf.recurse(d.name)
  51. except Exception:
  52. conf.env.revert()
  53. node = conf.path.find_node('%s/build/config.log' % d.name)
  54. if node:
  55. Logs.info('-- BEGIN %s config.log --\n%s-- END %s config.log --', d.name, node.read(), d.name)
  56. try:
  57. e = sys.exc_info()[1]
  58. print(e)
  59. print(e.stdout, e.stderr)
  60. except Exception:
  61. pass
  62. else:
  63. conf.env.revert()
  64. conf.env.append_value('CFG', [d.name])
  65. print("The configurations enabled are %r" % conf.env.CFG)
  66. # now remove the cache folders and re-create them
  67. #conf.cmd_and_log('rm -rf .waf*')
  68. for x in PYTHONS:
  69. try:
  70. conf.find_program('python'+x, var=x)
  71. # unpacking the waf directory concurrently can lead to a race condition, we'll need to take care of this (thanks, build farm!)
  72. conf.cmd_and_log(conf.env[x] + ['./waf', '--version'], env={})
  73. except Errors.WafError as e:
  74. pass
  75. else:
  76. conf.env.append_value('PYTHONS', x)
  77. Logs.info('executing the build for folders %r and with pythons %r', conf.env.CFG, conf.env.PYTHONS)
  78. Logs.info("contents of config.log:")
  79. Logs.info(conf.path.find_node('build/config.log').read())
  80. def build(bld):
  81. print('Note: call "waf installcheck" (the default build does not do anything)')
  82. from waflib.Build import BuildContext
  83. class abc(BuildContext):
  84. cmd = "installcheck"
  85. fun = "installcheck"
  86. def installcheck(bld):
  87. bld.jobs = 1
  88. #if bld.cmd == 'build':
  89. # Logs.info('Running action build') # build farm
  90. #print('testsuite: waflib')
  91. def waf_cmd(self):
  92. cmd = self.env[self.generator.python] + [self.env.WAF, 'distclean', 'configure', 'build', 'clean', 'build', '-o', 'build' + self.generator.python]
  93. cwd = self.generator.cwd
  94. env = dict(os.environ)
  95. env['WAFDIR'] = ''
  96. env['WAFLOCK'] = '.lock-wscript' + self.generator.python # use a different build directory for each build
  97. try:
  98. bld.cmd_and_log(cmd, cwd=cwd, env=env, quiet=0, )
  99. except Errors.WafError as e:
  100. e = sys.exc_info()[1]
  101. s = "testsuite: %s\ntestsuite-xfail: %s [ %s \n %s ]\n" % (self.generator.name, self.generator.name, e.stderr, e.stdout)
  102. Logs.info(s)
  103. else:
  104. s = "testsuite: %s\ntestsuite-success: %s\n" % (self.generator.name, self.generator.name)
  105. Logs.info(s)
  106. for x in bld.env.PYTHONS:
  107. for dirname in bld.env.CFG:
  108. bld(rule = waf_cmd,
  109. cwd = dirname,
  110. always = 1,
  111. python = x,
  112. name = '%s_%s' % (dirname, x))
  113. #if bld.cmd == 'build':
  114. # Logs.info('BUILD STATUS: 0\nACTION PASSED: build') # build farm
  115. # Logs.info('Running action test') # build farm
  116. #Logs.info('testsuite: abc')
  117. #def end(bld):
  118. # Logs.info('testsuite-success: abc')
  119. # Logs.info('TEST STATUS: 0\nACTION FAILED: test')
  120. #bld.add_post_fun(end)
  121. #elif bld.cmd == 'install':
  122. # Logs.info('Running action install') # build farm
  123. # Logs.info('INSTALL STATUS: 0\nACTION PASSED: install') # build farm