d_config.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Thomas Nagy, 2016-2018 (ita)
  4. from waflib import Utils
  5. from waflib.Configure import conf
  6. @conf
  7. def d_platform_flags(self):
  8. """
  9. Sets the extensions dll/so for d programs and libraries
  10. """
  11. v = self.env
  12. if not v.DEST_OS:
  13. v.DEST_OS = Utils.unversioned_sys_platform()
  14. binfmt = Utils.destos_to_binfmt(self.env.DEST_OS)
  15. if binfmt == 'pe':
  16. v.dprogram_PATTERN = '%s.exe'
  17. v.dshlib_PATTERN = 'lib%s.dll'
  18. v.dstlib_PATTERN = 'lib%s.a'
  19. elif binfmt == 'mac-o':
  20. v.dprogram_PATTERN = '%s'
  21. v.dshlib_PATTERN = 'lib%s.dylib'
  22. v.dstlib_PATTERN = 'lib%s.a'
  23. else:
  24. v.dprogram_PATTERN = '%s'
  25. v.dshlib_PATTERN = 'lib%s.so'
  26. v.dstlib_PATTERN = 'lib%s.a'
  27. DLIB = '''
  28. version(D_Version2) {
  29. import std.stdio;
  30. int main() {
  31. writefln("phobos2");
  32. return 0;
  33. }
  34. } else {
  35. version(Tango) {
  36. import tango.stdc.stdio;
  37. int main() {
  38. printf("tango");
  39. return 0;
  40. }
  41. } else {
  42. import std.stdio;
  43. int main() {
  44. writefln("phobos1");
  45. return 0;
  46. }
  47. }
  48. }
  49. '''
  50. """Detection string for the D standard library"""
  51. @conf
  52. def check_dlibrary(self, execute=True):
  53. """
  54. Detects the kind of standard library that comes with the compiler,
  55. and sets conf.env.DLIBRARY to tango, phobos1 or phobos2
  56. """
  57. ret = self.check_cc(features='d dprogram', fragment=DLIB, compile_filename='test.d', execute=execute, define_ret=True)
  58. if execute:
  59. self.env.DLIBRARY = ret.strip()