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.

93 lines
2.5KB

  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Krzysztof KosiƄski 2014
  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, gcc
  10. from waflib.Configure import conf
  11. import waflib.Context
  12. import waflib.extras.clang_cross_common
  13. def options(opt):
  14. """
  15. Target triplet for clang::
  16. $ waf configure --clang-target-triple=x86_64-pc-linux-gnu
  17. """
  18. cc_compiler_opts = opt.add_option_group('Configuration options')
  19. cc_compiler_opts.add_option('--clang-target-triple', default=None,
  20. help='Target triple for clang',
  21. dest='clang_target_triple')
  22. cc_compiler_opts.add_option('--clang-sysroot', default=None,
  23. help='Sysroot for clang',
  24. dest='clang_sysroot')
  25. @conf
  26. def find_clang(conf):
  27. """
  28. Finds the program clang and executes it to ensure it really is clang
  29. """
  30. import os
  31. cc = conf.find_program('clang', var='CC')
  32. if conf.options.clang_target_triple != None:
  33. conf.env.append_value('CC', ['-target', conf.options.clang_target_triple])
  34. if conf.options.clang_sysroot != None:
  35. sysroot = str()
  36. if os.path.isabs(conf.options.clang_sysroot):
  37. sysroot = conf.options.clang_sysroot
  38. else:
  39. sysroot = os.path.normpath(os.path.join(os.getcwd(), conf.options.clang_sysroot))
  40. conf.env.append_value('CC', ['--sysroot', sysroot])
  41. conf.get_cc_version(cc, clang=True)
  42. conf.env.CC_NAME = 'clang'
  43. @conf
  44. def clang_modifier_x86_64_w64_mingw32(conf):
  45. conf.gcc_modifier_win32()
  46. @conf
  47. def clang_modifier_i386_w64_mingw32(conf):
  48. conf.gcc_modifier_win32()
  49. @conf
  50. def clang_modifier_x86_64_windows_msvc(conf):
  51. conf.clang_modifier_msvc()
  52. # Allow the user to override any flags if they so desire.
  53. clang_modifier_user_func = getattr(conf, 'clang_modifier_x86_64_windows_msvc_user', None)
  54. if clang_modifier_user_func:
  55. clang_modifier_user_func()
  56. @conf
  57. def clang_modifier_i386_windows_msvc(conf):
  58. conf.clang_modifier_msvc()
  59. # Allow the user to override any flags if they so desire.
  60. clang_modifier_user_func = getattr(conf, 'clang_modifier_i386_windows_msvc_user', None)
  61. if clang_modifier_user_func:
  62. clang_modifier_user_func()
  63. def configure(conf):
  64. conf.find_clang()
  65. conf.find_program(['llvm-ar', 'ar'], var='AR')
  66. conf.find_ar()
  67. conf.gcc_common_flags()
  68. # Allow the user to provide flags for the target platform.
  69. conf.gcc_modifier_platform()
  70. # And allow more fine grained control based on the compiler's triplet.
  71. conf.clang_modifier_target_triple()
  72. conf.cc_load_tools()
  73. conf.cc_add_flags()
  74. conf.link_add_flags()