]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/tools/clang-win.jam
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / tools / build / src / tools / clang-win.jam
1 # Copyright Vladimir Prus 2004.
2 # Copyright Peter Dimov 2018
3 #
4 # Distributed under the Boost Software License, Version 1.0.
5 # (See accompanying file LICENSE.txt
6 # or copy at https://www.bfgroup.xyz/b2/LICENSE.txt)
7
8 import common ;
9 import errors ;
10 import feature ;
11 import clang ;
12 import msvc ;
13 import os ;
14 import toolset ;
15 import generators ;
16 import path ;
17 import regex ;
18
19 feature.extend-subfeature toolset clang : platform : win ;
20
21 toolset.inherit-generators clang-win <toolset>clang <toolset-clang:platform>win : msvc ;
22 toolset.inherit-flags clang-win : msvc : : YLOPTION ;
23 toolset.inherit-rules clang-win : msvc ;
24
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 ;
28 generators.override clang-win.compile.c.pch : pch.default-c-pch-generator ;
29 generators.override clang-win.compile.c++.pch : pch.default-cpp-pch-generator ;
30
31
32 if [ MATCH (--debug-(clang-(win-)?)?configuration) : [ modules.peek : ARGV ] ]
33 {
34 local rule .notice ( messages * )
35 {
36 ECHO "notice: [clang-win]" $(messages) ;
37 }
38 }
39 else
40 {
41 local rule .notice ( messages * )
42 {
43 }
44 }
45
46 # [ get-option archiver : 32 : $(options) ]
47 #
48 # returns <archiver-32>, or <archiver>
49
50 local 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
68 rule init ( version ? : command * : options * )
69 {
70 command = [ common.get-invocation-command-nodefault clang-win : clang-cl.exe : $(command) ] ;
71
72 if ! $(command)
73 {
74 errors.error "Cannot configure toolset clang-win: no 'clang-cl.exe' command found or given" ;
75 }
76
77 local compiler = "\"$(command)\"" ;
78 compiler = "$(compiler:J= )" ;
79
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 ; }
87
88 .notice "using compiler '$(compiler)', version '$(version)', target '$(target)', default address-model=$(default-addr)" ;
89
90 local condition = [ common.check-init-parameters clang-win : version $(version) ] ;
91
92 common.handle-options clang-win : $(condition) : $(command) : $(options) ;
93
94 for local addr in 32 64
95 {
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 }
107
108 local config = [ SPLIT_BY_CHARACTERS [ SHELL "$(compiler) --target=$(clang-arch)-pc-windows-msvc -### foo.obj /link 2>&1" ] : "\n" ] ;
109
110 local match = 1 ;
111 local items ;
112
113 while $(match)
114 {
115 match = [ MATCH "^ *(\"[^\"]*\")(.*)" : $(config) ] ;
116
117 if $(match)
118 {
119 items += $(match[1]) ;
120 config = $(match[2]) ;
121 }
122 }
123
124 local asm ;
125
126 if $(items)
127 {
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 }
137 }
138
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 }
149
150 local linker ;
151
152 if $(items)
153 {
154 linker = [ regex.replace $(items[1]) "\\\\+HostX64\\\\+x86\\\\+" "\\HostX86\\x86\\" ] ;
155 }
156
157 .notice "$(arch)-$(addr):" "using linker '$(linker)'" ;
158
159 local archiver = [ get-option "archiver" : $(addr) : $(options) ] ;
160
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) ] ;
174
175 for local item in $(items)
176 {
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)'" ;
200
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>" ;
217 }
218
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 }
239 }
240
241 toolset.flags clang-win.link LIBRARY_OPTION <toolset>clang-win : "" : unchecked ;
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 ;
247 }