1 # Copyright Vladimir Prus 2004.
2 # Copyright Peter Dimov 2018
4 # Distributed under the Boost Software License, Version 1.0.
5 # (See accompanying file LICENSE_1_0.txt
6 # or copy at http://www.boost.org/LICENSE_1_0.txt)
19 feature.extend-subfeature toolset clang : platform : win ;
21 toolset.inherit-generators clang-win <toolset>clang <toolset-clang:platform>win : msvc : msvc.compile.c.pch msvc.compile.c++.pch ;
22 toolset.inherit-flags clang-win : msvc ;
23 toolset.inherit-rules clang-win : msvc ;
25 # Override default do-nothing generators.
26 generators.override clang-win.compile.rc : rc.compile.resource ;
27 generators.override clang-win.compile.mc : mc.compile ;
29 if [ MATCH (--debug-(clang-(win-)?)?configuration) : [ modules.peek : ARGV ] ]
31 local rule .notice ( messages * )
33 ECHO "notice: [clang-win]" $(messages) ;
38 local rule .notice ( messages * )
43 # [ get-option archiver : 32 : $(options) ]
45 # returns <archiver-32>, or <archiver>
47 local rule get-option ( option : addr : options * )
49 local r = [ feature.get-values "<$(option)-$(addr)>" : $(options) ] ;
50 r ?= [ feature.get-values "<$(option)>" : $(options) ] ;
58 # <assembler>ml.exe (or <assembler-32>, or <assembler-64>)
60 # <manifest-tool>mt.exe
61 # <resource-compiler>rc.exe
63 # <idl-compiler>midl.exe
65 rule init ( version ? : command * : options * )
67 command = [ common.get-invocation-command-nodefault clang-win : clang-cl.exe : $(command) ] ;
71 errors.error "Cannot configure toolset clang-win: no 'clang-cl.exe' command found or given" ;
74 local compiler = "\"$(command)\"" ;
75 compiler = "$(compiler:J= )" ;
77 version ?= [ MATCH "version ([0-9.]+)" : [ SHELL "$(compiler) -v 2>&1" ] ] ;
79 .notice "using compiler '$(compiler)', version '$(version)'" ;
81 local condition = [ common.check-init-parameters clang-win : version $(version) ] ;
83 common.handle-options clang-win : $(condition) : $(command) : $(options) ;
85 for local addr in 32 64
87 local config = [ SPLIT_BY_CHARACTERS [ SHELL "$(compiler) -m$(addr) -### foo.obj /link 2>&1" ] : "\n" ] ;
94 match = [ MATCH "^ *(\"[^\"]*\")(.*)" : $(config) ] ;
98 items += $(match[1]) ;
99 config = $(match[2]) ;
103 local ml = [ regex.replace $(items[1]) "x64\\\\+link\\.exe" "x64\\ml64.exe" ] ;
104 ml = [ regex.replace $(ml) "x86\\\\+link\\.exe" "x86\\ml.exe" ] ;
106 if ! [ MATCH "(ml\\.exe)" "(ml64\\.exe)" : $(ml) ]
111 local assembler = [ get-option "assembler" : $(addr) : $(options) ] ;
113 if $(addr) = 32 { assembler ?= ml.exe ; } else { assembler ?= ml64.exe ; }
115 local link = [ regex.replace $(items[1]) "\\\\+HostX64\\\\+x86\\\\+" "\\HostX86\\x86\\" ] ;
117 local archiver = [ get-option "archiver" : $(addr) : $(options) ] ;
118 archiver ?= "$(link) /lib" ;
119 archiver ?= lib.exe ;
121 .notice "$(addr):" "using assembler '$(assembler)'" ;
122 .notice "$(addr):" "using archiver '$(archiver)'" ;
124 local manifest-tool = [ get-option "manifest-tool" : $(addr) : $(options) ] ;
125 local resource-compiler = [ get-option "resource-compiler" : $(addr) : $(options) ] ;
126 local mc-compiler = [ get-option "mc-compiler" : $(addr) : $(options) ] ;
127 local idl-compiler = [ get-option "idl-compiler" : $(addr) : $(options) ] ;
129 for local item in $(items)
131 match = [ MATCH "\"-libpath:(.*)\\\\+Lib\\\\.*\\\\um\\\\+x(.*)\"" : $(item) ] ;
135 local sdk-path = "$(match[1])\\bin\\x$(match[2])" ;
136 .notice "$(addr):" "using SDK path '$(sdk-path)'" ;
138 manifest-tool ?= "\"$(sdk-path)\\mt.exe\"" ;
139 resource-compiler ?= "\"$(sdk-path)\\rc.exe\"" ;
140 mc-compiler ?= "\"$(sdk-path)\\mc.exe\"" ;
141 idl-compiler ?= "\"$(sdk-path)\\midl.exe\"" ;
145 manifest-tool ?= mt.exe ;
146 resource-compiler ?= rc.exe ;
147 mc-compiler ?= mc.exe ;
148 idl-compiler ?= midl.exe ;
150 .notice "$(addr):" "using manifest-tool '$(manifest-tool)'" ;
151 .notice "$(addr):" "using resource-compiler '$(resource-compiler)'" ;
152 .notice "$(addr):" "using mc-compiler '$(mc-compiler)'" ;
153 .notice "$(addr):" "using idl-compiler '$(idl-compiler)'" ;
155 local cond = "$(condition)/<architecture>/<address-model>$(addr)" "$(condition)/<architecture>x86/<address-model>$(addr)" ;
156 if $(addr) = 32 { cond += "$(condition)/<architecture>/<address-model>" ; }
158 toolset.flags clang-win.compile .CC $(cond) : $(compiler) -m$(addr) ;
159 toolset.flags clang-win.link .LD $(cond) : $(compiler) -m$(addr) /link "/incremental:no" "/manifest" ;
160 toolset.flags clang-win.compile .ASM $(cond) : $(assembler) -nologo ;
161 toolset.flags clang-win.archive .LD $(cond) : $(archiver) /nologo ;
162 toolset.flags clang-win.link .MT $(cond) : $(manifest-tool) -nologo ;
163 toolset.flags clang-win.compile .MC $(cond) : $(mc-compiler) ;
164 toolset.flags clang-win.compile .RC $(cond) : $(resource-compiler) /nologo ;
165 toolset.flags clang-win.compile .IDL $(cond) : $(idl-compiler) ;