mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-25 11:19:52 +01:00
Support pure clang-cl builds on not Windows
A.k.a. I just tested it on Linux.
This commit is contained in:
parent
7310ade7c3
commit
32c2a49bf0
@ -4,7 +4,7 @@
|
||||
|
||||
"Process *.rc* files for C/C++: X{.rc -> [.res|.rc.o]}"
|
||||
|
||||
import re
|
||||
import re, sys
|
||||
from waflib import Task
|
||||
from waflib.TaskGen import extension
|
||||
from waflib.Tools import c_preproc
|
||||
@ -68,7 +68,21 @@ def configure(conf):
|
||||
v = conf.env
|
||||
if not v.WINRC:
|
||||
if v.CC_NAME == 'msvc':
|
||||
conf.find_program('RC', var='WINRC', path_list=v.PATH)
|
||||
if sys.platform == 'win32':
|
||||
conf.find_program('RC', var='WINRC', path_list=v.PATH)
|
||||
else:
|
||||
llvm_env_path = conf.environ.get('LLVM_PATH')
|
||||
llvm_path = None
|
||||
if llvm_env_path:
|
||||
llvm_path = llvm_env_path
|
||||
elif 'LLVM_PATH' in v:
|
||||
llvm_path = v['LLVM_PATH']
|
||||
|
||||
paths = v.PATH
|
||||
if llvm_path:
|
||||
paths = [llvm_path] + v.PATH
|
||||
conf.find_program('llvm-rc', var='WINRC', path_list=paths)
|
||||
|
||||
v.WINRC_TGT_F = '/fo'
|
||||
v.WINRC_SRC_F = ''
|
||||
else:
|
||||
|
@ -24,7 +24,7 @@ Or:
|
||||
|
||||
import sys, os
|
||||
|
||||
from waflib import Utils
|
||||
from waflib import Utils, Errors, Logs
|
||||
from waflib.Configure import conf
|
||||
|
||||
def options(opt):
|
||||
@ -71,11 +71,67 @@ def find_clang_cl(conf):
|
||||
v.CC = v.CXX = cc
|
||||
v.CC_NAME_SECONDARY = v.CXX_NAME_SECONDARY = 'clang'
|
||||
|
||||
if sys.platform != 'win32':
|
||||
v.MSVC_COMPILER = 'msvc'
|
||||
v.MSVC_VERSION = 19
|
||||
|
||||
if not v.LINK_CXX:
|
||||
conf.find_program( \
|
||||
'lld-link', \
|
||||
path_list=paths, \
|
||||
errmsg='lld-link was not found (linker)', \
|
||||
var='LINK_CXX')
|
||||
|
||||
if not v.LINK_CC:
|
||||
v.LINK_CC = v.LINK_CXX
|
||||
|
||||
@conf
|
||||
def find_llvm_tools(conf):
|
||||
"""
|
||||
Find the librarian, manifest tool, and resource compiler.
|
||||
"""
|
||||
|
||||
v = conf.env
|
||||
|
||||
v.CC_NAME = v.CXX_NAME = 'msvc'
|
||||
|
||||
llvm_env_path = conf.environ.get('LLVM_PATH')
|
||||
llvm_path = None
|
||||
if llvm_env_path:
|
||||
llvm_path = llvm_env_path
|
||||
elif 'LLVM_PATH' in v:
|
||||
llvm_path = v['LLVM_PATH']
|
||||
|
||||
paths = v.PATH
|
||||
if llvm_path:
|
||||
paths = [llvm_path] + v.PATH
|
||||
|
||||
if not v.AR:
|
||||
stliblink = conf.find_program('llvm-lib', path_list=paths, var='AR')
|
||||
if not stliblink:
|
||||
conf.fatal('Unable to find required program "llvm-lib"')
|
||||
|
||||
v.ARFLAGS = ['/nologo']
|
||||
|
||||
# We assume clang_cl to only be used with relatively new MSVC installations.
|
||||
v.MSVC_MANIFEST = True
|
||||
conf.find_program('llvm-mt', path_list=paths, var='MT')
|
||||
v.MTFLAGS = ['/nologo']
|
||||
|
||||
try:
|
||||
conf.load('winres')
|
||||
except Errors.ConfigurationError:
|
||||
Logs.warn('Resource compiler not found. Compiling resource file is disabled')
|
||||
|
||||
def configure(conf):
|
||||
from waflib.Tools.msvc import autodetect, find_msvc, msvc_common_flags
|
||||
|
||||
conf.autodetect(True)
|
||||
conf.find_msvc()
|
||||
if sys.platform == 'win32':
|
||||
conf.autodetect(True)
|
||||
conf.find_msvc()
|
||||
else:
|
||||
conf.find_llvm_tools()
|
||||
|
||||
conf.find_clang_cl()
|
||||
conf.msvc_common_flags()
|
||||
conf.cc_load_tools()
|
||||
|
Loading…
Reference in New Issue
Block a user