ldc2.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Alex Rønne Petersen, 2012 (alexrp/Zor)
  4. from waflib.Tools import ar, d
  5. from waflib.Configure import conf
  6. @conf
  7. def find_ldc2(conf):
  8. """
  9. Finds the program *ldc2* and set the variable *D*
  10. """
  11. conf.find_program(['ldc2'], var='D')
  12. out = conf.cmd_and_log(conf.env.D + ['-version'])
  13. if out.find("based on DMD v2.") == -1:
  14. conf.fatal("detected compiler is not ldc2")
  15. @conf
  16. def common_flags_ldc2(conf):
  17. """
  18. Sets the D flags required by *ldc2*
  19. """
  20. v = conf.env
  21. v.D_SRC_F = ['-c']
  22. v.D_TGT_F = '-of%s'
  23. v.D_LINKER = v.D
  24. v.DLNK_SRC_F = ''
  25. v.DLNK_TGT_F = '-of%s'
  26. v.DINC_ST = '-I%s'
  27. v.DSHLIB_MARKER = v.DSTLIB_MARKER = ''
  28. v.DSTLIB_ST = v.DSHLIB_ST = '-L-l%s'
  29. v.DSTLIBPATH_ST = v.DLIBPATH_ST = '-L-L%s'
  30. v.LINKFLAGS_dshlib = ['-L-shared']
  31. v.DHEADER_ext = '.di'
  32. v.DFLAGS_d_with_header = ['-H', '-Hf']
  33. v.D_HDR_F = '%s'
  34. v.LINKFLAGS = []
  35. v.DFLAGS_dshlib = ['-relocation-model=pic']
  36. def configure(conf):
  37. """
  38. Configuration for *ldc2*
  39. """
  40. conf.find_ldc2()
  41. conf.load('ar')
  42. conf.load('d')
  43. conf.common_flags_ldc2()
  44. conf.d_platform_flags()