📄 msvc.jam
字号:
# Copyright (c) 2003 David Abrahams.# Copyright (c) 2005 Vladimir Prus.# Copyright (c) 2005 Alexey Pakhunov.# Copyright (c) 2006 Bojan Resnik.# Copyright (c) 2006 Ilya Sokolov.# Copyright (c) 2007 Rene Rivera# Copyright (c) 2008 Jurko Gospodnetic## Use, modification and distribution is subject to the Boost Software# License Version 1.0. (See accompanying file LICENSE_1_0.txt or# http://www.boost.org/LICENSE_1_0.txt)################################################################################## MSVC Boost Build toolset module.# --------------------------------## All toolset versions need to have their location either auto-detected or# explicitly specified except for the special 'default' version that expects the# environment to find the needed tools or report an error.#################################################################################import "class" : new ;import common ;import errors ;import feature ;import generators ;import mc ;import midl ;import os ;import path ;import pch ;import property ;import rc ;import toolset ;import type ;################################################################################## Public rules.################################################################################## Initialize a specific toolset version configuration. As the result, path to# compiler and, possible, program names are set up, and will be used when that# version of compiler is requested. For example, you might have:## using msvc : 6.5 : cl.exe ;# using msvc : 7.0 : Y:/foo/bar/cl.exe ;## The version parameter may be ommited:## using msvc : : Z:/foo/bar/cl.exe ;## The following keywords have special meanings when specified as versions:# - all - all detected but not yet used versions will be marked as used# with their default options.# - default - this is an equivalent to an empty version.## Depending on a supplied version, detected configurations and presence 'cl.exe'# in the path different results may be achieved. The following table describes# the possible scenarios:## Nothing "x.y"# Passed Nothing "x.y" detected, detected,# version detected detected cl.exe in path cl.exe in path## default Error Use "x.y" Create "default" Use "x.y"# all None Use all None Use all# x.y - Use "x.y" - Use "x.y"# a.b Error Error Create "a.b" Create "a.b"## "x.y" - refers to a detected version;# "a.b" - refers to an undetected version.## FIXME: Currently the command parameter and the <compiler> property parameter# seem to overlap in duties. Remove this duplication. This seems to be related# to why someone started preparing to replace init with configure rules.#rule init ( # The msvc version being configured. When omitted the tools invoked when no # explicit version is given will be configured. version ? # The command used to invoke the compiler. If not specified: # - if version is given, default location for that version will be # searched # # - if version is not given, default locations for MSVC 9.0, 8.0, 7.1, 7.0 # and 6.* will be searched # # - if compiler is not found in the default locations, PATH will be # searched. : command * # Options may include: # # All options shared by multiple toolset types as handled by the # common.handle-options() rule, e.g. <cflags>, <compileflags>, <cxxflags>, # <fflags> & <linkflags>. # # <assembler> # <compiler> # <idl-compiler> # <linker> # <mc-compiler> # <resource-compiler> # Exact tool names to be used by this msvc toolset configuration. # # <compiler-filter> # Command through which to pipe the output of running the compiler. # For example to pass the output to STLfilt. # # <setup> # Global setup command to invoke before running any of the msvc tools. # It will be passed additional option parameters depending on the actual # target platform. # # <setup-amd64> # <setup-i386> # <setup-ia64> # Platform specific setup command to invoke before running any of the # msvc tools used when builing a target for a specific platform, e.g. # when building a 32 or 64 bit executable. : options *){ if $(command) { options += <command>$(command) ; } configure $(version) : $(options) ;}# 'configure' is a newer version of 'init'. The parameter 'command' is passed as# a part of the 'options' list. See the 'init' rule comment for more detailed# information.#rule configure ( version ? : options * ){ switch $(version) { case "all" : if $(options) { errors.error "MSVC toolset configuration: options should be" "empty when '$(version)' is specified." ; } # Configure (i.e. mark as used) all registered versions. local all-versions = [ $(.versions).all ] ; if ! $(all-versions) { if $(.debug-configuration) { ECHO "notice: [msvc-cfg] Asked to configure all registered" "msvc toolset versions when there are none currently" "registered." ; } } else { for local v in $(all-versions) { # Note that there is no need to skip already configured # versions here as this will request configure-really rule # to configure the version using default options which will # in turn cause it to simply do nothing in case the version # has already been configured. configure-really $(v) ; } } case "default" : configure-really : $(options) ; case * : configure-really $(version) : $(options) ; }}# Sets up flag definitions dependent on the compiler version used.# - 'version' is the version of compiler in N.M format.# - 'conditions' is the property set to be used as flag conditions.# - 'toolset' is the toolset for which flag settings are to be defined.# This makes the rule reusable for other msvc-option-compatible compilers.#rule configure-version-specific ( toolset : version : conditions ){ toolset.push-checking-for-flags-module unchecked ; # Starting with versions 7.0, the msvc compiler have the /Zc:forScope and # /Zc:wchar_t options that improve C++ standard conformance, but those # options are off by default. If we are sure that the msvc version is at # 7.*, add those options explicitly. We can be sure either if user specified # version 7.* explicitly or if we auto-detected the version ourselves. if ! [ MATCH ^(6\\.) : $(version) ] { toolset.flags $(toolset).compile CFLAGS $(conditions) : /Zc:forScope /Zc:wchar_t ; toolset.flags $(toolset).compile.c++ C++FLAGS $(conditions) : /wd4675 ; # Explicitly disable the 'function is deprecated' warning. Some msvc # versions have a bug, causing them to emit the deprecation warning even # with /W0. toolset.flags $(toolset).compile CFLAGS $(conditions)/<warnings>off : /wd4996 ; if [ MATCH ^([78]\\.) : $(version) ] { # 64-bit compatibility warning deprecated since 9.0, see # http://msdn.microsoft.com/en-us/library/yt4xw8fh.aspx toolset.flags $(toolset).compile CFLAGS $(conditions)/<warnings>all : /Wp64 ; } } # # Processor-specific optimization. # if [ MATCH ^([67]) : $(version) ] { # 8.0 deprecates some of the options. toolset.flags $(toolset).compile CFLAGS $(conditions)/<optimization>speed $(conditions)/<optimization>space : /Ogiy /Gs ; toolset.flags $(toolset).compile CFLAGS $(conditions)/<optimization>speed : /Ot ; toolset.flags $(toolset).compile CFLAGS $(conditions)/<optimization>space : /Os ; toolset.flags $(toolset).compile CFLAGS $(conditions)/$(.cpu-arch-i386)/<instruction-set> : /GB ; toolset.flags $(toolset).compile CFLAGS $(conditions)/$(.cpu-arch-i386)/<instruction-set>i386 : /G3 ; toolset.flags $(toolset).compile CFLAGS $(conditions)/$(.cpu-arch-i386)/<instruction-set>i486 : /G4 ; toolset.flags $(toolset).compile CFLAGS $(conditions)/$(.cpu-arch-i386)/<instruction-set>$(.cpu-type-g5) : /G5 ; toolset.flags $(toolset).compile CFLAGS $(conditions)/$(.cpu-arch-i386)/<instruction-set>$(.cpu-type-g6) : /G6 ; toolset.flags $(toolset).compile CFLAGS $(conditions)/$(.cpu-arch-i386)/<instruction-set>$(.cpu-type-g7) : /G7 ; # Improve floating-point accuracy. Otherwise, some of C++ Boost's "math" # tests will fail. toolset.flags $(toolset).compile CFLAGS $(conditions) : /Op ; # 7.1 and below have single-threaded static RTL. toolset.flags $(toolset).compile CFLAGS $(conditions)/<runtime-debugging>off/<runtime-link>static/<threading>single : /ML ; toolset.flags $(toolset).compile CFLAGS $(conditions)/<runtime-debugging>on/<runtime-link>static/<threading>single : /MLd ; } else { # 8.0 and above adds some more options. toolset.flags $(toolset).compile CFLAGS $(conditions)/$(.cpu-arch-amd64)/<instruction-set> : /favor:blend ; toolset.flags $(toolset).compile CFLAGS $(conditions)/$(.cpu-arch-amd64)/<instruction-set>$(.cpu-type-em64t) : /favor:EM64T ; toolset.flags $(toolset).compile CFLAGS $(conditions)/$(.cpu-arch-amd64)/<instruction-set>$(.cpu-type-amd64) : /favor:AMD64 ; # 8.0 and above only has multi-threaded static RTL. toolset.flags $(toolset).compile CFLAGS $(conditions)/<runtime-debugging>off/<runtime-link>static/<threading>single : /MT ; toolset.flags $(toolset).compile CFLAGS $(conditions)/<runtime-debugging>on/<runtime-link>static/<threading>single : /MTd ; } toolset.pop-checking-for-flags-module ;}# Registers this toolset including all of its flags, features & generators. Does# nothing on repeated calls.#rule register-toolset ( ){ if ! msvc in [ feature.values toolset ] { register-toolset-really ; }}# Declare action for creating static libraries. If library exists, remove it# before adding files. See# http://article.gmane.org/gmane.comp.lib.boost.build/4241 for rationale.if [ os.name ] in NT{ # The 'DEL' command would issue a message to stdout if the file does not # exist, so need a check. actions archive { if exist "$(<[1])" DEL "$(<[1])" $(.LD) $(AROPTIONS) /out:"$(<[1])" @"@($(<[1]:W).rsp:E=$(.nl)"$(>)" $(.nl)$(LIBRARIES_MENTIONED_BY_FILE) $(.nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST).lib" $(.nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA).lib")" }}else{ actions archive { $(.RM) "$(<[1])" $(.LD) $(AROPTIONS) /out:"$(<[1])" @"@($(<[1]:W).rsp:E=$(.nl)"$(>)" $(.nl)$(LIBRARIES_MENTIONED_BY_FILE) $(.nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST).lib" $(.nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA).lib")" }}# For the assembler the following options are turned on by default:## -coff generate COFF format object file (compatible with cl.exe output)# -Zp4 align structures to 4 bytes# -Cp preserve case of user identifiers# -Cx preserve case in publics, externs#actions compile.asm{ $(.ASM) -nologo -c -coff -Zp4 -Cp -Cx $(USER_ASMFLAGS) -Fo "$(<:W)" "$(>:W)"}rule compile.c ( targets + : sources * : properties * ){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -