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