2011-09-10 11:13:51 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
# Carlos Rafael Giani, 2006 (dv)
|
|
|
|
# Tamas Pal, 2007 (folti)
|
|
|
|
# Nicolas Mercier, 2009
|
2012-12-10 11:24:15 +01:00
|
|
|
# Matt Clarkson, 2012
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
"""
|
|
|
|
Microsoft Visual C++/Intel C++ compiler support
|
|
|
|
|
2018-05-08 23:43:59 +02:00
|
|
|
If you get detection problems, first try any of the following::
|
|
|
|
|
|
|
|
chcp 65001
|
2018-05-09 07:17:42 +02:00
|
|
|
set PYTHONIOENCODING=...
|
2018-05-08 23:43:59 +02:00
|
|
|
set PYTHONLEGACYWINDOWSSTDIO=1
|
|
|
|
|
2011-09-10 11:13:51 +02:00
|
|
|
Usage::
|
|
|
|
|
|
|
|
$ waf configure --msvc_version="msvc 10.0,msvc 9.0" --msvc_target="x64"
|
|
|
|
|
|
|
|
or::
|
|
|
|
|
|
|
|
def configure(conf):
|
2016-06-25 23:54:12 +02:00
|
|
|
conf.env.MSVC_VERSIONS = ['msvc 10.0', 'msvc 9.0', 'msvc 8.0', 'msvc 7.1', 'msvc 7.0', 'msvc 6.0', 'wsdk 7.0', 'intel 11', 'PocketPC 9.0', 'Smartphone 8.0']
|
|
|
|
conf.env.MSVC_TARGETS = ['x64']
|
2011-09-10 11:13:51 +02:00
|
|
|
conf.load('msvc')
|
|
|
|
|
|
|
|
or::
|
|
|
|
|
|
|
|
def configure(conf):
|
|
|
|
conf.load('msvc', funs='no_autodetect')
|
|
|
|
conf.check_lib_msvc('gdi32')
|
|
|
|
conf.check_libs_msvc('kernel32 user32')
|
|
|
|
def build(bld):
|
|
|
|
tg = bld.program(source='main.c', target='app', use='KERNEL32 USER32 GDI32')
|
|
|
|
|
|
|
|
Platforms and targets will be tested in the order they appear;
|
|
|
|
the first good configuration will be used.
|
2015-09-01 04:06:34 +02:00
|
|
|
|
2015-12-25 19:28:29 +01:00
|
|
|
To force testing all the configurations that are not used, use the ``--no-msvc-lazy`` option
|
2016-06-25 23:54:12 +02:00
|
|
|
or set ``conf.env.MSVC_LAZY_AUTODETECT=False``.
|
2015-09-01 04:06:34 +02:00
|
|
|
|
2015-03-16 21:24:22 +01:00
|
|
|
Supported platforms: ia64, x64, x86, x86_amd64, x86_ia64, x86_arm, amd64_x86, amd64_arm
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
Compilers supported:
|
|
|
|
|
2017-08-05 23:15:50 +02:00
|
|
|
* msvc => Visual Studio, versions 6.0 (VC 98, VC .NET 2002) to 15 (Visual Studio 2017)
|
2013-02-17 14:09:32 +01:00
|
|
|
* wsdk => Windows SDK, versions 6.0, 6.1, 7.0, 7.1, 8.0
|
2012-12-10 11:24:15 +01:00
|
|
|
* icl => Intel compiler, versions 9, 10, 11, 13
|
2013-02-17 14:09:32 +01:00
|
|
|
* winphone => Visual Studio to target Windows Phone 8 native (version 8.0 for now)
|
2011-09-10 11:13:51 +02:00
|
|
|
* Smartphone => Compiler/SDK for Smartphone devices (armv4/v4i)
|
|
|
|
* PocketPC => Compiler/SDK for PocketPC devices (armv4/v4i)
|
|
|
|
|
|
|
|
To use WAF in a VS2008 Make file project (see http://code.google.com/p/waf/issues/detail?id=894)
|
|
|
|
You may consider to set the environment variable "VS_UNICODE_OUTPUT" to nothing before calling waf.
|
|
|
|
So in your project settings use something like 'cmd.exe /C "set VS_UNICODE_OUTPUT=& set PYTHONUNBUFFERED=true & waf build"'.
|
|
|
|
cmd.exe /C "chcp 1252 & set PYTHONUNBUFFERED=true && set && waf configure"
|
|
|
|
Setting PYTHONUNBUFFERED gives the unbuffered output.
|
|
|
|
"""
|
|
|
|
|
2018-05-08 23:43:59 +02:00
|
|
|
import os, sys, re, traceback
|
2016-06-25 21:30:32 +02:00
|
|
|
from waflib import Utils, Logs, Options, Errors
|
2012-05-29 22:44:00 +02:00
|
|
|
from waflib.TaskGen import after_method, feature
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
from waflib.Configure import conf
|
2016-06-05 00:23:57 +02:00
|
|
|
from waflib.Tools import ccroot, c, cxx, ar
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
g_msvc_systemlibs = '''
|
|
|
|
aclui activeds ad1 adptif adsiid advapi32 asycfilt authz bhsupp bits bufferoverflowu cabinet
|
|
|
|
cap certadm certidl ciuuid clusapi comctl32 comdlg32 comsupp comsuppd comsuppw comsuppwd comsvcs
|
|
|
|
credui crypt32 cryptnet cryptui d3d8thk daouuid dbgeng dbghelp dciman32 ddao35 ddao35d
|
|
|
|
ddao35u ddao35ud delayimp dhcpcsvc dhcpsapi dlcapi dnsapi dsprop dsuiext dtchelp
|
|
|
|
faultrep fcachdll fci fdi framedyd framedyn gdi32 gdiplus glauxglu32 gpedit gpmuuid
|
|
|
|
gtrts32w gtrtst32hlink htmlhelp httpapi icm32 icmui imagehlp imm32 iphlpapi iprop
|
|
|
|
kernel32 ksguid ksproxy ksuser libcmt libcmtd libcpmt libcpmtd loadperf lz32 mapi
|
|
|
|
mapi32 mgmtapi minidump mmc mobsync mpr mprapi mqoa mqrt msacm32 mscms mscoree
|
|
|
|
msdasc msimg32 msrating mstask msvcmrt msvcurt msvcurtd mswsock msxml2 mtx mtxdm
|
|
|
|
netapi32 nmapinmsupp npptools ntdsapi ntdsbcli ntmsapi ntquery odbc32 odbcbcp
|
|
|
|
odbccp32 oldnames ole32 oleacc oleaut32 oledb oledlgolepro32 opends60 opengl32
|
|
|
|
osptk parser pdh penter pgobootrun pgort powrprof psapi ptrustm ptrustmd ptrustu
|
|
|
|
ptrustud qosname rasapi32 rasdlg rassapi resutils riched20 rpcndr rpcns4 rpcrt4 rtm
|
|
|
|
rtutils runtmchk scarddlg scrnsave scrnsavw secur32 sensapi setupapi sfc shell32
|
|
|
|
shfolder shlwapi sisbkup snmpapi sporder srclient sti strsafe svcguid tapi32 thunk32
|
|
|
|
traffic unicows url urlmon user32 userenv usp10 uuid uxtheme vcomp vcompd vdmdbg
|
|
|
|
version vfw32 wbemuuid webpost wiaguid wininet winmm winscard winspool winstrm
|
|
|
|
wintrust wldap32 wmiutils wow32 ws2_32 wsnmp32 wsock32 wst wtsapi32 xaswitch xolehlp
|
|
|
|
'''.split()
|
|
|
|
"""importlibs provided by MSVC/Platform SDK. Do NOT search them"""
|
|
|
|
|
2017-03-25 23:01:36 +01:00
|
|
|
all_msvc_platforms = [ ('x64', 'amd64'), ('x86', 'x86'), ('ia64', 'ia64'),
|
|
|
|
('x86_amd64', 'amd64'), ('x86_ia64', 'ia64'), ('x86_arm', 'arm'), ('x86_arm64', 'arm64'),
|
|
|
|
('amd64_x86', 'x86'), ('amd64_arm', 'arm'), ('amd64_arm64', 'arm64') ]
|
2011-09-10 11:13:51 +02:00
|
|
|
"""List of msvc platforms"""
|
|
|
|
|
|
|
|
all_wince_platforms = [ ('armv4', 'arm'), ('armv4i', 'arm'), ('mipsii', 'mips'), ('mipsii_fp', 'mips'), ('mipsiv', 'mips'), ('mipsiv_fp', 'mips'), ('sh4', 'sh'), ('x86', 'cex86') ]
|
|
|
|
"""List of wince platforms"""
|
|
|
|
|
|
|
|
all_icl_platforms = [ ('intel64', 'amd64'), ('em64t', 'amd64'), ('ia32', 'x86'), ('Itanium', 'ia64')]
|
|
|
|
"""List of icl platforms"""
|
|
|
|
|
|
|
|
def options(opt):
|
|
|
|
opt.add_option('--msvc_version', type='string', help = 'msvc version, eg: "msvc 10.0,msvc 9.0"', default='')
|
|
|
|
opt.add_option('--msvc_targets', type='string', help = 'msvc targets, eg: "x64,arm"', default='')
|
2016-01-02 01:04:08 +01:00
|
|
|
opt.add_option('--no-msvc-lazy', action='store_false', help = 'lazily check msvc target environments', default=True, dest='msvc_lazy')
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2018-05-08 23:43:59 +02:00
|
|
|
def cmd_encoding():
|
2018-05-08 22:55:19 +02:00
|
|
|
"""
|
|
|
|
Return the code page of the stdout/stderr corresponding with the current console.
|
|
|
|
Note that None of following method is useless, be careful especially
|
|
|
|
under DBCS/MBCS code page environments:
|
2018-05-08 23:43:59 +02:00
|
|
|
|
2018-05-08 22:55:19 +02:00
|
|
|
- locale.getpreferredencoding() or ctypes.windll.kernel32.GetACP()
|
2018-05-09 07:23:37 +02:00
|
|
|
- Return user's code page, not each consoles.
|
|
|
|
- both ignore `chcp 65001`.
|
2018-05-08 22:55:19 +02:00
|
|
|
|
|
|
|
- sys.stdout.encoding
|
2018-05-09 07:23:37 +02:00
|
|
|
- olways returns 'utf-8' in Python 3, not user's code page.
|
2018-05-08 23:43:59 +02:00
|
|
|
|
2018-05-09 07:23:37 +02:00
|
|
|
This is only meant for stdout/stderr, for stdin GetConsoleCP() should be used
|
|
|
|
instead of GetConsoleOutputCP().
|
2018-05-08 23:43:59 +02:00
|
|
|
|
2018-05-08 22:55:19 +02:00
|
|
|
:return: the string which represents the code page
|
|
|
|
:rtype: str
|
|
|
|
"""
|
2018-05-08 23:43:59 +02:00
|
|
|
try:
|
|
|
|
import ctypes
|
|
|
|
codepage = ctypes.windll.kernel32.GetConsoleOutputCP()
|
|
|
|
if codepage:
|
|
|
|
return 'cp%d' % codepage
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
return sys.stdout.encoding or 'cp1252'
|
2018-05-08 22:55:19 +02:00
|
|
|
|
2016-05-22 17:11:29 +02:00
|
|
|
@conf
|
2016-05-22 18:27:57 +02:00
|
|
|
def setup_msvc(conf, versiondict):
|
2015-08-31 20:55:15 +02:00
|
|
|
"""
|
|
|
|
Checks installed compilers and targets and returns the first combination from the user's
|
|
|
|
options, env, or the global supported lists that checks.
|
|
|
|
|
2016-05-22 18:27:57 +02:00
|
|
|
:param versiondict: dict(platform -> dict(architecture -> configuration))
|
|
|
|
:type versiondict: dict(string -> dict(string -> target_compiler)
|
|
|
|
:return: the compiler, revision, path, include dirs, library paths and target architecture
|
2015-08-31 20:55:15 +02:00
|
|
|
:rtype: tuple of strings
|
|
|
|
"""
|
2011-09-10 11:13:51 +02:00
|
|
|
platforms = getattr(Options.options, 'msvc_targets', '').split(',')
|
|
|
|
if platforms == ['']:
|
2016-06-25 23:54:12 +02:00
|
|
|
platforms=Utils.to_list(conf.env.MSVC_TARGETS) or [i for i,j in all_msvc_platforms+all_icl_platforms+all_wince_platforms]
|
2011-09-10 11:13:51 +02:00
|
|
|
desired_versions = getattr(Options.options, 'msvc_version', '').split(',')
|
|
|
|
if desired_versions == ['']:
|
2017-05-06 10:33:10 +02:00
|
|
|
desired_versions = conf.env.MSVC_VERSIONS or list(reversed(sorted(versiondict.keys())))
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2016-05-22 02:43:35 +02:00
|
|
|
# Override lazy detection by evaluating after the fact.
|
|
|
|
lazy_detect = getattr(Options.options, 'msvc_lazy', True)
|
2016-06-25 23:54:12 +02:00
|
|
|
if conf.env.MSVC_LAZY_AUTODETECT is False:
|
2016-05-22 02:43:35 +02:00
|
|
|
lazy_detect = False
|
|
|
|
|
|
|
|
if not lazy_detect:
|
2016-05-22 18:39:44 +02:00
|
|
|
for val in versiondict.values():
|
2016-05-22 18:27:57 +02:00
|
|
|
for arch in list(val.keys()):
|
|
|
|
cfg = val[arch]
|
|
|
|
cfg.evaluate()
|
|
|
|
if not cfg.is_valid:
|
|
|
|
del val[arch]
|
2016-06-25 23:54:12 +02:00
|
|
|
conf.env.MSVC_INSTALLED_VERSIONS = versiondict
|
2016-05-22 02:43:35 +02:00
|
|
|
|
2011-09-10 11:13:51 +02:00
|
|
|
for version in desired_versions:
|
2017-05-06 10:33:10 +02:00
|
|
|
Logs.debug('msvc: detecting %r - %r', version, desired_versions)
|
2011-09-10 11:13:51 +02:00
|
|
|
try:
|
2016-05-22 18:27:57 +02:00
|
|
|
targets = versiondict[version]
|
2016-05-22 02:43:35 +02:00
|
|
|
except KeyError:
|
|
|
|
continue
|
2017-05-06 10:33:10 +02:00
|
|
|
|
|
|
|
seen = set()
|
2016-05-22 18:27:57 +02:00
|
|
|
for arch in platforms:
|
2017-05-06 10:33:10 +02:00
|
|
|
if arch in seen:
|
|
|
|
continue
|
|
|
|
else:
|
|
|
|
seen.add(arch)
|
2016-05-22 03:07:44 +02:00
|
|
|
try:
|
2016-05-22 18:27:57 +02:00
|
|
|
cfg = targets[arch]
|
2016-05-22 03:07:44 +02:00
|
|
|
except KeyError:
|
|
|
|
continue
|
2017-05-06 10:33:10 +02:00
|
|
|
|
2016-05-22 03:07:44 +02:00
|
|
|
cfg.evaluate()
|
|
|
|
if cfg.is_valid:
|
|
|
|
compiler,revision = version.rsplit(' ', 1)
|
2016-05-22 12:40:51 +02:00
|
|
|
return compiler,revision,cfg.bindirs,cfg.incdirs,cfg.libdirs,cfg.cpu
|
2016-05-22 16:48:14 +02:00
|
|
|
conf.fatal('msvc: Impossible to find a valid architecture for building %r - %r' % (desired_versions, list(versiondict.keys())))
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
@conf
|
|
|
|
def get_msvc_version(conf, compiler, version, target, vcvars):
|
|
|
|
"""
|
2015-08-31 20:55:15 +02:00
|
|
|
Checks that an installed compiler actually runs and uses vcvars to obtain the
|
|
|
|
environment needed by the compiler.
|
|
|
|
|
|
|
|
:param compiler: compiler type, for looking up the executable name
|
|
|
|
:param version: compiler version, for debugging only
|
|
|
|
:param target: target architecture
|
|
|
|
:param vcvars: batch file to run to check the environment
|
|
|
|
:return: the location of the compiler executable, the location of include dirs, and the library paths
|
2011-09-10 11:13:51 +02:00
|
|
|
:rtype: tuple of strings
|
|
|
|
"""
|
2016-06-05 00:23:57 +02:00
|
|
|
Logs.debug('msvc: get_msvc_version: %r %r %r', compiler, version, target)
|
2014-02-26 07:24:47 +01:00
|
|
|
|
|
|
|
try:
|
|
|
|
conf.msvc_cnt += 1
|
|
|
|
except AttributeError:
|
|
|
|
conf.msvc_cnt = 1
|
|
|
|
batfile = conf.bldnode.make_node('waf-print-msvc-%d.bat' % conf.msvc_cnt)
|
2011-09-10 11:13:51 +02:00
|
|
|
batfile.write("""@echo off
|
|
|
|
set INCLUDE=
|
|
|
|
set LIB=
|
|
|
|
call "%s" %s
|
|
|
|
echo PATH=%%PATH%%
|
|
|
|
echo INCLUDE=%%INCLUDE%%
|
2013-02-17 14:09:32 +01:00
|
|
|
echo LIB=%%LIB%%;%%LIBPATH%%
|
2011-09-10 11:13:51 +02:00
|
|
|
""" % (vcvars,target))
|
2014-11-13 19:27:58 +01:00
|
|
|
sout = conf.cmd_and_log(['cmd.exe', '/E:on', '/V:on', '/C', batfile.abspath()])
|
2011-09-10 11:13:51 +02:00
|
|
|
lines = sout.splitlines()
|
|
|
|
|
2012-05-29 22:44:00 +02:00
|
|
|
if not lines[0]:
|
|
|
|
lines.pop(0)
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2012-05-29 22:44:00 +02:00
|
|
|
MSVC_PATH = MSVC_INCDIR = MSVC_LIBDIR = None
|
|
|
|
for line in lines:
|
2011-09-10 11:13:51 +02:00
|
|
|
if line.startswith('PATH='):
|
|
|
|
path = line[5:]
|
|
|
|
MSVC_PATH = path.split(';')
|
|
|
|
elif line.startswith('INCLUDE='):
|
|
|
|
MSVC_INCDIR = [i for i in line[8:].split(';') if i]
|
|
|
|
elif line.startswith('LIB='):
|
|
|
|
MSVC_LIBDIR = [i for i in line[4:].split(';') if i]
|
2012-05-29 22:44:00 +02:00
|
|
|
if None in (MSVC_PATH, MSVC_INCDIR, MSVC_LIBDIR):
|
|
|
|
conf.fatal('msvc: Could not find a valid architecture for building (get_msvc_version_3)')
|
|
|
|
|
2011-09-10 11:13:51 +02:00
|
|
|
# Check if the compiler is usable at all.
|
|
|
|
# The detection may return 64-bit versions even on 32-bit systems, and these would fail to run.
|
2012-05-29 22:44:00 +02:00
|
|
|
env = dict(os.environ)
|
2011-09-10 11:13:51 +02:00
|
|
|
env.update(PATH = path)
|
|
|
|
compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
|
|
|
|
cxx = conf.find_program(compiler_name, path_list=MSVC_PATH)
|
|
|
|
|
2017-02-16 07:03:43 +01:00
|
|
|
# delete CL if exists. because it could contain parameters which can change cl's behaviour rather catastrophically.
|
2011-09-10 11:13:51 +02:00
|
|
|
if 'CL' in env:
|
|
|
|
del(env['CL'])
|
|
|
|
|
|
|
|
try:
|
2016-05-18 22:01:37 +02:00
|
|
|
conf.cmd_and_log(cxx + ['/help'], env=env)
|
|
|
|
except UnicodeError:
|
2017-08-19 11:54:58 +02:00
|
|
|
st = traceback.format_exc()
|
2016-05-18 22:01:37 +02:00
|
|
|
if conf.logger:
|
|
|
|
conf.logger.error(st)
|
|
|
|
conf.fatal('msvc: Unicode error - check the code page?')
|
|
|
|
except Exception as e:
|
2016-06-05 00:23:57 +02:00
|
|
|
Logs.debug('msvc: get_msvc_version: %r %r %r -> failure %s', compiler, version, target, str(e))
|
2016-05-18 22:01:37 +02:00
|
|
|
conf.fatal('msvc: cannot run the compiler in get_msvc_version (run with -v to display errors)')
|
|
|
|
else:
|
2016-06-05 00:23:57 +02:00
|
|
|
Logs.debug('msvc: get_msvc_version: %r %r %r -> OK', compiler, version, target)
|
2011-09-10 11:13:51 +02:00
|
|
|
finally:
|
|
|
|
conf.env[compiler_name] = ''
|
|
|
|
|
|
|
|
return (MSVC_PATH, MSVC_INCDIR, MSVC_LIBDIR)
|
|
|
|
|
|
|
|
def gather_wince_supported_platforms():
|
|
|
|
"""
|
|
|
|
Checks SmartPhones SDKs
|
|
|
|
|
|
|
|
:param versions: list to modify
|
|
|
|
:type versions: list
|
|
|
|
"""
|
|
|
|
supported_wince_platforms = []
|
|
|
|
try:
|
2012-02-11 14:49:27 +01:00
|
|
|
ce_sdk = Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Wow6432node\\Microsoft\\Windows CE Tools\\SDKs')
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2011-09-10 11:13:51 +02:00
|
|
|
try:
|
2012-02-11 14:49:27 +01:00
|
|
|
ce_sdk = Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Microsoft\\Windows CE Tools\\SDKs')
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2011-09-10 11:13:51 +02:00
|
|
|
ce_sdk = ''
|
|
|
|
if not ce_sdk:
|
|
|
|
return supported_wince_platforms
|
|
|
|
|
2016-05-22 18:27:57 +02:00
|
|
|
index = 0
|
2011-09-10 11:13:51 +02:00
|
|
|
while 1:
|
|
|
|
try:
|
2016-05-22 18:27:57 +02:00
|
|
|
sdk_device = Utils.winreg.EnumKey(ce_sdk, index)
|
2016-05-22 12:40:51 +02:00
|
|
|
sdk = Utils.winreg.OpenKey(ce_sdk, sdk_device)
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2011-09-10 11:13:51 +02:00
|
|
|
break
|
2016-05-22 18:27:57 +02:00
|
|
|
index += 1
|
2011-09-10 11:13:51 +02:00
|
|
|
try:
|
2012-02-11 14:49:27 +01:00
|
|
|
path,type = Utils.winreg.QueryValueEx(sdk, 'SDKRootDir')
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2011-11-07 20:02:39 +01:00
|
|
|
try:
|
2012-02-11 14:49:27 +01:00
|
|
|
path,type = Utils.winreg.QueryValueEx(sdk,'SDKInformation')
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2011-11-07 20:02:39 +01:00
|
|
|
continue
|
2016-05-22 12:40:51 +02:00
|
|
|
path,xml = os.path.split(path)
|
|
|
|
path = str(path)
|
2011-09-10 11:13:51 +02:00
|
|
|
path,device = os.path.split(path)
|
|
|
|
if not device:
|
|
|
|
path,device = os.path.split(path)
|
2015-09-09 18:30:23 +02:00
|
|
|
platforms = []
|
2011-09-10 11:13:51 +02:00
|
|
|
for arch,compiler in all_wince_platforms:
|
|
|
|
if os.path.isdir(os.path.join(path, device, 'Lib', arch)):
|
|
|
|
platforms.append((arch, compiler, os.path.join(path, device, 'Include', arch), os.path.join(path, device, 'Lib', arch)))
|
2015-09-09 18:30:23 +02:00
|
|
|
if platforms:
|
|
|
|
supported_wince_platforms.append((device, platforms))
|
2011-09-10 11:13:51 +02:00
|
|
|
return supported_wince_platforms
|
|
|
|
|
|
|
|
def gather_msvc_detected_versions():
|
|
|
|
#Detected MSVC versions!
|
|
|
|
version_pattern = re.compile('^(\d\d?\.\d\d?)(Exp)?$')
|
|
|
|
detected_versions = []
|
2014-01-05 22:27:06 +01:00
|
|
|
for vcver,vcvar in (('VCExpress','Exp'), ('VisualStudio','')):
|
2016-05-22 12:40:51 +02:00
|
|
|
prefix = 'SOFTWARE\\Wow6432node\\Microsoft\\' + vcver
|
2011-09-10 11:13:51 +02:00
|
|
|
try:
|
2012-02-11 14:49:27 +01:00
|
|
|
all_versions = Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE, prefix)
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2016-05-22 12:40:51 +02:00
|
|
|
prefix = 'SOFTWARE\\Microsoft\\' + vcver
|
2011-09-10 11:13:51 +02:00
|
|
|
try:
|
2012-02-11 14:49:27 +01:00
|
|
|
all_versions = Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE, prefix)
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2011-09-10 11:13:51 +02:00
|
|
|
continue
|
|
|
|
|
|
|
|
index = 0
|
|
|
|
while 1:
|
|
|
|
try:
|
2012-02-11 14:49:27 +01:00
|
|
|
version = Utils.winreg.EnumKey(all_versions, index)
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2011-09-10 11:13:51 +02:00
|
|
|
break
|
2016-05-22 00:45:47 +02:00
|
|
|
index += 1
|
2011-09-10 11:13:51 +02:00
|
|
|
match = version_pattern.match(version)
|
2016-05-22 03:13:28 +02:00
|
|
|
if match:
|
2011-09-10 11:13:51 +02:00
|
|
|
versionnumber = float(match.group(1))
|
2016-05-22 03:13:28 +02:00
|
|
|
else:
|
|
|
|
continue
|
|
|
|
detected_versions.append((versionnumber, version+vcvar, prefix+'\\'+version))
|
2011-09-10 11:13:51 +02:00
|
|
|
def fun(tup):
|
|
|
|
return tup[0]
|
|
|
|
|
2012-02-06 01:45:44 +01:00
|
|
|
detected_versions.sort(key = fun)
|
2011-09-10 11:13:51 +02:00
|
|
|
return detected_versions
|
|
|
|
|
2016-05-22 02:43:35 +02:00
|
|
|
class target_compiler(object):
|
2016-05-22 12:12:32 +02:00
|
|
|
"""
|
|
|
|
Wrap a compiler configuration; call evaluate() to determine
|
|
|
|
whether the configuration is usable.
|
|
|
|
"""
|
2016-05-22 12:04:23 +02:00
|
|
|
def __init__(self, ctx, compiler, cpu, version, bat_target, bat, callback=None):
|
2016-05-22 12:12:32 +02:00
|
|
|
"""
|
|
|
|
:param ctx: configuration context to use to eventually get the version environment
|
|
|
|
:param compiler: compiler name
|
|
|
|
:param cpu: target cpu
|
|
|
|
:param version: compiler version number
|
|
|
|
:param bat_target: ?
|
|
|
|
:param bat: path to the batch file to run
|
|
|
|
"""
|
2016-05-22 02:43:35 +02:00
|
|
|
self.conf = ctx
|
|
|
|
self.name = None
|
|
|
|
self.is_valid = False
|
|
|
|
self.is_done = False
|
|
|
|
|
|
|
|
self.compiler = compiler
|
2016-05-22 12:04:23 +02:00
|
|
|
self.cpu = cpu
|
2016-05-22 02:43:35 +02:00
|
|
|
self.version = version
|
|
|
|
self.bat_target = bat_target
|
|
|
|
self.bat = bat
|
|
|
|
self.callback = callback
|
|
|
|
|
|
|
|
def evaluate(self):
|
|
|
|
if self.is_done:
|
|
|
|
return
|
|
|
|
self.is_done = True
|
|
|
|
try:
|
2016-05-22 02:45:12 +02:00
|
|
|
vs = self.conf.get_msvc_version(self.compiler, self.version, self.bat_target, self.bat)
|
2016-06-05 00:23:57 +02:00
|
|
|
except Errors.ConfigurationError:
|
2016-05-22 02:43:35 +02:00
|
|
|
self.is_valid = False
|
|
|
|
return
|
|
|
|
if self.callback:
|
|
|
|
vs = self.callback(self, vs)
|
|
|
|
self.is_valid = True
|
|
|
|
(self.bindirs, self.incdirs, self.libdirs) = vs
|
|
|
|
|
|
|
|
def __str__(self):
|
2017-05-06 10:33:10 +02:00
|
|
|
return str((self.compiler, self.cpu, self.version, self.bat_target, self.bat))
|
2016-05-22 02:43:35 +02:00
|
|
|
|
2016-05-22 02:50:02 +02:00
|
|
|
def __repr__(self):
|
2017-05-06 10:33:10 +02:00
|
|
|
return repr((self.compiler, self.cpu, self.version, self.bat_target, self.bat))
|
2016-05-22 02:50:02 +02:00
|
|
|
|
2017-10-20 20:15:16 +02:00
|
|
|
@conf
|
|
|
|
def gather_wsdk_versions(conf, versions):
|
|
|
|
"""
|
|
|
|
Use winreg to add the msvc versions to the input list
|
|
|
|
|
|
|
|
:param versions: list to modify
|
|
|
|
:type versions: list
|
|
|
|
"""
|
|
|
|
version_pattern = re.compile('^v..?.?\...?.?')
|
|
|
|
try:
|
|
|
|
all_versions = Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Wow6432node\\Microsoft\\Microsoft SDKs\\Windows')
|
|
|
|
except OSError:
|
|
|
|
try:
|
|
|
|
all_versions = Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows')
|
|
|
|
except OSError:
|
|
|
|
return
|
|
|
|
index = 0
|
|
|
|
while 1:
|
|
|
|
try:
|
|
|
|
version = Utils.winreg.EnumKey(all_versions, index)
|
|
|
|
except OSError:
|
|
|
|
break
|
|
|
|
index += 1
|
|
|
|
if not version_pattern.match(version):
|
|
|
|
continue
|
|
|
|
try:
|
|
|
|
msvc_version = Utils.winreg.OpenKey(all_versions, version)
|
|
|
|
path,type = Utils.winreg.QueryValueEx(msvc_version,'InstallationFolder')
|
|
|
|
except OSError:
|
|
|
|
continue
|
|
|
|
if path and os.path.isfile(os.path.join(path, 'bin', 'SetEnv.cmd')):
|
|
|
|
targets = {}
|
|
|
|
for target,arch in all_msvc_platforms:
|
|
|
|
targets[target] = target_compiler(conf, 'wsdk', arch, version, '/'+target, os.path.join(path, 'bin', 'SetEnv.cmd'))
|
|
|
|
versions['wsdk ' + version[1:]] = targets
|
|
|
|
|
2011-09-10 11:13:51 +02:00
|
|
|
@conf
|
2015-09-01 04:06:34 +02:00
|
|
|
def gather_msvc_targets(conf, versions, version, vc_path):
|
2011-09-10 11:13:51 +02:00
|
|
|
#Looking for normal MSVC compilers!
|
2016-05-22 18:27:57 +02:00
|
|
|
targets = {}
|
2017-03-15 18:03:35 +01:00
|
|
|
|
2017-03-25 23:01:36 +01:00
|
|
|
if os.path.isfile(os.path.join(vc_path, 'VC', 'Auxiliary', 'Build', 'vcvarsall.bat')):
|
|
|
|
for target,realtarget in all_msvc_platforms[::-1]:
|
|
|
|
targets[target] = target_compiler(conf, 'msvc', realtarget, version, target, os.path.join(vc_path, 'VC', 'Auxiliary', 'Build', 'vcvarsall.bat'))
|
2017-03-14 22:06:54 +01:00
|
|
|
elif os.path.isfile(os.path.join(vc_path, 'vcvarsall.bat')):
|
2011-09-10 11:13:51 +02:00
|
|
|
for target,realtarget in all_msvc_platforms[::-1]:
|
2016-05-22 18:27:57 +02:00
|
|
|
targets[target] = target_compiler(conf, 'msvc', realtarget, version, target, os.path.join(vc_path, 'vcvarsall.bat'))
|
2011-09-10 11:13:51 +02:00
|
|
|
elif os.path.isfile(os.path.join(vc_path, 'Common7', 'Tools', 'vsvars32.bat')):
|
2016-05-22 18:27:57 +02:00
|
|
|
targets['x86'] = target_compiler(conf, 'msvc', 'x86', version, 'x86', os.path.join(vc_path, 'Common7', 'Tools', 'vsvars32.bat'))
|
2011-09-10 11:13:51 +02:00
|
|
|
elif os.path.isfile(os.path.join(vc_path, 'Bin', 'vcvars32.bat')):
|
2016-05-22 18:27:57 +02:00
|
|
|
targets['x86'] = target_compiler(conf, 'msvc', 'x86', version, '', os.path.join(vc_path, 'Bin', 'vcvars32.bat'))
|
2013-02-17 14:09:32 +01:00
|
|
|
if targets:
|
2017-05-06 10:33:10 +02:00
|
|
|
versions['msvc %s' % version] = targets
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
@conf
|
2015-09-01 04:06:34 +02:00
|
|
|
def gather_wince_targets(conf, versions, version, vc_path, vsvars, supported_platforms):
|
2011-09-10 11:13:51 +02:00
|
|
|
#Looking for Win CE compilers!
|
|
|
|
for device,platforms in supported_platforms:
|
2016-05-22 18:27:57 +02:00
|
|
|
targets = {}
|
2011-09-10 11:13:51 +02:00
|
|
|
for platform,compiler,include,lib in platforms:
|
|
|
|
winCEpath = os.path.join(vc_path, 'ce')
|
|
|
|
if not os.path.isdir(winCEpath):
|
|
|
|
continue
|
2015-08-31 20:55:15 +02:00
|
|
|
|
2011-09-10 11:13:51 +02:00
|
|
|
if os.path.isdir(os.path.join(winCEpath, 'lib', platform)):
|
2015-08-31 20:55:15 +02:00
|
|
|
bindirs = [os.path.join(winCEpath, 'bin', compiler), os.path.join(winCEpath, 'bin', 'x86_'+compiler)]
|
2011-11-07 20:02:39 +01:00
|
|
|
incdirs = [os.path.join(winCEpath, 'include'), os.path.join(winCEpath, 'atlmfc', 'include'), include]
|
|
|
|
libdirs = [os.path.join(winCEpath, 'lib', platform), os.path.join(winCEpath, 'atlmfc', 'lib', platform), lib]
|
2016-05-22 02:43:35 +02:00
|
|
|
def combine_common(obj, compiler_env):
|
2017-10-20 20:15:16 +02:00
|
|
|
# TODO this is likely broken, remove in waf 2.1
|
2015-08-31 20:55:15 +02:00
|
|
|
(common_bindirs,_1,_2) = compiler_env
|
|
|
|
return (bindirs + common_bindirs, incdirs, libdirs)
|
2016-05-22 18:27:57 +02:00
|
|
|
targets[platform] = target_compiler(conf, 'msvc', platform, version, 'x86', vsvars, combine_common)
|
|
|
|
if targets:
|
|
|
|
versions[device + ' ' + version] = targets
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2013-02-17 14:09:32 +01:00
|
|
|
@conf
|
2015-09-01 04:06:34 +02:00
|
|
|
def gather_winphone_targets(conf, versions, version, vc_path, vsvars):
|
2013-02-17 14:09:32 +01:00
|
|
|
#Looking for WinPhone compilers
|
2016-05-22 18:27:57 +02:00
|
|
|
targets = {}
|
2013-02-17 14:09:32 +01:00
|
|
|
for target,realtarget in all_msvc_platforms[::-1]:
|
2016-05-22 18:27:57 +02:00
|
|
|
targets[target] = target_compiler(conf, 'winphone', realtarget, version, target, vsvars)
|
2013-02-17 14:09:32 +01:00
|
|
|
if targets:
|
2016-05-22 18:27:57 +02:00
|
|
|
versions['winphone ' + version] = targets
|
2013-02-17 14:09:32 +01:00
|
|
|
|
2017-04-22 02:03:37 +02:00
|
|
|
@conf
|
|
|
|
def gather_vswhere_versions(conf, versions):
|
|
|
|
try:
|
2017-05-06 10:33:10 +02:00
|
|
|
import json
|
|
|
|
except ImportError:
|
|
|
|
Logs.error('Visual Studio 2017 detection requires Python 2.6')
|
|
|
|
return
|
|
|
|
|
|
|
|
prg_path = os.environ.get('ProgramFiles(x86)', os.environ.get('ProgramFiles', 'C:\\Program Files (x86)'))
|
2017-04-22 02:03:37 +02:00
|
|
|
|
2017-05-06 10:33:10 +02:00
|
|
|
vswhere = os.path.join(prg_path, 'Microsoft Visual Studio', 'Installer', 'vswhere.exe')
|
|
|
|
args = [vswhere, '-products', '*', '-legacy', '-format', 'json']
|
|
|
|
try:
|
2018-05-08 23:43:59 +02:00
|
|
|
txt = conf.cmd_and_log(args, decode_as=cmd_encoding())
|
2017-05-06 10:33:10 +02:00
|
|
|
except Errors.WafError as e:
|
|
|
|
Logs.debug('msvc: vswhere.exe failed %s', e)
|
|
|
|
return
|
|
|
|
|
2017-05-13 09:53:49 +02:00
|
|
|
if sys.version_info[0] < 3:
|
2018-05-08 23:43:59 +02:00
|
|
|
txt = txt.decode(cmd_encoding())
|
|
|
|
|
2017-05-06 10:33:10 +02:00
|
|
|
arr = json.loads(txt)
|
|
|
|
arr.sort(key=lambda x: x['installationVersion'])
|
|
|
|
for entry in arr:
|
|
|
|
ver = entry['installationVersion']
|
|
|
|
ver = str('.'.join(ver.split('.')[:2]))
|
|
|
|
path = str(os.path.abspath(entry['installationPath']))
|
|
|
|
if os.path.exists(path) and ('msvc %s' % ver) not in versions:
|
|
|
|
conf.gather_msvc_targets(versions, ver, path)
|
2017-04-22 02:03:37 +02:00
|
|
|
|
2011-09-10 11:13:51 +02:00
|
|
|
@conf
|
2015-09-01 04:06:34 +02:00
|
|
|
def gather_msvc_versions(conf, versions):
|
2011-09-10 11:13:51 +02:00
|
|
|
vc_paths = []
|
|
|
|
for (v,version,reg) in gather_msvc_detected_versions():
|
|
|
|
try:
|
|
|
|
try:
|
2012-02-11 14:49:27 +01:00
|
|
|
msvc_version = Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE, reg + "\\Setup\\VC")
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2012-02-11 14:49:27 +01:00
|
|
|
msvc_version = Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE, reg + "\\Setup\\Microsoft Visual C++")
|
|
|
|
path,type = Utils.winreg.QueryValueEx(msvc_version, 'ProductDir')
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2017-03-14 22:06:54 +01:00
|
|
|
try:
|
|
|
|
msvc_version = Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432node\\Microsoft\\VisualStudio\\SxS\\VS7")
|
|
|
|
path,type = Utils.winreg.QueryValueEx(msvc_version, version)
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2017-03-14 22:06:54 +01:00
|
|
|
continue
|
|
|
|
else:
|
|
|
|
vc_paths.append((version, os.path.abspath(str(path))))
|
2011-09-10 11:13:51 +02:00
|
|
|
continue
|
2016-05-22 10:58:24 +02:00
|
|
|
else:
|
|
|
|
vc_paths.append((version, os.path.abspath(str(path))))
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
wince_supported_platforms = gather_wince_supported_platforms()
|
|
|
|
|
|
|
|
for version,vc_path in vc_paths:
|
|
|
|
vs_path = os.path.dirname(vc_path)
|
|
|
|
vsvars = os.path.join(vs_path, 'Common7', 'Tools', 'vsvars32.bat')
|
|
|
|
if wince_supported_platforms and os.path.isfile(vsvars):
|
2015-09-01 04:06:34 +02:00
|
|
|
conf.gather_wince_targets(versions, version, vc_path, vsvars, wince_supported_platforms)
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2015-09-09 18:31:09 +02:00
|
|
|
# WP80 works with 11.0Exp and 11.0, both of which resolve to the same vc_path.
|
|
|
|
# Stop after one is found.
|
|
|
|
for version,vc_path in vc_paths:
|
|
|
|
vs_path = os.path.dirname(vc_path)
|
2013-02-17 14:09:32 +01:00
|
|
|
vsvars = os.path.join(vs_path, 'VC', 'WPSDK', 'WP80', 'vcvarsphoneall.bat')
|
|
|
|
if os.path.isfile(vsvars):
|
2015-09-01 04:06:34 +02:00
|
|
|
conf.gather_winphone_targets(versions, '8.0', vc_path, vsvars)
|
2015-09-09 18:31:09 +02:00
|
|
|
break
|
2013-02-17 14:09:32 +01:00
|
|
|
|
2011-09-10 11:13:51 +02:00
|
|
|
for version,vc_path in vc_paths:
|
|
|
|
vs_path = os.path.dirname(vc_path)
|
2015-09-01 04:06:34 +02:00
|
|
|
conf.gather_msvc_targets(versions, version, vc_path)
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
@conf
|
2015-09-01 04:06:34 +02:00
|
|
|
def gather_icl_versions(conf, versions):
|
2011-09-10 11:13:51 +02:00
|
|
|
"""
|
|
|
|
Checks ICL compilers
|
|
|
|
|
|
|
|
:param versions: list to modify
|
|
|
|
:type versions: list
|
|
|
|
"""
|
|
|
|
version_pattern = re.compile('^...?.?\....?.?')
|
|
|
|
try:
|
2012-02-11 14:49:27 +01:00
|
|
|
all_versions = Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Wow6432node\\Intel\\Compilers\\C++')
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2011-09-10 11:13:51 +02:00
|
|
|
try:
|
2012-02-11 14:49:27 +01:00
|
|
|
all_versions = Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Intel\\Compilers\\C++')
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2011-09-10 11:13:51 +02:00
|
|
|
return
|
|
|
|
index = 0
|
|
|
|
while 1:
|
|
|
|
try:
|
2012-02-11 14:49:27 +01:00
|
|
|
version = Utils.winreg.EnumKey(all_versions, index)
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2011-09-10 11:13:51 +02:00
|
|
|
break
|
2016-05-22 00:45:47 +02:00
|
|
|
index += 1
|
2011-09-10 11:13:51 +02:00
|
|
|
if not version_pattern.match(version):
|
|
|
|
continue
|
2016-05-22 18:27:57 +02:00
|
|
|
targets = {}
|
2011-09-10 11:13:51 +02:00
|
|
|
for target,arch in all_icl_platforms:
|
2017-04-17 12:26:47 +02:00
|
|
|
if target=='intel64':
|
|
|
|
targetDir='EM64T_NATIVE'
|
|
|
|
else:
|
|
|
|
targetDir=target
|
2011-09-10 11:13:51 +02:00
|
|
|
try:
|
2012-02-11 14:49:27 +01:00
|
|
|
Utils.winreg.OpenKey(all_versions,version+'\\'+targetDir)
|
|
|
|
icl_version=Utils.winreg.OpenKey(all_versions,version)
|
|
|
|
path,type=Utils.winreg.QueryValueEx(icl_version,'ProductDir')
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2016-05-22 10:58:24 +02:00
|
|
|
pass
|
|
|
|
else:
|
2012-12-10 11:24:15 +01:00
|
|
|
batch_file=os.path.join(path,'bin','iclvars.bat')
|
|
|
|
if os.path.isfile(batch_file):
|
2016-05-22 18:27:57 +02:00
|
|
|
targets[target] = target_compiler(conf, 'intel', arch, version, target, batch_file)
|
2011-09-10 11:13:51 +02:00
|
|
|
for target,arch in all_icl_platforms:
|
|
|
|
try:
|
2012-02-11 14:49:27 +01:00
|
|
|
icl_version = Utils.winreg.OpenKey(all_versions, version+'\\'+target)
|
|
|
|
path,type = Utils.winreg.QueryValueEx(icl_version,'ProductDir')
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2016-05-22 10:58:24 +02:00
|
|
|
continue
|
|
|
|
else:
|
2012-12-10 11:24:15 +01:00
|
|
|
batch_file=os.path.join(path,'bin','iclvars.bat')
|
|
|
|
if os.path.isfile(batch_file):
|
2016-05-22 18:27:57 +02:00
|
|
|
targets[target] = target_compiler(conf, 'intel', arch, version, target, batch_file)
|
2011-09-10 11:13:51 +02:00
|
|
|
major = version[0:2]
|
2016-05-22 18:27:57 +02:00
|
|
|
versions['intel ' + major] = targets
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2012-12-10 11:24:15 +01:00
|
|
|
@conf
|
2015-09-01 04:06:34 +02:00
|
|
|
def gather_intel_composer_versions(conf, versions):
|
2012-12-10 11:24:15 +01:00
|
|
|
"""
|
|
|
|
Checks ICL compilers that are part of Intel Composer Suites
|
|
|
|
|
|
|
|
:param versions: list to modify
|
|
|
|
:type versions: list
|
|
|
|
"""
|
|
|
|
version_pattern = re.compile('^...?.?\...?.?.?')
|
|
|
|
try:
|
|
|
|
all_versions = Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Wow6432node\\Intel\\Suites')
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2012-12-10 11:24:15 +01:00
|
|
|
try:
|
|
|
|
all_versions = Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Intel\\Suites')
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2012-12-17 17:53:27 +01:00
|
|
|
return
|
2012-12-10 11:24:15 +01:00
|
|
|
index = 0
|
|
|
|
while 1:
|
|
|
|
try:
|
|
|
|
version = Utils.winreg.EnumKey(all_versions, index)
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2012-12-10 11:24:15 +01:00
|
|
|
break
|
2016-05-22 00:45:47 +02:00
|
|
|
index += 1
|
2012-12-10 11:24:15 +01:00
|
|
|
if not version_pattern.match(version):
|
|
|
|
continue
|
2016-05-22 18:27:57 +02:00
|
|
|
targets = {}
|
2012-12-10 11:24:15 +01:00
|
|
|
for target,arch in all_icl_platforms:
|
2017-04-17 12:26:47 +02:00
|
|
|
if target=='intel64':
|
|
|
|
targetDir='EM64T_NATIVE'
|
|
|
|
else:
|
|
|
|
targetDir=target
|
2012-12-10 11:24:15 +01:00
|
|
|
try:
|
|
|
|
try:
|
|
|
|
defaults = Utils.winreg.OpenKey(all_versions,version+'\\Defaults\\C++\\'+targetDir)
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2016-05-22 10:58:24 +02:00
|
|
|
if targetDir == 'EM64T_NATIVE':
|
2012-12-10 11:24:15 +01:00
|
|
|
defaults = Utils.winreg.OpenKey(all_versions,version+'\\Defaults\\C++\\EM64T')
|
|
|
|
else:
|
2016-05-22 10:58:24 +02:00
|
|
|
raise
|
2012-12-10 11:24:15 +01:00
|
|
|
uid,type = Utils.winreg.QueryValueEx(defaults, 'SubKey')
|
|
|
|
Utils.winreg.OpenKey(all_versions,version+'\\'+uid+'\\C++\\'+targetDir)
|
|
|
|
icl_version=Utils.winreg.OpenKey(all_versions,version+'\\'+uid+'\\C++')
|
|
|
|
path,type=Utils.winreg.QueryValueEx(icl_version,'ProductDir')
|
2017-06-23 16:51:54 +02:00
|
|
|
except OSError:
|
2016-05-22 10:58:24 +02:00
|
|
|
pass
|
|
|
|
else:
|
2012-12-10 11:24:15 +01:00
|
|
|
batch_file=os.path.join(path,'bin','iclvars.bat')
|
|
|
|
if os.path.isfile(batch_file):
|
2016-05-22 18:27:57 +02:00
|
|
|
targets[target] = target_compiler(conf, 'intel', arch, version, target, batch_file)
|
2012-12-10 11:32:24 +01:00
|
|
|
# The intel compilervar_arch.bat is broken when used with Visual Studio Express 2012
|
|
|
|
# http://software.intel.com/en-us/forums/topic/328487
|
|
|
|
compilervars_warning_attr = '_compilervars_warning_key'
|
|
|
|
if version[0:2] == '13' and getattr(conf, compilervars_warning_attr, True):
|
|
|
|
setattr(conf, compilervars_warning_attr, False)
|
|
|
|
patch_url = 'http://software.intel.com/en-us/forums/topic/328487'
|
|
|
|
compilervars_arch = os.path.join(path, 'bin', 'compilervars_arch.bat')
|
2014-01-05 22:27:06 +01:00
|
|
|
for vscomntool in ('VS110COMNTOOLS', 'VS100COMNTOOLS'):
|
2013-09-07 10:33:33 +02:00
|
|
|
if vscomntool in os.environ:
|
|
|
|
vs_express_path = os.environ[vscomntool] + r'..\IDE\VSWinExpress.exe'
|
|
|
|
dev_env_path = os.environ[vscomntool] + r'..\IDE\devenv.exe'
|
2013-03-23 09:23:02 +01:00
|
|
|
if (r'if exist "%VS110COMNTOOLS%..\IDE\VSWinExpress.exe"' in Utils.readf(compilervars_arch) and
|
|
|
|
not os.path.exists(vs_express_path) and not os.path.exists(dev_env_path)):
|
|
|
|
Logs.warn(('The Intel compilervar_arch.bat only checks for one Visual Studio SKU '
|
2015-09-22 07:08:21 +02:00
|
|
|
'(VSWinExpress.exe) but it does not seem to be installed at %r. '
|
|
|
|
'The intel command line set up will fail to configure unless the file %r'
|
|
|
|
'is patched. See: %s') % (vs_express_path, compilervars_arch, patch_url))
|
2012-12-10 11:24:15 +01:00
|
|
|
major = version[0:2]
|
2016-05-22 18:27:57 +02:00
|
|
|
versions['intel ' + major] = targets
|
2012-12-10 11:24:15 +01:00
|
|
|
|
2016-05-22 16:57:22 +02:00
|
|
|
@conf
|
2016-05-22 18:27:57 +02:00
|
|
|
def detect_msvc(self):
|
|
|
|
return self.setup_msvc(self.get_msvc_versions())
|
2016-05-22 16:57:22 +02:00
|
|
|
|
2011-09-10 11:13:51 +02:00
|
|
|
@conf
|
2016-05-22 17:06:53 +02:00
|
|
|
def get_msvc_versions(self):
|
2011-09-10 11:13:51 +02:00
|
|
|
"""
|
2016-05-22 18:27:57 +02:00
|
|
|
:return: platform to compiler configurations
|
|
|
|
:rtype: dict
|
2011-09-10 11:13:51 +02:00
|
|
|
"""
|
2017-03-25 13:33:22 +01:00
|
|
|
dct = Utils.ordered_iter_dict()
|
2016-05-22 18:27:57 +02:00
|
|
|
self.gather_icl_versions(dct)
|
|
|
|
self.gather_intel_composer_versions(dct)
|
|
|
|
self.gather_wsdk_versions(dct)
|
|
|
|
self.gather_msvc_versions(dct)
|
2017-04-22 02:03:37 +02:00
|
|
|
self.gather_vswhere_versions(dct)
|
2017-04-08 21:35:23 +02:00
|
|
|
Logs.debug('msvc: detected versions %r', list(dct.keys()))
|
2016-05-22 18:27:57 +02:00
|
|
|
return dct
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
@conf
|
|
|
|
def find_lt_names_msvc(self, libname, is_static=False):
|
|
|
|
"""
|
|
|
|
Win32/MSVC specific code to glean out information from libtool la files.
|
2016-05-22 11:15:00 +02:00
|
|
|
this function is not attached to the task_gen class. Returns a triplet:
|
|
|
|
(library absolute path, library name without extension, whether the library is static)
|
2011-09-10 11:13:51 +02:00
|
|
|
"""
|
|
|
|
lt_names=[
|
|
|
|
'lib%s.la' % libname,
|
|
|
|
'%s.la' % libname,
|
|
|
|
]
|
|
|
|
|
2016-06-25 23:54:12 +02:00
|
|
|
for path in self.env.LIBPATH:
|
2011-09-10 11:13:51 +02:00
|
|
|
for la in lt_names:
|
|
|
|
laf=os.path.join(path,la)
|
|
|
|
dll=None
|
|
|
|
if os.path.exists(laf):
|
|
|
|
ltdict = Utils.read_la_file(laf)
|
|
|
|
lt_libdir=None
|
|
|
|
if ltdict.get('libdir', ''):
|
|
|
|
lt_libdir = ltdict['libdir']
|
|
|
|
if not is_static and ltdict.get('library_names', ''):
|
|
|
|
dllnames=ltdict['library_names'].split()
|
|
|
|
dll=dllnames[0].lower()
|
|
|
|
dll=re.sub('\.dll$', '', dll)
|
|
|
|
return (lt_libdir, dll, False)
|
|
|
|
elif ltdict.get('old_library', ''):
|
|
|
|
olib=ltdict['old_library']
|
|
|
|
if os.path.exists(os.path.join(path,olib)):
|
|
|
|
return (path, olib, True)
|
|
|
|
elif lt_libdir != '' and os.path.exists(os.path.join(lt_libdir,olib)):
|
|
|
|
return (lt_libdir, olib, True)
|
|
|
|
else:
|
|
|
|
return (None, olib, True)
|
|
|
|
else:
|
|
|
|
raise self.errors.WafError('invalid libtool object file: %s' % laf)
|
|
|
|
return (None, None, None)
|
|
|
|
|
|
|
|
@conf
|
|
|
|
def libname_msvc(self, libname, is_static=False):
|
|
|
|
lib = libname.lower()
|
|
|
|
lib = re.sub('\.lib$','',lib)
|
|
|
|
|
|
|
|
if lib in g_msvc_systemlibs:
|
|
|
|
return lib
|
|
|
|
|
|
|
|
lib=re.sub('^lib','',lib)
|
|
|
|
|
|
|
|
if lib == 'm':
|
|
|
|
return None
|
|
|
|
|
|
|
|
(lt_path, lt_libname, lt_static) = self.find_lt_names_msvc(lib, is_static)
|
|
|
|
|
|
|
|
if lt_path != None and lt_libname != None:
|
2017-04-22 22:08:00 +02:00
|
|
|
if lt_static:
|
2017-02-16 07:03:43 +01:00
|
|
|
# file existence check has been made by find_lt_names
|
2011-09-10 11:13:51 +02:00
|
|
|
return os.path.join(lt_path,lt_libname)
|
|
|
|
|
|
|
|
if lt_path != None:
|
2016-06-25 23:54:12 +02:00
|
|
|
_libpaths = [lt_path] + self.env.LIBPATH
|
2011-09-10 11:13:51 +02:00
|
|
|
else:
|
2016-06-25 23:54:12 +02:00
|
|
|
_libpaths = self.env.LIBPATH
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
static_libs=[
|
|
|
|
'lib%ss.lib' % lib,
|
|
|
|
'lib%s.lib' % lib,
|
|
|
|
'%ss.lib' % lib,
|
|
|
|
'%s.lib' %lib,
|
|
|
|
]
|
|
|
|
|
|
|
|
dynamic_libs=[
|
|
|
|
'lib%s.dll.lib' % lib,
|
|
|
|
'lib%s.dll.a' % lib,
|
|
|
|
'%s.dll.lib' % lib,
|
|
|
|
'%s.dll.a' % lib,
|
|
|
|
'lib%s_d.lib' % lib,
|
|
|
|
'%s_d.lib' % lib,
|
|
|
|
'%s.lib' %lib,
|
|
|
|
]
|
|
|
|
|
|
|
|
libnames=static_libs
|
|
|
|
if not is_static:
|
|
|
|
libnames=dynamic_libs + static_libs
|
|
|
|
|
|
|
|
for path in _libpaths:
|
|
|
|
for libn in libnames:
|
|
|
|
if os.path.exists(os.path.join(path, libn)):
|
2016-06-05 00:23:57 +02:00
|
|
|
Logs.debug('msvc: lib found: %s', os.path.join(path,libn))
|
2011-09-10 11:13:51 +02:00
|
|
|
return re.sub('\.lib$', '',libn)
|
|
|
|
|
|
|
|
#if no lib can be found, just return the libname as msvc expects it
|
2016-06-05 00:23:57 +02:00
|
|
|
self.fatal('The library %r could not be found' % libname)
|
2011-09-10 11:13:51 +02:00
|
|
|
return re.sub('\.lib$', '', libname)
|
|
|
|
|
|
|
|
@conf
|
|
|
|
def check_lib_msvc(self, libname, is_static=False, uselib_store=None):
|
|
|
|
"""
|
|
|
|
Ideally we should be able to place the lib in the right env var, either STLIB or LIB,
|
|
|
|
but we don't distinguish static libs from shared libs.
|
2016-06-25 23:54:12 +02:00
|
|
|
This is ok since msvc doesn't have any special linker flag to select static libs (no env.STLIB_MARKER)
|
2011-09-10 11:13:51 +02:00
|
|
|
"""
|
|
|
|
libn = self.libname_msvc(libname, is_static)
|
|
|
|
|
|
|
|
if not uselib_store:
|
|
|
|
uselib_store = libname.upper()
|
|
|
|
|
|
|
|
if False and is_static: # disabled
|
|
|
|
self.env['STLIB_' + uselib_store] = [libn]
|
|
|
|
else:
|
|
|
|
self.env['LIB_' + uselib_store] = [libn]
|
|
|
|
|
|
|
|
@conf
|
|
|
|
def check_libs_msvc(self, libnames, is_static=False):
|
|
|
|
for libname in Utils.to_list(libnames):
|
|
|
|
self.check_lib_msvc(libname, is_static)
|
|
|
|
|
|
|
|
def configure(conf):
|
|
|
|
"""
|
|
|
|
Configuration methods to call for detecting msvc
|
|
|
|
"""
|
2015-09-01 04:06:34 +02:00
|
|
|
conf.autodetect(True)
|
2011-09-10 11:13:51 +02:00
|
|
|
conf.find_msvc()
|
|
|
|
conf.msvc_common_flags()
|
|
|
|
conf.cc_load_tools()
|
|
|
|
conf.cxx_load_tools()
|
|
|
|
conf.cc_add_flags()
|
|
|
|
conf.cxx_add_flags()
|
|
|
|
conf.link_add_flags()
|
|
|
|
conf.visual_studio_add_flags()
|
|
|
|
|
|
|
|
@conf
|
|
|
|
def no_autodetect(conf):
|
|
|
|
conf.env.NO_MSVC_DETECT = 1
|
|
|
|
configure(conf)
|
|
|
|
|
|
|
|
@conf
|
2016-05-22 02:43:35 +02:00
|
|
|
def autodetect(conf, arch=False):
|
2011-09-10 11:13:51 +02:00
|
|
|
v = conf.env
|
|
|
|
if v.NO_MSVC_DETECT:
|
|
|
|
return
|
2016-05-22 02:43:35 +02:00
|
|
|
|
2016-05-22 18:27:57 +02:00
|
|
|
compiler, version, path, includes, libdirs, cpu = conf.detect_msvc()
|
2012-09-18 23:57:17 +02:00
|
|
|
if arch:
|
2016-06-25 23:54:12 +02:00
|
|
|
v.DEST_CPU = cpu
|
2012-09-18 23:57:17 +02:00
|
|
|
|
2016-06-25 23:54:12 +02:00
|
|
|
v.PATH = path
|
|
|
|
v.INCLUDES = includes
|
|
|
|
v.LIBPATH = libdirs
|
|
|
|
v.MSVC_COMPILER = compiler
|
2011-09-10 11:13:51 +02:00
|
|
|
try:
|
2016-06-25 23:54:12 +02:00
|
|
|
v.MSVC_VERSION = float(version)
|
2017-07-30 00:13:42 +02:00
|
|
|
except ValueError:
|
2016-06-25 23:54:12 +02:00
|
|
|
v.MSVC_VERSION = float(version[:-3])
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
def _get_prog_names(conf, compiler):
|
2016-05-22 02:43:35 +02:00
|
|
|
if compiler == 'intel':
|
2011-09-10 11:13:51 +02:00
|
|
|
compiler_name = 'ICL'
|
|
|
|
linker_name = 'XILINK'
|
|
|
|
lib_name = 'XILIB'
|
|
|
|
else:
|
|
|
|
# assumes CL.exe
|
|
|
|
compiler_name = 'CL'
|
|
|
|
linker_name = 'LINK'
|
|
|
|
lib_name = 'LIB'
|
|
|
|
return compiler_name, linker_name, lib_name
|
|
|
|
|
|
|
|
@conf
|
|
|
|
def find_msvc(conf):
|
|
|
|
"""Due to path format limitations, limit operation only to native Win32. Yeah it sucks."""
|
|
|
|
if sys.platform == 'cygwin':
|
|
|
|
conf.fatal('MSVC module does not work under cygwin Python!')
|
|
|
|
|
|
|
|
# the autodetection is supposed to be performed before entering in this method
|
|
|
|
v = conf.env
|
2016-06-25 23:54:12 +02:00
|
|
|
path = v.PATH
|
|
|
|
compiler = v.MSVC_COMPILER
|
|
|
|
version = v.MSVC_VERSION
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
|
|
|
|
v.MSVC_MANIFEST = (compiler == 'msvc' and version >= 8) or (compiler == 'wsdk' and version >= 6) or (compiler == 'intel' and version >= 11)
|
|
|
|
|
|
|
|
# compiler
|
|
|
|
cxx = conf.find_program(compiler_name, var='CXX', path_list=path)
|
|
|
|
|
|
|
|
# before setting anything, check if the compiler is really msvc
|
|
|
|
env = dict(conf.environ)
|
2017-04-17 12:26:47 +02:00
|
|
|
if path:
|
|
|
|
env.update(PATH = ';'.join(path))
|
2011-09-10 11:13:51 +02:00
|
|
|
if not conf.cmd_and_log(cxx + ['/nologo', '/help'], env=env):
|
|
|
|
conf.fatal('the msvc compiler could not be identified')
|
|
|
|
|
|
|
|
# c/c++ compiler
|
2016-06-25 23:54:12 +02:00
|
|
|
v.CC = v.CXX = cxx
|
|
|
|
v.CC_NAME = v.CXX_NAME = 'msvc'
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
# linker
|
2016-06-25 23:54:12 +02:00
|
|
|
if not v.LINK_CXX:
|
2017-08-25 20:23:16 +02:00
|
|
|
conf.find_program(linker_name, path_list=path, errmsg='%s was not found (linker)' % linker_name, var='LINK_CXX')
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2016-06-25 23:54:12 +02:00
|
|
|
if not v.LINK_CC:
|
|
|
|
v.LINK_CC = v.LINK_CXX
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
# staticlib linker
|
2016-06-25 23:54:12 +02:00
|
|
|
if not v.AR:
|
2011-09-10 11:13:51 +02:00
|
|
|
stliblink = conf.find_program(lib_name, path_list=path, var='AR')
|
2016-06-25 23:54:12 +02:00
|
|
|
if not stliblink:
|
|
|
|
return
|
|
|
|
v.ARFLAGS = ['/nologo']
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
# manifest tool. Not required for VS 2003 and below. Must have for VS 2005 and later
|
|
|
|
if v.MSVC_MANIFEST:
|
2012-05-29 22:47:33 +02:00
|
|
|
conf.find_program('MT', path_list=path, var='MT')
|
2016-06-25 23:54:12 +02:00
|
|
|
v.MTFLAGS = ['/nologo']
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2013-02-17 14:09:32 +01:00
|
|
|
try:
|
|
|
|
conf.load('winres')
|
2016-06-05 00:23:57 +02:00
|
|
|
except Errors.ConfigurationError:
|
|
|
|
Logs.warn('Resource compiler not found. Compiling resource file is disabled')
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
@conf
|
|
|
|
def visual_studio_add_flags(self):
|
|
|
|
"""visual studio flags found in the system environment"""
|
|
|
|
v = self.env
|
2016-04-19 22:00:21 +02:00
|
|
|
if self.environ.get('INCLUDE'):
|
2016-01-17 14:25:57 +01:00
|
|
|
v.prepend_value('INCLUDES', [x for x in self.environ['INCLUDE'].split(';') if x]) # notice the 'S'
|
2016-04-19 22:00:21 +02:00
|
|
|
if self.environ.get('LIB'):
|
2016-01-17 14:25:57 +01:00
|
|
|
v.prepend_value('LIBPATH', [x for x in self.environ['LIB'].split(';') if x])
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
@conf
|
|
|
|
def msvc_common_flags(conf):
|
|
|
|
"""
|
|
|
|
Setup the flags required for executing the msvc compiler
|
|
|
|
"""
|
|
|
|
v = conf.env
|
|
|
|
|
2016-06-25 23:54:12 +02:00
|
|
|
v.DEST_BINFMT = 'pe'
|
2011-09-10 11:13:51 +02:00
|
|
|
v.append_value('CFLAGS', ['/nologo'])
|
|
|
|
v.append_value('CXXFLAGS', ['/nologo'])
|
2016-05-22 11:15:00 +02:00
|
|
|
v.append_value('LINKFLAGS', ['/nologo'])
|
2016-06-25 23:54:12 +02:00
|
|
|
v.DEFINES_ST = '/D%s'
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2016-06-25 23:54:12 +02:00
|
|
|
v.CC_SRC_F = ''
|
|
|
|
v.CC_TGT_F = ['/c', '/Fo']
|
|
|
|
v.CXX_SRC_F = ''
|
|
|
|
v.CXX_TGT_F = ['/c', '/Fo']
|
2013-07-16 21:10:32 +02:00
|
|
|
|
|
|
|
if (v.MSVC_COMPILER == 'msvc' and v.MSVC_VERSION >= 8) or (v.MSVC_COMPILER == 'wsdk' and v.MSVC_VERSION >= 6):
|
2016-06-25 23:54:12 +02:00
|
|
|
v.CC_TGT_F = ['/FC'] + v.CC_TGT_F
|
|
|
|
v.CXX_TGT_F = ['/FC'] + v.CXX_TGT_F
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2016-06-25 23:54:12 +02:00
|
|
|
v.CPPPATH_ST = '/I%s' # template for adding include paths
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2016-06-25 23:54:12 +02:00
|
|
|
v.AR_TGT_F = v.CCLNK_TGT_F = v.CXXLNK_TGT_F = '/OUT:'
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
# CRT specific flags
|
2016-06-25 23:54:12 +02:00
|
|
|
v.CFLAGS_CRT_MULTITHREADED = v.CXXFLAGS_CRT_MULTITHREADED = ['/MT']
|
|
|
|
v.CFLAGS_CRT_MULTITHREADED_DLL = v.CXXFLAGS_CRT_MULTITHREADED_DLL = ['/MD']
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2016-06-25 23:54:12 +02:00
|
|
|
v.CFLAGS_CRT_MULTITHREADED_DBG = v.CXXFLAGS_CRT_MULTITHREADED_DBG = ['/MTd']
|
|
|
|
v.CFLAGS_CRT_MULTITHREADED_DLL_DBG = v.CXXFLAGS_CRT_MULTITHREADED_DLL_DBG = ['/MDd']
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2016-07-17 15:19:06 +02:00
|
|
|
v.LIB_ST = '%s.lib'
|
|
|
|
v.LIBPATH_ST = '/LIBPATH:%s'
|
2016-06-25 23:54:12 +02:00
|
|
|
v.STLIB_ST = '%s.lib'
|
|
|
|
v.STLIBPATH_ST = '/LIBPATH:%s'
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2016-06-25 23:54:12 +02:00
|
|
|
if v.MSVC_MANIFEST:
|
2011-09-10 11:13:51 +02:00
|
|
|
v.append_value('LINKFLAGS', ['/MANIFEST'])
|
|
|
|
|
2016-06-25 23:54:12 +02:00
|
|
|
v.CFLAGS_cshlib = []
|
|
|
|
v.CXXFLAGS_cxxshlib = []
|
|
|
|
v.LINKFLAGS_cshlib = v.LINKFLAGS_cxxshlib = ['/DLL']
|
|
|
|
v.cshlib_PATTERN = v.cxxshlib_PATTERN = '%s.dll'
|
|
|
|
v.implib_PATTERN = '%s.lib'
|
|
|
|
v.IMPLIB_ST = '/IMPLIB:%s'
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2016-06-25 23:54:12 +02:00
|
|
|
v.LINKFLAGS_cstlib = []
|
|
|
|
v.cstlib_PATTERN = v.cxxstlib_PATTERN = '%s.lib'
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2016-06-25 23:54:12 +02:00
|
|
|
v.cprogram_PATTERN = v.cxxprogram_PATTERN = '%s.exe'
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2018-04-14 08:39:27 +02:00
|
|
|
v.def_PATTERN = '/def:%s'
|
|
|
|
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
#######################################################################################################
|
|
|
|
##### conf above, build below
|
|
|
|
|
|
|
|
@after_method('apply_link')
|
|
|
|
@feature('c', 'cxx')
|
|
|
|
def apply_flags_msvc(self):
|
|
|
|
"""
|
|
|
|
Add additional flags implied by msvc, such as subsystems and pdb files::
|
|
|
|
|
|
|
|
def build(bld):
|
|
|
|
bld.stlib(source='main.c', target='bar', subsystem='gruik')
|
|
|
|
"""
|
|
|
|
if self.env.CC_NAME != 'msvc' or not getattr(self, 'link_task', None):
|
|
|
|
return
|
|
|
|
|
|
|
|
is_static = isinstance(self.link_task, ccroot.stlink_task)
|
|
|
|
|
|
|
|
subsystem = getattr(self, 'subsystem', '')
|
|
|
|
if subsystem:
|
|
|
|
subsystem = '/subsystem:%s' % subsystem
|
|
|
|
flags = is_static and 'ARFLAGS' or 'LINKFLAGS'
|
|
|
|
self.env.append_value(flags, subsystem)
|
|
|
|
|
|
|
|
if not is_static:
|
|
|
|
for f in self.env.LINKFLAGS:
|
|
|
|
d = f.lower()
|
|
|
|
if d[1:] == 'debug':
|
|
|
|
pdbnode = self.link_task.outputs[0].change_ext('.pdb')
|
|
|
|
self.link_task.outputs.append(pdbnode)
|
|
|
|
|
2014-06-10 22:47:28 +02:00
|
|
|
if getattr(self, 'install_task', None):
|
2016-05-06 15:51:21 +02:00
|
|
|
self.pdb_install_task = self.add_install_files(
|
2016-05-17 19:49:44 +02:00
|
|
|
install_to=self.install_task.install_to, install_from=pdbnode)
|
2011-09-10 11:13:51 +02:00
|
|
|
break
|
|
|
|
|
|
|
|
@feature('cprogram', 'cshlib', 'cxxprogram', 'cxxshlib')
|
|
|
|
@after_method('apply_link')
|
|
|
|
def apply_manifest(self):
|
|
|
|
"""
|
|
|
|
Special linker for MSVC with support for embedding manifests into DLL's
|
|
|
|
and executables compiled by Visual Studio 2005 or probably later. Without
|
|
|
|
the manifest file, the binaries are unusable.
|
|
|
|
See: http://msdn2.microsoft.com/en-us/library/ms235542(VS.80).aspx
|
|
|
|
"""
|
|
|
|
if self.env.CC_NAME == 'msvc' and self.env.MSVC_MANIFEST and getattr(self, 'link_task', None):
|
|
|
|
out_node = self.link_task.outputs[0]
|
|
|
|
man_node = out_node.parent.find_or_declare(out_node.name + '.manifest')
|
|
|
|
self.link_task.outputs.append(man_node)
|
2016-06-16 21:39:50 +02:00
|
|
|
self.env.DO_MANIFEST = True
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2013-02-17 14:09:32 +01:00
|
|
|
def make_winapp(self, family):
|
|
|
|
append = self.env.append_unique
|
|
|
|
append('DEFINES', 'WINAPI_FAMILY=%s' % family)
|
2016-05-22 11:15:00 +02:00
|
|
|
append('CXXFLAGS', ['/ZW', '/TP'])
|
2013-02-17 14:09:32 +01:00
|
|
|
for lib_path in self.env.LIBPATH:
|
|
|
|
append('CXXFLAGS','/AI%s'%lib_path)
|
|
|
|
|
|
|
|
@feature('winphoneapp')
|
|
|
|
@after_method('process_use')
|
|
|
|
@after_method('propagate_uselib_vars')
|
|
|
|
def make_winphone_app(self):
|
2015-04-26 21:00:15 +02:00
|
|
|
"""
|
|
|
|
Insert configuration flags for windows phone applications (adds /ZW, /TP...)
|
|
|
|
"""
|
2013-02-17 14:09:32 +01:00
|
|
|
make_winapp(self, 'WINAPI_FAMILY_PHONE_APP')
|
2017-04-22 21:48:34 +02:00
|
|
|
self.env.append_unique('LINKFLAGS', ['/NODEFAULTLIB:ole32.lib', 'PhoneAppModelHost.lib'])
|
2013-02-17 14:09:32 +01:00
|
|
|
|
|
|
|
@feature('winapp')
|
|
|
|
@after_method('process_use')
|
|
|
|
@after_method('propagate_uselib_vars')
|
|
|
|
def make_windows_app(self):
|
2015-04-26 21:00:15 +02:00
|
|
|
"""
|
|
|
|
Insert configuration flags for windows applications (adds /ZW, /TP...)
|
|
|
|
"""
|
2013-02-17 14:09:32 +01:00
|
|
|
make_winapp(self, 'WINAPI_FAMILY_DESKTOP_APP')
|