2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-25 19:30:04 +01:00

Add simple compiler tools for clang and clang++

This commit is contained in:
Krzysztof Kosiński 2014-01-25 21:00:27 +01:00
parent 30bdee769b
commit e95b150c56
3 changed files with 64 additions and 2 deletions

View File

@ -1039,7 +1039,7 @@ def cxx_load_tools(conf):
conf.load('cxx')
@conf
def get_cc_version(conf, cc, gcc=False, icc=False):
def get_cc_version(conf, cc, gcc=False, icc=False, clang=False):
"""
Run the preprocessor to determine the compiler version
@ -1066,8 +1066,11 @@ def get_cc_version(conf, cc, gcc=False, icc=False):
if icc and out.find('__INTEL_COMPILER') < 0:
conf.fatal('Not icc/icpc')
if clang and out.find('__clang__') < 0:
conf.fatal('Not clang/clang++')
k = {}
if icc or gcc:
if icc or gcc or clang:
out = out.splitlines()
for line in out:
lst = shlex.split(line)

29
waflib/Tools/clang.py Normal file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env python
# encoding: utf-8
# Krzysztof Kosiński 2014
"""
Detect the Clang C compiler
"""
import os, sys
from waflib.Tools import ccroot, ar, gcc
from waflib.Configure import conf
@conf
def find_clang(conf):
"""
Find the program clang and execute it to ensure it really is clang
"""
cc = conf.find_program('clang', var='CC')
conf.get_cc_version(cc, clang=True)
conf.env.CC_NAME = 'clang'
def configure(conf):
conf.find_clang()
conf.find_ar()
conf.gcc_common_flags()
conf.gcc_modifier_platform()
conf.cc_load_tools()
conf.cc_add_flags()
conf.link_add_flags()

30
waflib/Tools/clangxx.py Normal file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env python
# encoding: utf-8
# Thomas Nagy 2009-2010 (ita)
"""
Detect the Clang++ C++ compiler
"""
import os, sys
from waflib.Tools import ccroot, ar, gxx
from waflib.Configure import conf
@conf
def find_clangxx(conf):
"""
Find the program clang++, and execute it to ensure it really is clang++
"""
cxx = conf.find_program('clang++', var='CXX')
conf.get_cc_version(cxx, clang=True)
conf.env.CXX_NAME = 'clang'
def configure(conf):
conf.find_clangxx()
conf.find_ar()
conf.gxx_common_flags()
conf.gxx_modifier_platform()
conf.cxx_load_tools()
conf.cxx_add_flags()
conf.link_add_flags()