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.

89 lines
2.1KB

  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Carlos Rafael Giani, 2007 (dv)
  4. # Thomas Nagy, 2008-2010 (ita)
  5. import sys
  6. from waflib.Tools import ar, d
  7. from waflib.Configure import conf
  8. @conf
  9. def find_dmd(conf):
  10. """
  11. Find the program *dmd*, *dmd2*, or *ldc* and set the variable *D*
  12. """
  13. conf.find_program(['dmd', 'dmd2', 'ldc'], var='D')
  14. # make sure that we're dealing with dmd1, dmd2, or ldc(1)
  15. out = conf.cmd_and_log(conf.env.D + ['--help'])
  16. if out.find("D Compiler v") == -1:
  17. out = conf.cmd_and_log(conf.env.D + ['-version'])
  18. if out.find("based on DMD v1.") == -1:
  19. conf.fatal("detected compiler is not dmd/ldc")
  20. @conf
  21. def common_flags_ldc(conf):
  22. """
  23. Set the D flags required by *ldc*
  24. """
  25. v = conf.env
  26. v['DFLAGS'] = ['-d-version=Posix']
  27. v['LINKFLAGS'] = []
  28. v['DFLAGS_dshlib'] = ['-relocation-model=pic']
  29. @conf
  30. def common_flags_dmd(conf):
  31. """
  32. Set the flags required by *dmd* or *dmd2*
  33. """
  34. v = conf.env
  35. # _DFLAGS _DIMPORTFLAGS
  36. # Compiler is dmd so 'gdc' part will be ignored, just
  37. # ensure key is there, so wscript can append flags to it
  38. #v['DFLAGS'] = ['-version=Posix']
  39. v['D_SRC_F'] = ['-c']
  40. v['D_TGT_F'] = '-of%s'
  41. # linker
  42. v['D_LINKER'] = v['D']
  43. v['DLNK_SRC_F'] = ''
  44. v['DLNK_TGT_F'] = '-of%s'
  45. v['DINC_ST'] = '-I%s'
  46. v['DSHLIB_MARKER'] = v['DSTLIB_MARKER'] = ''
  47. v['DSTLIB_ST'] = v['DSHLIB_ST'] = '-L-l%s'
  48. v['DSTLIBPATH_ST'] = v['DLIBPATH_ST'] = '-L-L%s'
  49. v['LINKFLAGS_dprogram']= ['-quiet']
  50. v['DFLAGS_dshlib'] = ['-fPIC']
  51. v['LINKFLAGS_dshlib'] = ['-L-shared']
  52. v['DHEADER_ext'] = '.di'
  53. v.DFLAGS_d_with_header = ['-H', '-Hf']
  54. v['D_HDR_F'] = '%s'
  55. def configure(conf):
  56. """
  57. Configuration for *dmd*, *dmd2*, and *ldc*
  58. """
  59. conf.find_dmd()
  60. if sys.platform == 'win32':
  61. out = conf.cmd_and_log(conf.env.D + ['--help'])
  62. if out.find("D Compiler v2.") > -1:
  63. conf.fatal('dmd2 on Windows is not supported, use gdc or ldc2 instead')
  64. conf.load('ar')
  65. conf.load('d')
  66. conf.common_flags_dmd()
  67. conf.d_platform_flags()
  68. if str(conf.env.D).find('ldc') > -1:
  69. conf.common_flags_ldc()