mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-22 01:46:15 +01:00
Improve extras/clang_cl
This commit is contained in:
parent
e3c275a96a
commit
52a49960c1
@ -4,8 +4,8 @@
|
||||
|
||||
"Process *.rc* files for C/C++: X{.rc -> [.res|.rc.o]}"
|
||||
|
||||
import re, sys
|
||||
from waflib import Task
|
||||
import re
|
||||
from waflib import Task, Utils
|
||||
from waflib.TaskGen import extension
|
||||
from waflib.Tools import c_preproc
|
||||
|
||||
@ -68,7 +68,7 @@ def configure(conf):
|
||||
v = conf.env
|
||||
if not v.WINRC:
|
||||
if v.CC_NAME == 'msvc':
|
||||
if sys.platform == 'win32':
|
||||
if Utils.is_win32:
|
||||
conf.find_program('RC', var='WINRC', path_list=v.PATH)
|
||||
else:
|
||||
llvm_env_path = conf.environ.get('LLVM_PATH')
|
||||
|
@ -10,15 +10,14 @@ well as a cross compiler for Windows from Linux (provided you have set up the
|
||||
environment). Requires Visual Studio 2015+ to be installed.
|
||||
|
||||
On Windows it uses (most) MSVC tools.
|
||||
See waflib/Tools/msvc.py and waflib/Tools/msvc_common.py for more details.
|
||||
|
||||
Usage:
|
||||
$ waf configure
|
||||
Or:
|
||||
$ LLVM_PATH=C:\Program Files\LLVM\bin waf configure
|
||||
$ LLVM_PATH=C:\\Program Files\\LLVM\\bin waf configure
|
||||
Or:
|
||||
def configure(conf):
|
||||
conf.env.LLVM_PATH = 'C:\Program Files\LLVM\bin'
|
||||
conf.env.LLVM_PATH = 'C:\\Program Files\\LLVM\\bin'
|
||||
conf.load('clang_cl')
|
||||
"""
|
||||
|
||||
@ -26,97 +25,74 @@ import sys, os
|
||||
|
||||
from waflib import Utils, Errors, Logs
|
||||
from waflib.Configure import conf
|
||||
from waflib.Tools import msvc
|
||||
|
||||
def options(opt):
|
||||
from waflib.Tools.msvc import options as msvc_opt
|
||||
msvc_opt(opt)
|
||||
msvc.options(opt)
|
||||
|
||||
@conf
|
||||
def find_clang_cl(conf):
|
||||
"""
|
||||
Find the program clang-cl.
|
||||
"""
|
||||
del(conf.env.CC)
|
||||
del(conf.env.CXX)
|
||||
|
||||
v = conf.env
|
||||
llvm_path = None
|
||||
|
||||
del(v.CC)
|
||||
del(v.CXX)
|
||||
|
||||
llvm_path = str()
|
||||
|
||||
if sys.platform == 'win32':
|
||||
if Utils.is_win32:
|
||||
try:
|
||||
llvm_key = Utils.winreg.OpenKey( \
|
||||
Utils.winreg.HKEY_LOCAL_MACHINE, \
|
||||
'SOFTWARE\\Wow6432Node\\LLVM\\LLVM')
|
||||
llvm_key = Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE,'SOFTWARE\\Wow6432Node\\LLVM\\LLVM')
|
||||
except OSError:
|
||||
llvm_key = Utils.winreg.OpenKey( \
|
||||
Utils.winreg.HKEY_LOCAL_MACHINE, \
|
||||
'SOFTWARE\\LLVM\\LLVM')
|
||||
llvm_key = Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\LLVM\\LLVM')
|
||||
|
||||
llvm_path,type = Utils.winreg.QueryValueEx(llvm_key, '')
|
||||
llvm_path = os.path.join(llvm_path, 'bin')
|
||||
|
||||
llvm_env_path = conf.environ.get('LLVM_PATH')
|
||||
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 != 'bin' and llvm_path != str():
|
||||
paths = [llvm_path] + v.PATH
|
||||
llvm_path = conf.environ.get('LLVM_PATH') or conf.env.LLVM_PATH
|
||||
if llvm_path and llvm_path != 'bin':
|
||||
paths = [llvm_path] + conf.env.PATH
|
||||
else:
|
||||
paths = conf.env.PATH
|
||||
|
||||
cc = conf.find_program('clang-cl', var='CC', path_list=paths)
|
||||
v.CC = v.CXX = cc
|
||||
v.CC_NAME_SECONDARY = v.CXX_NAME_SECONDARY = 'clang'
|
||||
conf.env.CC = conf.env.CXX = cc
|
||||
conf.env.CC_NAME_SECONDARY = conf.env.CXX_NAME_SECONDARY = 'clang'
|
||||
|
||||
if sys.platform != 'win32':
|
||||
v.MSVC_COMPILER = 'msvc'
|
||||
v.MSVC_VERSION = 19
|
||||
if not Utils.is_win32:
|
||||
conf.env.MSVC_COMPILER = 'msvc'
|
||||
conf.env.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 conf.env.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
|
||||
if not conf.env.LINK_CC:
|
||||
conf.env.LINK_CC = conf.env.LINK_CXX
|
||||
|
||||
@conf
|
||||
def find_llvm_tools(conf):
|
||||
"""
|
||||
Find the librarian, manifest tool, and resource compiler.
|
||||
"""
|
||||
conf.env.CC_NAME = conf.env.CXX_NAME = 'msvc'
|
||||
|
||||
v = conf.env
|
||||
llvm_path = conf.environ.get('LLVM_PATH') or conf.env.LLVM_PATH
|
||||
if llvm_path and llvm_path != 'bin':
|
||||
paths = [llvm_path] + conf.env.PATH
|
||||
else:
|
||||
paths = conf.env.PATH
|
||||
|
||||
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:
|
||||
if not conf.env.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']
|
||||
conf.env.ARFLAGS = ['/nologo']
|
||||
|
||||
# We assume clang_cl to only be used with relatively new MSVC installations.
|
||||
v.MSVC_MANIFEST = True
|
||||
conf.env.MSVC_MANIFEST = True
|
||||
conf.find_program('llvm-mt', path_list=paths, var='MT')
|
||||
v.MTFLAGS = ['/nologo']
|
||||
conf.env.MTFLAGS = ['/nologo']
|
||||
|
||||
try:
|
||||
conf.load('winres')
|
||||
@ -124,8 +100,6 @@ def find_llvm_tools(conf):
|
||||
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
|
||||
|
||||
if sys.platform == 'win32':
|
||||
conf.autodetect(True)
|
||||
conf.find_msvc()
|
||||
|
Loading…
Reference in New Issue
Block a user