jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.2KB

  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Carlos Rafael Giani, 2007 (dv)
  4. # Thomas Nagy, 2010 (ita)
  5. """
  6. Try to detect a D compiler from the list of supported compilers::
  7. def options(opt):
  8. opt.load('compiler_d')
  9. def configure(cnf):
  10. cnf.load('compiler_d')
  11. def build(bld):
  12. bld.program(source='main.d', target='app')
  13. Only three D compilers are really present at the moment:
  14. * gdc
  15. * dmd, the ldc compiler having a very similar command-line interface
  16. * ldc2
  17. """
  18. import os, sys, imp, types, re
  19. from waflib import Utils, Configure, Options, Logs
  20. d_compiler = {
  21. 'default' : ['gdc', 'dmd', 'ldc2']
  22. }
  23. """
  24. Dict mapping the platform names to lists of names of D compilers to try, in order of preference::
  25. from waflib.Tools.compiler_d import d_compiler
  26. d_compiler['default'] = ['gdc', 'dmd', 'ldc2']
  27. """
  28. def default_compilers():
  29. build_platform = Utils.unversioned_sys_platform()
  30. possible_compiler_list = d_compiler.get(build_platform, d_compiler['default'])
  31. return ' '.join(possible_compiler_list)
  32. def configure(conf):
  33. """
  34. Try to find a suitable D compiler or raise a :py:class:`waflib.Errors.ConfigurationError`.
  35. """
  36. try: test_for_compiler = conf.options.check_d_compiler or default_compilers()
  37. except AttributeError: conf.fatal("Add options(opt): opt.load('compiler_d')")
  38. for compiler in re.split('[ ,]+', test_for_compiler):
  39. conf.env.stash()
  40. conf.start_msg('Checking for %r (D compiler)' % compiler)
  41. try:
  42. conf.load(compiler)
  43. except conf.errors.ConfigurationError as e:
  44. conf.env.revert()
  45. conf.end_msg(False)
  46. Logs.debug('compiler_d: %r' % e)
  47. else:
  48. if conf.env.D:
  49. conf.end_msg(conf.env.get_flat('D'))
  50. conf.env['COMPILER_D'] = compiler
  51. break
  52. conf.end_msg(False)
  53. else:
  54. conf.fatal('could not configure a D compiler!')
  55. def options(opt):
  56. """
  57. Restrict the compiler detection from the command-line::
  58. $ waf configure --check-d-compiler=dmd
  59. """
  60. test_for_compiler = default_compilers()
  61. d_compiler_opts = opt.add_option_group('Configuration options')
  62. d_compiler_opts.add_option('--check-d-compiler', default=None,
  63. help='list of D compilers to try [%s]' % test_for_compiler, dest='check_d_compiler')
  64. for x in test_for_compiler.split():
  65. opt.load('%s' % x)