msvc

Microsoft Visual C++/Intel C++ compiler support

If you get detection problems, first try any of the following:

chcp 65001
set PYTHONIOENCODING=...
set PYTHONLEGACYWINDOWSSTDIO=1

Usage:

$ waf configure --msvc_version="msvc 10.0,msvc 9.0" --msvc_target="x64"

or:

def configure(conf):
        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']
        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.

To force testing all the configurations that are not used, use the --no-msvc-lazy option or set conf.env.MSVC_LAZY_AUTODETECT=False.

Supported platforms: ia64, x64, x86, x86_amd64, x86_ia64, x86_arm, amd64_x86, amd64_arm

Compilers supported:

  • msvc => Visual Studio, versions 6.0 (VC 98, VC .NET 2002) to 15 (Visual Studio 2017)

  • wsdk => Windows SDK, versions 6.0, 6.1, 7.0, 7.1, 8.0

  • icl => Intel compiler, versions 9, 10, 11, 13

  • winphone => Visual Studio to target Windows Phone 8 native (version 8.0 for now)

  • 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.

waflib.Tools.msvc.after_method(*k)[source]

Decorator that registers a task generator method which will be executed after the functions of given name(s):

from waflib.TaskGen import feature, after
@feature('myfeature')
@after_method('fun2')
def fun1(self):
        print('feature 1!')
@feature('myfeature')
def fun2(self):
        print('feature 2!')
def build(bld):
        bld(features='myfeature')
Parameters

k (list of string) – method names

waflib.Tools.msvc.feature(*k)

Decorator that registers a task generator method that will be executed when the object attribute feature contains the corresponding key(s):

from waflib.TaskGen import feature
@feature('myfeature')
def myfunction(self):
        print('that is my feature!')
def build(bld):
        bld(features='myfeature')
Parameters

k (list of string) – feature names

waflib.Tools.msvc.conf(f)

Decorator: attach new configuration functions to waflib.Build.BuildContext and waflib.Configure.ConfigurationContext. The methods bound will accept a parameter named ‘mandatory’ to disable the configuration errors:

def configure(conf):
        conf.find_program('abc', mandatory=False)
Parameters

f (function) – method to bind

waflib.Tools.msvc.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']

importlibs provided by MSVC/Platform SDK. Do NOT search them

waflib.Tools.msvc.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')]

List of msvc platforms

waflib.Tools.msvc.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

waflib.Tools.msvc.all_icl_platforms = [('intel64', 'amd64'), ('em64t', 'amd64'), ('ia32', 'x86'), ('Itanium', 'ia64')]

List of icl platforms

waflib.Tools.msvc.setup_msvc(conf, versiondict)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

Checks installed compilers and targets and returns the first combination from the user’s options, env, or the global supported lists that checks.

Parameters

versiondict (dict(string -> dict(string -> target_compiler)) – dict(platform -> dict(architecture -> configuration))

Returns

the compiler, revision, path, include dirs, library paths and target architecture

Return type

tuple of strings

waflib.Tools.msvc.get_msvc_version(conf, compiler, version, target, vcvars)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

Checks that an installed compiler actually runs and uses vcvars to obtain the environment needed by the compiler.

Parameters
  • compiler – compiler type, for looking up the executable name

  • version – compiler version, for debugging only

  • target – target architecture

  • vcvars – batch file to run to check the environment

Returns

the location of the compiler executable, the location of include dirs, and the library paths

Return type

tuple of strings

waflib.Tools.msvc.gather_wince_supported_platforms()[source]

Checks SmartPhones SDKs

Parameters

versions (list) – list to modify

class waflib.Tools.msvc.target_compiler(ctx, compiler, cpu, version, bat_target, bat, callback=None)[source]

Wrap a compiler configuration; call evaluate() to determine whether the configuration is usable.

__init__(ctx, compiler, cpu, version, bat_target, bat, callback=None)[source]
Parameters
  • ctx – configuration context to use to eventually get the version environment

  • compiler – compiler name

  • cpu – target cpu

  • version – compiler version number

  • bat_target

    ?

  • bat – path to the batch file to run

waflib.Tools.msvc.gather_wsdk_versions(conf, versions)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

Use winreg to add the msvc versions to the input list

Parameters

versions (list) – list to modify

waflib.Tools.msvc.gather_msvc_targets(conf, versions, version, vc_path)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

waflib.Tools.msvc.gather_wince_targets(conf, versions, version, vc_path, vsvars, supported_platforms)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

waflib.Tools.msvc.gather_winphone_targets(conf, versions, version, vc_path, vsvars)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

waflib.Tools.msvc.gather_vswhere_versions(conf, versions)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

waflib.Tools.msvc.gather_msvc_versions(conf, versions)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

waflib.Tools.msvc.gather_icl_versions(conf, versions)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

Checks ICL compilers

Parameters

versions (list) – list to modify

waflib.Tools.msvc.gather_intel_composer_versions(conf, versions)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

Checks ICL compilers that are part of Intel Composer Suites

Parameters

versions (list) – list to modify

waflib.Tools.msvc.detect_msvc(self)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

waflib.Tools.msvc.get_msvc_versions(self)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

Returns

platform to compiler configurations

Return type

dict

waflib.Tools.msvc.find_lt_names_msvc(self, libname, is_static=False)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

Win32/MSVC specific code to glean out information from libtool la files. 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)

waflib.Tools.msvc.libname_msvc(self, libname, is_static=False)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

waflib.Tools.msvc.check_lib_msvc(self, libname, is_static=False, uselib_store=None)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

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. This is ok since msvc doesn’t have any special linker flag to select static libs (no env.STLIB_MARKER)

waflib.Tools.msvc.check_libs_msvc(self, libnames, is_static=False)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

waflib.Tools.msvc.configure(conf)[source]

Configuration methods to call for detecting msvc

waflib.Tools.msvc.no_autodetect(conf)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

waflib.Tools.msvc.autodetect(conf, arch=False)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

waflib.Tools.msvc.find_msvc(conf)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext Due to path format limitations, limit operation only to native Win32. Yeah it sucks.

waflib.Tools.msvc.visual_studio_add_flags(self)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext visual studio flags found in the system environment

waflib.Tools.msvc.msvc_common_flags(conf)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

Setup the flags required for executing the msvc compiler

waflib.Tools.msvc.apply_flags_msvc(self)[source]

Task generator method

Add additional flags implied by msvc, such as subsystems and pdb files:

def build(bld):
        bld.stlib(source='main.c', target='bar', subsystem='gruik')
Feature

c, cxx

waflib.Tools.msvc.apply_manifest(self)[source]

Task generator method

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

Feature

cprogram, cshlib, cxxprogram, cxxshlib

waflib.Tools.msvc.make_winphone_app(self)[source]

Task generator method

Insert configuration flags for windows phone applications (adds /ZW, /TP…)

Feature

winphoneapp

waflib.Tools.msvc.make_windows_app(self)[source]

Task generator method

Insert configuration flags for windows applications (adds /ZW, /TP…)

Feature

winapp

Features defined in this module: