]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/build/src/tools/clang-win.jam
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / boost / tools / build / src / tools / clang-win.jam
CommitLineData
7c673cae 1# Copyright Vladimir Prus 2004.
92f5a8d4
TL
2# Copyright Peter Dimov 2018
3#
7c673cae 4# Distributed under the Boost Software License, Version 1.0.
1e59de90
TL
5# (See accompanying file LICENSE.txt
6# or copy at https://www.bfgroup.xyz/b2/LICENSE.txt)
7c673cae 7
7c673cae
FG
8import common ;
9import errors ;
10import feature ;
11import clang ;
12import msvc ;
13import os ;
14import toolset ;
15import generators ;
7c673cae 16import path ;
92f5a8d4 17import regex ;
7c673cae
FG
18
19feature.extend-subfeature toolset clang : platform : win ;
20
1e59de90
TL
21toolset.inherit-generators clang-win <toolset>clang <toolset-clang:platform>win : msvc ;
22toolset.inherit-flags clang-win : msvc : : YLOPTION ;
7c673cae
FG
23toolset.inherit-rules clang-win : msvc ;
24
25# Override default do-nothing generators.
7c673cae
FG
26generators.override clang-win.compile.rc : rc.compile.resource ;
27generators.override clang-win.compile.mc : mc.compile ;
1e59de90
TL
28generators.override clang-win.compile.c.pch : pch.default-c-pch-generator ;
29generators.override clang-win.compile.c++.pch : pch.default-cpp-pch-generator ;
30
7c673cae 31
92f5a8d4 32if [ MATCH (--debug-(clang-(win-)?)?configuration) : [ modules.peek : ARGV ] ]
7c673cae 33{
92f5a8d4 34 local rule .notice ( messages * )
7c673cae 35 {
92f5a8d4 36 ECHO "notice: [clang-win]" $(messages) ;
7c673cae 37 }
92f5a8d4
TL
38}
39else
40{
41 local rule .notice ( messages * )
7c673cae 42 {
7c673cae 43 }
92f5a8d4
TL
44}
45
46# [ get-option archiver : 32 : $(options) ]
47#
48# returns <archiver-32>, or <archiver>
49
50local rule get-option ( option : addr : options * )
51{
52 local r = [ feature.get-values "<$(option)-$(addr)>" : $(options) ] ;
53 r ?= [ feature.get-values "<$(option)>" : $(options) ] ;
54 return $(r) ;
55}
56
57# init
58#
59# options:
60#
61# <assembler>ml.exe (or <assembler-32>, or <assembler-64>)
62# <archiver>lib.exe
63# <manifest-tool>mt.exe
64# <resource-compiler>rc.exe
65# <mc-compiler>mc.exe
66# <idl-compiler>midl.exe
67
68rule init ( version ? : command * : options * )
69{
70 command = [ common.get-invocation-command-nodefault clang-win : clang-cl.exe : $(command) ] ;
71
72 if ! $(command)
7c673cae 73 {
92f5a8d4 74 errors.error "Cannot configure toolset clang-win: no 'clang-cl.exe' command found or given" ;
7c673cae 75 }
92f5a8d4
TL
76
77 local compiler = "\"$(command)\"" ;
78 compiler = "$(compiler:J= )" ;
79
1e59de90
TL
80 local version-output = [ SHELL "$(compiler) -v 2>&1" ] ;
81
82 version ?= [ MATCH "version ([0-9.]+)" : $(version-output) ] ;
83 local target = [ MATCH "Target: ([A-Za-z0-9_]+)" : $(version-output) ] ;
84
85 local default-addr = 32 ;
86 if $(target) = x86_64 { default-addr = 64 ; }
92f5a8d4 87
1e59de90 88 .notice "using compiler '$(compiler)', version '$(version)', target '$(target)', default address-model=$(default-addr)" ;
92f5a8d4 89
1e59de90 90 local condition = [ common.check-init-parameters clang-win : version $(version) ] ;
92f5a8d4
TL
91
92 common.handle-options clang-win : $(condition) : $(command) : $(options) ;
1e59de90 93
92f5a8d4 94 for local addr in 32 64
7c673cae 95 {
1e59de90
TL
96 for local arch in x86 arm
97 {
98 local clang-arch ;
99 if $(arch) = x86
100 {
101 if $(addr) = 32 { clang-arch = i386 ; } else { clang-arch = x86_64 ; }
102 }
103 else if $(arch) = arm
104 {
105 if $(addr) = 32 { clang-arch = arm ; } else { clang-arch = aarch64 ; }
106 }
92f5a8d4 107
1e59de90 108 local config = [ SPLIT_BY_CHARACTERS [ SHELL "$(compiler) --target=$(clang-arch)-pc-windows-msvc -### foo.obj /link 2>&1" ] : "\n" ] ;
92f5a8d4 109
1e59de90
TL
110 local match = 1 ;
111 local items ;
92f5a8d4 112
1e59de90 113 while $(match)
7c673cae 114 {
1e59de90
TL
115 match = [ MATCH "^ *(\"[^\"]*\")(.*)" : $(config) ] ;
116
117 if $(match)
118 {
119 items += $(match[1]) ;
120 config = $(match[2]) ;
121 }
7c673cae 122 }
7c673cae 123
1e59de90 124 local asm ;
f67539c2 125
1e59de90 126 if $(items)
f67539c2 127 {
1e59de90
TL
128 asm = [ regex.replace $(items[1]) "x64\\\\+link\\.exe" "x64\\ml64.exe" ] ;
129 asm = [ regex.replace $(asm) "x86\\\\+link\\.exe" "x86\\ml.exe" ] ;
130 asm = [ regex.replace $(asm) "arm64\\\\+link\\.exe" "arm64\\armasm64.exe" ] ;
131 asm = [ regex.replace $(asm) "arm\\\\+link\\.exe" "arm\\armasm.exe" ] ;
132
133 if ! [ MATCH "(ml\\.exe)" "(ml64\\.exe)" "(armasm64\\.exe)" "(armasm\\.exe)" : $(asm) ]
134 {
135 asm = ;
136 }
f67539c2 137 }
7c673cae 138
1e59de90
TL
139 local assembler = [ get-option "assembler" : $(addr) : $(options) ] ;
140 assembler ?= $(asm) ;
141 if $(arch) = x86
142 {
143 if $(addr) = 32 { assembler ?= ml.exe ; } else { assembler ?= ml64.exe ; }
144 }
145 else if $(arch) = arm
146 {
147 if $(addr) = 32 { assembler ?= armasm.exe ; } else { assembler ?= armasm64.exe ; }
148 }
7c673cae 149
1e59de90 150 local linker ;
7c673cae 151
1e59de90
TL
152 if $(items)
153 {
154 linker = [ regex.replace $(items[1]) "\\\\+HostX64\\\\+x86\\\\+" "\\HostX86\\x86\\" ] ;
155 }
7c673cae 156
1e59de90 157 .notice "$(arch)-$(addr):" "using linker '$(linker)'" ;
7c673cae 158
1e59de90 159 local archiver = [ get-option "archiver" : $(addr) : $(options) ] ;
7c673cae 160
1e59de90
TL
161 if $(linker)
162 {
163 archiver ?= "$(linker) /lib" ;
164 }
165 archiver ?= lib.exe ;
166
167 .notice "$(arch)-$(addr):" "using assembler '$(assembler)'" ;
168 .notice "$(arch)-$(addr):" "using archiver '$(archiver)'" ;
169
170 local manifest-tool = [ get-option "manifest-tool" : $(addr) : $(options) ] ;
171 local resource-compiler = [ get-option "resource-compiler" : $(addr) : $(options) ] ;
172 local mc-compiler = [ get-option "mc-compiler" : $(addr) : $(options) ] ;
173 local idl-compiler = [ get-option "idl-compiler" : $(addr) : $(options) ] ;
7c673cae 174
1e59de90 175 for local item in $(items)
92f5a8d4 176 {
1e59de90
TL
177 match = [ MATCH "\"-libpath:(.*)\\\\+Lib\\\\.*\\\\um\\\\+x(.*)\"" : $(item) ] ;
178
179 if $(match)
180 {
181 local sdk-path = "$(match[1])\\bin\\x$(match[2])" ;
182 .notice "$(arch)-$(addr):" "using SDK path '$(sdk-path)'" ;
183
184 manifest-tool ?= "\"$(sdk-path)\\mt.exe\"" ;
185 resource-compiler ?= "\"$(sdk-path)\\rc.exe\"" ;
186 mc-compiler ?= "\"$(sdk-path)\\mc.exe\"" ;
187 idl-compiler ?= "\"$(sdk-path)\\midl.exe\"" ;
188 }
189 }
190
191 manifest-tool ?= mt.exe ;
192 resource-compiler ?= rc.exe ;
193 mc-compiler ?= mc.exe ;
194 idl-compiler ?= midl.exe ;
195
196 .notice "$(arch)-$(addr):" "using manifest-tool '$(manifest-tool)'" ;
197 .notice "$(arch)-$(addr):" "using resource-compiler '$(resource-compiler)'" ;
198 .notice "$(arch)-$(addr):" "using mc-compiler '$(mc-compiler)'" ;
199 .notice "$(arch)-$(addr):" "using idl-compiler '$(idl-compiler)'" ;
7c673cae 200
1e59de90
TL
201 local linker-arch ;
202 if $(arch) = x86
203 {
204 if $(addr) = 32 { linker-arch = x86 ; } else { linker-arch = x64 ; }
205 }
206 else if $(arch) = arm
207 {
208 if $(addr) = 32 { linker-arch = arm ; } else { linker-arch = arm64 ; }
209 }
210
211 local cond = "$(condition)/<architecture>$(arch)/<address-model>$(addr)" ;
212 if $(addr) = $(default-addr) && $(arch) = x86
213 {
214 cond += "$(condition)/<architecture>/<address-model>" ;
215 cond += "$(condition)/<architecture>/<address-model>$(addr)" ;
216 cond += "$(condition)/<architecture>$(arch)/<address-model>" ;
92f5a8d4 217 }
7c673cae 218
1e59de90
TL
219 toolset.flags clang-win.compile .CC $(cond) : $(compiler) --target=$(clang-arch)-pc-windows-msvc ;
220 toolset.flags clang-win.link .LD $(cond) : $(compiler) --target=$(clang-arch)-pc-windows-msvc ;
221 toolset.flags clang-win.link LINKOPT $(cond) : /link ;
222 toolset.flags clang-win.link LINKFLAGS $(cond) : "/incremental:no" "/manifest" "/machine:$(linker-arch)" ;
223 if $(arch) = x86
224 {
225 toolset.flags clang-win.compile .ASM $(cond) : $(assembler) -nologo -c -Zp4 -Cp -Cx ;
226 toolset.flags clang-win.compile .ASM_OUTPUT $(cond) : -Fo ;
227 }
228 else if $(arch) = arm
229 {
230 toolset.flags clang-win.compile .ASM $(cond) : $(assembler) -machine $(arch) ;
231 toolset.flags clang-win.compile .ASM_OUTPUT $(cond) : -o ;
232 }
233 toolset.flags clang-win.archive .LD $(cond) : $(archiver) /nologo ;
234 toolset.flags clang-win.link .MT $(cond) : $(manifest-tool) -nologo ;
235 toolset.flags clang-win.compile .MC $(cond) : $(mc-compiler) ;
236 toolset.flags clang-win.compile .RC $(cond) : $(resource-compiler) ;
237 toolset.flags clang-win.compile .IDL $(cond) : $(idl-compiler) ;
238 }
92f5a8d4 239 }
f67539c2
TL
240
241 toolset.flags clang-win.link LIBRARY_OPTION <toolset>clang-win : "" : unchecked ;
1e59de90
TL
242
243 # Enable response file control
244 toolset.flags clang-win RESPONSE_FILE_SUB <response-file>auto : a ;
245 toolset.flags clang-win RESPONSE_FILE_SUB <response-file>file : f ;
246 toolset.flags clang-win RESPONSE_FILE_SUB <response-file>contents : c ;
92f5a8d4 247}