1# Copyright Vladimir Prus 2004. 2# Distributed under the Boost Software License, Version 1.0. 3# (See accompanying file LICENSE_1_0.txt 4# or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6# Importing common is needed because the rules we inherit here depend on it. 7# That is nasty. 8import common ; 9import errors ; 10import feature ; 11import clang ; 12import msvc ; 13import os ; 14import toolset ; 15import generators ; 16import type ; 17import path ; 18import set ; 19 20feature.extend-subfeature toolset clang : platform : win ; 21 22toolset.inherit-generators clang-win <toolset>clang <toolset-clang:platform>win : msvc ; 23toolset.inherit-flags clang-win : msvc : <debug-symbols>on/<debug-store>object <asynch-exceptions>off <asynch-exceptions>on : YLOPTION ; 24toolset.inherit-rules clang-win : msvc ; 25 26# Override default do-nothing generators. 27generators.override clang-win.compile.c.pch : pch.default-c-pch-generator ; 28generators.override clang-win.compile.c++.pch : pch.default-cpp-pch-generator ; 29generators.override clang-win.compile.rc : rc.compile.resource ; 30generators.override clang-win.compile.mc : mc.compile ; 31 32toolset.flags clang-win.compile PCH_SOURCE <pch>on : <pch-source> ; 33 34toolset.flags clang-win.compile CFLAGS <debug-symbols>on/<debug-store>object : "" ; 35 36# Initializes the intel toolset for windows 37rule init ( version ? : # the compiler version 38 command * : # the command to invoke the compiler itself 39 options * # Additional option: <compatibility> 40 # either 'vc6', 'vc7', 'vc7.1' 41 # or 'native'(default). 42 ) 43{ 44 local compatibility = 45 [ feature.get-values <compatibility> : $(options) ] ; 46 local condition = [ common.check-init-parameters clang-win 47 : version $(version) : compatibility $(compatibility) ] ; 48 49 if ! $(compatibility) 50 { 51 import errors ; 52 errors.error "Please set <compatibility> property for visual studio version!" ; 53 } 54 local vc_version = [ MATCH vc([0-9]+) : $(compatibility) ] ; 55 if ! $(vc_version) 56 { 57 errors.user-error "Invalid value for compatibility option:" 58 $(compatibility) ; 59 } 60 61 local m = [ MATCH ([0-9]+).* : $(version) ] ; 62 local major = $(m[1]) ; 63 64 command = [ common.get-invocation-command clang-win : clang-cl.exe : 65 $(command) ] ; 66 67 common.handle-options clang-win : $(condition) : $(command) : $(options) ; 68 69 local setup ; 70 setup = [ get-visual-studio-vcvars $(vc_version) ] ; # Get visual studio vcvars bat file path 71 72 local target_types ; 73 if [ MATCH ^(AMD64) : [ os.environ PROCESSOR_ARCHITECTURE ] ] 74 { 75 target_types = x86 amd64 ; 76 } 77 else 78 { 79 target_types = x86 x86_amd64 ; 80 } 81 82 for local c in $(target_types) 83 { 84 local cpu-conditions ; 85 local setup-call ; 86 setup-call = "call \""$(setup)"\" $(c) > nul " ; 87 cpu-conditions = $(condition)/$(.cpu-arch-$(c)) ; 88 89 if [ os.name ] = NT 90 { 91 setup-call = $(setup-call)" 92 " ; 93 } 94 else 95 { 96 setup-call = "cmd /S /C "$(setup-call)" \"&&\" " ; 97 } 98 99 if $(.debug-configuration) 100 { 101 for local cpu-condition in $(cpu-conditions) 102 { 103 ECHO "notice: [clang-cfg] condition: '$(cpu-condition)', setup: '$(setup-call)'" ; 104 } 105 } 106 107 local compiler ; 108 compiler = [ path.native $(command) ] ; 109 compiler = "\"$(compiler)\"" ; 110 111 toolset.flags clang-win.compile .CC $(cpu-conditions) : $(setup-call)$(compiler) ; 112 toolset.flags clang-win.link .LD $(cpu-conditions) : $(setup-call)link /nologo ; 113 toolset.flags clang-win.archive .LD $(cpu-conditions) : $(setup-call)link /lib /nologo ; 114 toolset.flags clang-win.link .MT $(cpu-conditions) : $(setup-call)mt -nologo ; 115 toolset.flags clang-win.compile .MC $(cpu-conditions) : $(setup-call)mc ; 116 toolset.flags clang-win.compile .RC $(cpu-conditions) : $(setup-call)rc ; 117 } 118 119 120 local C++FLAGS ; 121 122 if $(vc_version) = 10 123 { 124 C++FLAGS += -fmsc-version=1600 ; 125 } 126 else if $(vc_version) = 11 127 { 128 C++FLAGS += -fmsc-version=1700 ; 129 } 130 else if $(vc_version) = 12 131 { 132 C++FLAGS += -fmsc-version=1800 ; 133 } 134 135 toolset.flags clang-win CFLAGS $(condition) : $(C++FLAGS) ; 136 137 msvc.configure-version-specific clang-win : $(vc_version) : $(condition) ; 138} 139 140local rule get-visual-studio-vcvars ( version ) 141{ 142 local env_variable_name ; 143 env_variable_name = "VS"$(version:U)"0COMNTOOLS" ; 144 145 local vc-path = [ os.environ $(env_variable_name) ] ; 146 vc-path = [ path.join $(vc-path) "../../VC/vcvarsall.bat" ] ; 147 path.native $(vc-path) ; 148} 149 150 151if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] 152{ 153 .debug-configuration = true ; 154} 155 156# Copied from msvc.jam 157# Supported CPU architectures. 158.cpu-arch-x86 = 159 <architecture>/<address-model> 160 <architecture>/<address-model>32 161 <architecture>x86/<address-model> 162 <architecture>x86/<address-model>32 ; 163 164.cpu-arch-amd64 = 165 <architecture>/<address-model>64 166 <architecture>x86/<address-model>64 ; 167 168.cpu-arch-x86_amd64 = 169 <architecture>/<address-model>64 170 <architecture>x86/<address-model>64 ; 171 172# toolset.flags clang-win.link LIBRARY_OPTION <toolset>clang : "" ; 173 174toolset.flags clang-win YLOPTION ; 175 176