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.

107 lines
2.9KB

  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Thomas Nagy 2009-2018 (ita)
  4. # DragoonX6 2018
  5. """
  6. Detect the Clang++ C++ compiler
  7. This version is an attempt at supporting the -target and -sysroot flag of Clang++.
  8. """
  9. from waflib.Tools import ccroot, ar, gxx
  10. from waflib.Configure import conf
  11. import waflib.extras.clang_cross_common
  12. def options(opt):
  13. """
  14. Target triplet for clang++::
  15. $ waf configure --clangxx-target-triple=x86_64-pc-linux-gnu
  16. """
  17. cxx_compiler_opts = opt.add_option_group('Configuration options')
  18. cxx_compiler_opts.add_option('--clangxx-target-triple', default=None,
  19. help='Target triple for clang++',
  20. dest='clangxx_target_triple')
  21. cxx_compiler_opts.add_option('--clangxx-sysroot', default=None,
  22. help='Sysroot for clang++',
  23. dest='clangxx_sysroot')
  24. @conf
  25. def find_clangxx(conf):
  26. """
  27. Finds the program clang++, and executes it to ensure it really is clang++
  28. """
  29. import os
  30. cxx = conf.find_program('clang++', var='CXX')
  31. if conf.options.clangxx_target_triple != None:
  32. conf.env.append_value('CXX', ['-target', conf.options.clangxx_target_triple])
  33. if conf.options.clangxx_sysroot != None:
  34. sysroot = str()
  35. if os.path.isabs(conf.options.clangxx_sysroot):
  36. sysroot = conf.options.clangxx_sysroot
  37. else:
  38. sysroot = os.path.normpath(os.path.join(os.getcwd(), conf.options.clangxx_sysroot))
  39. conf.env.append_value('CXX', ['--sysroot', sysroot])
  40. conf.get_cc_version(cxx, clang=True)
  41. conf.env.CXX_NAME = 'clang'
  42. @conf
  43. def clangxx_modifier_x86_64_w64_mingw32(conf):
  44. conf.gcc_modifier_win32()
  45. @conf
  46. def clangxx_modifier_i386_w64_mingw32(conf):
  47. conf.gcc_modifier_win32()
  48. @conf
  49. def clangxx_modifier_msvc(conf):
  50. v = conf.env
  51. v.cxxprogram_PATTERN = v.cprogram_PATTERN
  52. v.cxxshlib_PATTERN = v.cshlib_PATTERN
  53. v.CXXFLAGS_cxxshlib = []
  54. v.LINKFLAGS_cxxshlib = v.LINKFLAGS_cshlib
  55. v.cxxstlib_PATTERN = v.cstlib_PATTERN
  56. v.LINK_CXX = v.CXX + ['-fuse-ld=lld', '-nostdlib']
  57. v.CXXLNK_TGT_F = v.CCLNK_TGT_F
  58. @conf
  59. def clangxx_modifier_x86_64_windows_msvc(conf):
  60. conf.clang_modifier_msvc()
  61. conf.clangxx_modifier_msvc()
  62. # Allow the user to override any flags if they so desire.
  63. clang_modifier_user_func = getattr(conf, 'clangxx_modifier_x86_64_windows_msvc_user', None)
  64. if clang_modifier_user_func:
  65. clang_modifier_user_func()
  66. @conf
  67. def clangxx_modifier_i386_windows_msvc(conf):
  68. conf.clang_modifier_msvc()
  69. conf.clangxx_modifier_msvc()
  70. # Allow the user to override any flags if they so desire.
  71. clang_modifier_user_func = getattr(conf, 'clangxx_modifier_i386_windows_msvc_user', None)
  72. if clang_modifier_user_func:
  73. clang_modifier_user_func()
  74. def configure(conf):
  75. conf.find_clangxx()
  76. conf.find_program(['llvm-ar', 'ar'], var='AR')
  77. conf.find_ar()
  78. conf.gxx_common_flags()
  79. # Allow the user to provide flags for the target platform.
  80. conf.gxx_modifier_platform()
  81. # And allow more fine grained control based on the compiler's triplet.
  82. conf.clang_modifier_target_triple(cpp=True)
  83. conf.cxx_load_tools()
  84. conf.cxx_add_flags()
  85. conf.link_add_flags()