Blame third_party/waf/waflib/extras/clangxx_cross.py

rpm-build 95f51c
#!/usr/bin/env python
rpm-build 95f51c
# encoding: utf-8
rpm-build 95f51c
# Thomas Nagy 2009-2018 (ita)
rpm-build 95f51c
# DragoonX6 2018
rpm-build 95f51c
rpm-build 95f51c
"""
rpm-build 95f51c
Detect the Clang++ C++ compiler
rpm-build 95f51c
This version is an attempt at supporting the -target and -sysroot flag of Clang++.
rpm-build 95f51c
"""
rpm-build 95f51c
rpm-build 95f51c
from waflib.Tools import ccroot, ar, gxx
rpm-build 95f51c
from waflib.Configure import conf
rpm-build 95f51c
import waflib.extras.clang_cross_common
rpm-build 95f51c
rpm-build 95f51c
def options(opt):
rpm-build 95f51c
	"""
rpm-build 95f51c
	Target triplet for clang++::
rpm-build 95f51c
			$ waf configure --clangxx-target-triple=x86_64-pc-linux-gnu
rpm-build 95f51c
	"""
rpm-build 95f51c
	cxx_compiler_opts = opt.add_option_group('Configuration options')
rpm-build 95f51c
	cxx_compiler_opts.add_option('--clangxx-target-triple', default=None,
rpm-build 95f51c
		help='Target triple for clang++',
rpm-build 95f51c
		dest='clangxx_target_triple')
rpm-build 95f51c
	cxx_compiler_opts.add_option('--clangxx-sysroot', default=None,
rpm-build 95f51c
		help='Sysroot for clang++',
rpm-build 95f51c
		dest='clangxx_sysroot')
rpm-build 95f51c
rpm-build 95f51c
@conf
rpm-build 95f51c
def find_clangxx(conf):
rpm-build 95f51c
	"""
rpm-build 95f51c
	Finds the program clang++, and executes it to ensure it really is clang++
rpm-build 95f51c
	"""
rpm-build 95f51c
rpm-build 95f51c
	import os
rpm-build 95f51c
rpm-build 95f51c
	cxx = conf.find_program('clang++', var='CXX')
rpm-build 95f51c
rpm-build 95f51c
	if conf.options.clangxx_target_triple != None:
rpm-build 95f51c
		conf.env.append_value('CXX', ['-target', conf.options.clangxx_target_triple])
rpm-build 95f51c
rpm-build 95f51c
	if conf.options.clangxx_sysroot != None:
rpm-build 95f51c
		sysroot = str()
rpm-build 95f51c
rpm-build 95f51c
		if os.path.isabs(conf.options.clangxx_sysroot):
rpm-build 95f51c
			sysroot = conf.options.clangxx_sysroot
rpm-build 95f51c
		else:
rpm-build 95f51c
			sysroot = os.path.normpath(os.path.join(os.getcwd(), conf.options.clangxx_sysroot))
rpm-build 95f51c
rpm-build 95f51c
		conf.env.append_value('CXX', ['--sysroot', sysroot])
rpm-build 95f51c
rpm-build 95f51c
	conf.get_cc_version(cxx, clang=True)
rpm-build 95f51c
	conf.env.CXX_NAME = 'clang'
rpm-build 95f51c
rpm-build 95f51c
@conf
rpm-build 95f51c
def clangxx_modifier_x86_64_w64_mingw32(conf):
rpm-build 95f51c
	conf.gcc_modifier_win32()
rpm-build 95f51c
rpm-build 95f51c
@conf
rpm-build 95f51c
def clangxx_modifier_i386_w64_mingw32(conf):
rpm-build 95f51c
	conf.gcc_modifier_win32()
rpm-build 95f51c
rpm-build 95f51c
@conf
rpm-build 95f51c
def clangxx_modifier_msvc(conf):
rpm-build 95f51c
	v = conf.env
rpm-build 95f51c
	v.cxxprogram_PATTERN = v.cprogram_PATTERN
rpm-build 95f51c
	v.cxxshlib_PATTERN   = v.cshlib_PATTERN
rpm-build 95f51c
rpm-build 95f51c
	v.CXXFLAGS_cxxshlib  = []
rpm-build 95f51c
	v.LINKFLAGS_cxxshlib = v.LINKFLAGS_cshlib
rpm-build 95f51c
	v.cxxstlib_PATTERN   = v.cstlib_PATTERN
rpm-build 95f51c
rpm-build 95f51c
	v.LINK_CXX           = v.CXX + ['-fuse-ld=lld', '-nostdlib']
rpm-build 95f51c
	v.CXXLNK_TGT_F       = v.CCLNK_TGT_F
rpm-build 95f51c
rpm-build 95f51c
@conf
rpm-build 95f51c
def clangxx_modifier_x86_64_windows_msvc(conf):
rpm-build 95f51c
	conf.clang_modifier_msvc()
rpm-build 95f51c
	conf.clangxx_modifier_msvc()
rpm-build 95f51c
rpm-build 95f51c
	# Allow the user to override any flags if they so desire.
rpm-build 95f51c
	clang_modifier_user_func = getattr(conf, 'clangxx_modifier_x86_64_windows_msvc_user', None)
rpm-build 95f51c
	if clang_modifier_user_func:
rpm-build 95f51c
		clang_modifier_user_func()
rpm-build 95f51c
rpm-build 95f51c
@conf
rpm-build 95f51c
def clangxx_modifier_i386_windows_msvc(conf):
rpm-build 95f51c
	conf.clang_modifier_msvc()
rpm-build 95f51c
	conf.clangxx_modifier_msvc()
rpm-build 95f51c
rpm-build 95f51c
	# Allow the user to override any flags if they so desire.
rpm-build 95f51c
	clang_modifier_user_func = getattr(conf, 'clangxx_modifier_i386_windows_msvc_user', None)
rpm-build 95f51c
	if clang_modifier_user_func:
rpm-build 95f51c
		clang_modifier_user_func()
rpm-build 95f51c
rpm-build 95f51c
def configure(conf):
rpm-build 95f51c
	conf.find_clangxx()
rpm-build 95f51c
	conf.find_program(['llvm-ar', 'ar'], var='AR')
rpm-build 95f51c
	conf.find_ar()
rpm-build 95f51c
	conf.gxx_common_flags()
rpm-build 95f51c
	# Allow the user to provide flags for the target platform.
rpm-build 95f51c
	conf.gxx_modifier_platform()
rpm-build 95f51c
	# And allow more fine grained control based on the compiler's triplet.
rpm-build 95f51c
	conf.clang_modifier_target_triple(cpp=True)
rpm-build 95f51c
	conf.cxx_load_tools()
rpm-build 95f51c
	conf.cxx_add_flags()
rpm-build 95f51c
	conf.link_add_flags()