]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/tools/clang-win.jam
import new upstream nautilus stable release 14.2.8
[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_1_0.txt
6 # or copy at http://www.boost.org/LICENSE_1_0.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 : msvc.compile.c.pch msvc.compile.c++.pch ;
22 toolset.inherit-flags clang-win : msvc ;
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
29 if [ MATCH (--debug-(clang-(win-)?)?configuration) : [ modules.peek : ARGV ] ]
30 {
31 local rule .notice ( messages * )
32 {
33 ECHO "notice: [clang-win]" $(messages) ;
34 }
35 }
36 else
37 {
38 local rule .notice ( messages * )
39 {
40 }
41 }
42
43 # [ get-option archiver : 32 : $(options) ]
44 #
45 # returns <archiver-32>, or <archiver>
46
47 local rule get-option ( option : addr : options * )
48 {
49 local r = [ feature.get-values "<$(option)-$(addr)>" : $(options) ] ;
50 r ?= [ feature.get-values "<$(option)>" : $(options) ] ;
51 return $(r) ;
52 }
53
54 # init
55 #
56 # options:
57 #
58 # <assembler>ml.exe (or <assembler-32>, or <assembler-64>)
59 # <archiver>lib.exe
60 # <manifest-tool>mt.exe
61 # <resource-compiler>rc.exe
62 # <mc-compiler>mc.exe
63 # <idl-compiler>midl.exe
64
65 rule init ( version ? : command * : options * )
66 {
67 command = [ common.get-invocation-command-nodefault clang-win : clang-cl.exe : $(command) ] ;
68
69 if ! $(command)
70 {
71 errors.error "Cannot configure toolset clang-win: no 'clang-cl.exe' command found or given" ;
72 }
73
74 local compiler = "\"$(command)\"" ;
75 compiler = "$(compiler:J= )" ;
76
77 version ?= [ MATCH "version ([0-9.]+)" : [ SHELL "$(compiler) -v 2>&1" ] ] ;
78
79 .notice "using compiler '$(compiler)', version '$(version)'" ;
80
81 local condition = [ common.check-init-parameters clang-win : version $(version) ] ;
82
83 common.handle-options clang-win : $(condition) : $(command) : $(options) ;
84
85 for local addr in 32 64
86 {
87 local config = [ SPLIT_BY_CHARACTERS [ SHELL "$(compiler) -m$(addr) -### foo.obj /link 2>&1" ] : "\n" ] ;
88
89 local match = 1 ;
90 local items ;
91
92 while $(match)
93 {
94 match = [ MATCH "^ *(\"[^\"]*\")(.*)" : $(config) ] ;
95
96 if $(match)
97 {
98 items += $(match[1]) ;
99 config = $(match[2]) ;
100 }
101 }
102
103 local ml = [ regex.replace $(items[1]) "x64\\\\+link\\.exe" "x64\\ml64.exe" ] ;
104 ml = [ regex.replace $(ml) "x86\\\\+link\\.exe" "x86\\ml.exe" ] ;
105
106 if ! [ MATCH "(ml\\.exe)" "(ml64\\.exe)" : $(ml) ]
107 {
108 ml = ;
109 }
110
111 local assembler = [ get-option "assembler" : $(addr) : $(options) ] ;
112 assembler ?= $(ml) ;
113 if $(addr) = 32 { assembler ?= ml.exe ; } else { assembler ?= ml64.exe ; }
114
115 local link = [ regex.replace $(items[1]) "\\\\+HostX64\\\\+x86\\\\+" "\\HostX86\\x86\\" ] ;
116
117 local archiver = [ get-option "archiver" : $(addr) : $(options) ] ;
118 archiver ?= "$(link) /lib" ;
119 archiver ?= lib.exe ;
120
121 .notice "$(addr):" "using assembler '$(assembler)'" ;
122 .notice "$(addr):" "using archiver '$(archiver)'" ;
123
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) ] ;
128
129 for local item in $(items)
130 {
131 match = [ MATCH "\"-libpath:(.*)\\\\+Lib\\\\.*\\\\um\\\\+x(.*)\"" : $(item) ] ;
132
133 if $(match)
134 {
135 local sdk-path = "$(match[1])\\bin\\x$(match[2])" ;
136 .notice "$(addr):" "using SDK path '$(sdk-path)'" ;
137
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\"" ;
142 }
143 }
144
145 manifest-tool ?= mt.exe ;
146 resource-compiler ?= rc.exe ;
147 mc-compiler ?= mc.exe ;
148 idl-compiler ?= midl.exe ;
149
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)'" ;
154
155 local cond = "$(condition)/<architecture>/<address-model>$(addr)" "$(condition)/<architecture>x86/<address-model>$(addr)" ;
156 if $(addr) = 32 { cond += "$(condition)/<architecture>/<address-model>" ; }
157
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) ;
166 }
167 }