1 // Copyright © 2016-2018 winapi-rs developers
2 // Licensed under the Apache License, Version 2.0
3 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
4 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
5 // All files in the project carrying such notice may not be copied, modified, or distributed
6 // except according to those terms.
7 use std::cell::Cell;
8 use std::collections::HashMap;
9 use std::env::var;
10 // (header name, &[header dependencies], &[library dependencies])
11 const DATA: &'static [(&'static str, &'static [&'static str], &'static [&'static str])] = &[
12 // km
13 // mmos
14 // shared
15 ("basetsd", &[], &[]),
16 ("bcrypt", &["minwindef", "winnt"], &["bcrypt"]),
17 ("bugcodes", &["ntdef"], &[]),
18 ("cderr", &["minwindef"], &[]),
19 ("cfg", &["minwindef"], &[]),
20 ("d3d9", &["basetsd", "d3d9caps", "d3d9types", "guiddef", "minwindef", "unknwnbase", "windef", "wingdi", "winnt"], &["d3d9"]),
21 ("d3d9caps", &["d3d9types", "guiddef", "minwindef", "winnt"], &[]),
22 ("d3d9types", &["basetsd", "guiddef", "minwindef", "windef", "winnt"], &[]),
23 ("dcomptypes", &["dxgitype", "minwindef", "winnt"], &[]),
24 ("devguid", &[], &[]),
25 ("devpkey", &["devpropdef"], &[]),
26 ("devpropdef", &["guiddef", "minwindef", "winnt"], &[]),
27 ("dinputd", &[], &[]),
28 ("dxgi", &["basetsd", "dxgiformat", "dxgitype", "guiddef", "minwindef", "unknwnbase", "windef", "winnt"], &["dxgi"]),
29 ("dxgi1_2", &["basetsd", "dxgi", "dxgiformat", "dxgitype", "guiddef", "minwinbase", "minwindef", "unknwnbase", "windef", "winnt"], &[]),
30 ("dxgi1_3", &["dxgi", "dxgi1_2", "dxgiformat", "guiddef", "minwindef", "unknwnbase", "windef", "winnt"], &["dxgi"]),
31 ("dxgi1_4", &["basetsd", "dxgi1_2", "dxgi1_3", "dxgiformat", "dxgitype", "guiddef", "minwindef", "unknwnbase", "winnt"], &[]),
32 ("dxgi1_5", &["basetsd", "dxgi", "dxgi1_2", "dxgi1_3", "dxgi1_4", "dxgiformat", "minwindef", "unknwnbase", "winnt"], &[]),
33 ("dxgi1_6", &["basetsd", "dxgi1_2", "dxgi1_4", "dxgi1_5", "dxgitype", "guiddef", "minwindef", "windef", "winnt"], &[]),
34 ("dxgiformat", &[], &[]),
35 ("dxgitype", &["d3d9types", "dxgiformat", "minwindef"], &[]),
36 ("evntprov", &["basetsd", "guiddef", "minwindef", "winnt"], &["advapi32"]),
37 ("evntrace", &["basetsd", "evntcons", "evntprov", "guiddef", "handleapi", "minwindef", "timezoneapi", "vadefs", "winnt", "wmistr"], &["advapi32"]),
38 ("guiddef", &[], &[]),
39 ("hidclass", &["guiddef", "minwindef", "winioctl", "winnt"], &[]),
40 ("hidpi", &["hidusage", "minwindef", "ntdef", "ntstatus", "winnt"], &["hid"]),
41 ("hidsdi", &["guiddef", "hidpi", "minwindef", "winnt"], &["hid"]),
42 ("hidusage", &["minwindef"], &[]),
43 ("in6addr", &["minwindef"], &[]),
44 ("inaddr", &["minwindef"], &[]),
45 ("intsafe", &[], &[]),
46 ("ks", &[], &[]),
47 ("ksmedia", &[], &[]),
48 ("ktmtypes", &["guiddef", "minwindef", "winnt"], &[]),
49 ("lmcons", &["minwindef", "winnt"], &[]),
50 ("minwindef", &["basetsd", "ntdef"], &[]),
51 ("mmreg", &["guiddef", "minwindef"], &[]),
52 ("mstcpip", &["basetsd", "guiddef", "in6addr", "inaddr", "minwindef", "winnt", "ws2def"], &["ntdll"]),
53 ("ntddscsi", &["basetsd", "minwindef", "ntdef", "winioctl", "winnt"], &[]),
54 ("ntddser", &["devpropdef"], &[]),
55 ("ntdef", &["basetsd", "guiddef"], &[]),
56 ("ntstatus", &["ntdef"], &[]),
57 ("qos", &["minwindef"], &[]),
58 ("rpc", &[], &[]),
59 ("rpcdce", &["guiddef", "minwindef", "rpc"], &[]),
60 ("rpcndr", &[], &[]),
61 ("sddl", &["basetsd", "minwindef", "winnt"], &["advapi32"]),
62 ("sspi", &["basetsd", "guiddef", "minwindef", "subauth", "wincred", "winnt"], &["credui", "secur32"]),
63 ("stralign", &["vcruntime", "winnt"], &["kernel32"]),
64 ("transportsettingcommon", &["guiddef"], &[]),
65 ("tvout", &["guiddef", "minwindef"], &[]),
66 ("usb", &["minwindef", "usbspec", "winnt"], &[]),
67 ("usbiodef", &["guiddef", "minwindef", "winioctl", "winnt"], &[]),
68 ("usbspec", &["basetsd", "guiddef", "minwindef", "winnt"], &[]),
69 ("windef", &["minwindef", "winnt"], &[]),
70 ("windowsx", &["minwindef"], &[]),
71 ("winerror", &["minwindef"], &[]),
72 ("winusbio", &["minwindef", "usb"], &[]),
73 ("wmistr", &["basetsd", "guiddef", "minwindef", "winnt"], &[]),
74 ("wnnc", &["minwindef"], &[]),
75 ("ws2def", &["basetsd", "guiddef", "inaddr", "minwindef", "vcruntime", "winnt"], &[]),
76 ("ws2ipdef", &["in6addr", "inaddr", "minwindef", "ws2def"], &[]),
77 ("wtypes", &["guiddef", "minwindef", "ntdef", "wtypesbase"], &[]),
78 ("wtypesbase", &["minwindef", "rpcndr", "winnt"], &[]),
79 // ucrt
80 // um
81 ("accctrl", &["guiddef", "minwindef", "winbase", "winnt"], &[]),
82 ("aclapi", &["accctrl", "guiddef", "minwindef", "winnt"], &["advapi32"]),
83 ("appmgmt", &["guiddef", "minwindef", "winnt"], &["advapi32"]),
84 ("audioclient", &["audiosessiontypes", "basetsd", "guiddef", "minwindef", "mmreg", "strmif", "unknwnbase", "winerror", "winnt", "wtypesbase"], &[]),
85 ("audiosessiontypes", &["minwindef"], &[]),
86 ("avrt", &["guiddef", "minwindef", "winnt"], &["avrt"]),
87 ("bits", &["basetsd", "guiddef", "minwindef", "unknwnbase", "winnt"], &[]),
88 ("bits10_1", &["basetsd", "bits", "bits2_0", "bits3_0", "bits5_0", "minwindef", "winnt"], &[]),
89 ("bits1_5", &["basetsd", "bits", "rpcndr", "winnt"], &[]),
90 ("bits2_0", &["basetsd", "bits", "bits1_5", "minwindef", "winnt"], &[]),
91 ("bits2_5", &["minwindef", "rpcndr", "unknwnbase", "winnt"], &[]),
92 ("bits3_0", &["basetsd", "bits", "bits2_0", "guiddef", "minwindef", "unknwnbase", "winnt"], &[]),
93 ("bits4_0", &["basetsd", "bits3_0", "minwindef", "unknwnbase", "winnt"], &[]),
94 ("bits5_0", &["basetsd", "bits1_5", "bits3_0", "bits4_0", "guiddef", "minwindef", "winnt"], &[]),
95 ("bitscfg", &["guiddef", "oaidl", "unknwnbase", "winnt", "wtypes"], &["oleaut32"]),
96 ("bitsmsg", &["minwindef"], &[]),
97 ("cfgmgr32", &["basetsd", "cfg", "guiddef", "minwindef", "winnt", "winreg"], &["setupapi"]),
98 ("cguid", &[], &[]),
99 ("combaseapi", &["basetsd", "guiddef", "minwindef", "objidl", "objidlbase", "propidl", "rpcdce", "unknwnbase", "winnt", "wtypesbase"], &["ole32"]),
100 ("coml2api", &["minwindef"], &[]),
101 ("commapi", &["minwinbase", "minwindef", "winbase", "winnt"], &["kernel32"]),
102 ("commctrl", &["basetsd", "commoncontrols", "guiddef", "minwinbase", "minwindef", "vcruntime", "windef", "winnt", "winuser"], &["comctl32"]),
103 ("commdlg", &["basetsd", "minwindef", "prsht", "unknwnbase", "windef", "wingdi", "winnt", "winuser"], &["comdlg32"]),
104 ("commoncontrols", &["commctrl", "guiddef", "minwindef", "unknwnbase", "windef", "winnt"], &["comctl32"]),
105 ("consoleapi", &["minwindef", "wincon", "winnt"], &["kernel32"]),
106 ("corsym", &["basetsd", "objidlbase", "unknwnbase", "winnt"], &[]),
107 ("d2d1", &["basetsd", "d2dbasetypes", "d3dcommon", "dcommon", "dwrite", "dxgi", "guiddef", "minwindef", "unknwnbase", "wincodec", "windef", "winnt"], &["d2d1"]),
108 ("d2d1_1", &["basetsd", "d2d1", "d2d1effectauthor", "d2dbasetypes", "dcommon", "documenttarget", "dwrite", "dxgi", "dxgiformat", "guiddef", "minwindef", "objidlbase", "unknwnbase", "wincodec", "winnt"], &["d2d1"]),
109 ("d2d1_2", &["d2d1", "d2d1_1", "dxgi", "minwindef", "winnt"], &["d2d1"]),
110 ("d2d1_3", &["basetsd", "d2d1", "d2d1_1", "d2d1_2", "d2d1effects", "d2d1svg", "dcommon", "dwrite", "dxgi", "dxgitype", "minwindef", "ntdef", "objidlbase", "wincodec", "winerror"], &["d2d1"]),
111 ("d2d1effectauthor", &["basetsd", "d2d1", "d2d1_1", "d2dbasetypes", "d3dcommon", "dxgiformat", "guiddef", "minwindef", "ntdef", "unknwnbase", "wincodec"], &[]),
112 ("d2d1effects", &[], &[]),
113 ("d2d1effects_1", &[], &[]),
114 ("d2d1effects_2", &[], &[]),
115 ("d2d1svg", &["basetsd", "d2d1", "d2d1_1", "guiddef", "minwindef", "ntdef", "objidlbase", "winerror"], &[]),
116 ("d2dbasetypes", &["d3d9types", "dcommon"], &[]),
117 ("d3d", &[], &[]),
118 ("d3d10", &["d3dcommon"], &[]),
119 ("d3d10_1", &[], &[]),
120 ("d3d10_1shader", &[], &[]),
121 ("d3d10effect", &[], &[]),
122 ("d3d10misc", &[], &[]),
123 ("d3d10sdklayers", &[], &[]),
124 ("d3d10shader", &["d3d10", "d3dcommon", "minwindef", "unknwnbase", "winnt"], &[]),
125 ("d3d11", &["basetsd", "d3dcommon", "dxgi", "dxgiformat", "dxgitype", "guiddef", "minwindef", "unknwnbase", "windef", "winnt"], &["d3d11"]),
126 ("d3d11_1", &["basetsd", "d3d11", "d3dcommon", "dxgiformat", "dxgitype", "guiddef", "minwindef", "unknwnbase", "winnt"], &[]),
127 ("d3d11_2", &["basetsd", "d3d11", "d3d11_1", "dxgiformat", "minwindef", "winnt"], &[]),
128 ("d3d11_3", &[], &[]),
129 ("d3d11_4", &[], &[]),
130 ("d3d11on12", &["d3d11", "d3d12", "d3dcommon", "guiddef", "minwindef", "unknwnbase", "winnt"], &["d3d11"]),
131 ("d3d11sdklayers", &["basetsd", "d3d11", "dxgi", "minwindef", "unknwnbase", "winnt"], &[]),
132 ("d3d11shader", &["basetsd", "d3dcommon", "minwindef", "unknwnbase", "winnt"], &[]),
133 ("d3d11tokenizedprogramformat", &["minwindef"], &[]),
134 ("d3d12", &["basetsd", "d3dcommon", "dxgiformat", "dxgitype", "guiddef", "minwinbase", "minwindef", "unknwnbase", "windef", "winnt"], &["d3d12"]),
135 ("d3d12sdklayers", &["basetsd", "d3d12", "minwindef", "unknwnbase", "winnt"], &[]),
136 ("d3d12shader", &["basetsd", "d3dcommon", "minwindef", "unknwnbase", "winnt"], &[]),
137 ("d3dcommon", &["basetsd", "minwindef", "unknwnbase", "winnt"], &[]),
138 ("d3dcompiler", &["basetsd", "d3d11shader", "d3dcommon", "guiddef", "minwindef", "winnt"], &["d3dcompiler"]),
139 ("d3dcsx", &[], &[]),
140 ("d3dx10core", &[], &[]),
141 ("d3dx10math", &[], &[]),
142 ("d3dx10mesh", &[], &[]),
143 ("datetimeapi", &["minwinbase", "minwindef", "winnt"], &["kernel32"]),
144 ("davclnt", &["minwindef", "winnt"], &["netapi32"]),
145 ("dbghelp", &["basetsd", "guiddef", "minwindef", "vcruntime", "winnt"], &["dbghelp"]),
146 ("dbt", &["basetsd", "guiddef", "minwindef", "winnt", "winuser"], &[]),
147 ("dcommon", &["basetsd", "dxgiformat", "minwindef", "windef"], &[]),
148 ("dcomp", &["d2d1", "d2d1_1", "d2d1effects", "d2dbasetypes", "d3d9types", "d3dcommon", "dcompanimation", "dcomptypes", "dxgi", "dxgi1_2", "dxgiformat", "guiddef", "minwinbase", "minwindef", "ntdef", "unknwnbase", "windef"], &["dcomp"]),
149 ("dcompanimation", &["ntdef", "unknwnbase"], &[]),
150 ("dde", &["basetsd", "minwindef"], &["user32"]),
151 ("ddraw", &[], &[]),
152 ("ddrawi", &[], &[]),
153 ("ddrawint", &[], &[]),
154 ("debugapi", &["minwinbase", "minwindef", "winnt"], &["kernel32"]),
155 ("devicetopology", &["guiddef", "minwindef", "unknwnbase", "windef", "winnt", "wtypes"], &[]),
156 ("dinput", &[], &[]),
157 ("dmksctl", &[], &[]),
158 ("dmusicc", &[], &[]),
159 ("docobj", &["guiddef", "minwindef", "oaidl", "unknwnbase", "winnt"], &[]),
160 ("documenttarget", &["basetsd", "guiddef", "ntdef", "unknwnbase"], &[]),
161 ("dpa_dsa", &["basetsd", "minwindef", "winnt"], &["comctl32"]),
162 ("dpapi", &["minwindef", "wincrypt", "windef", "winnt"], &["crypt32"]),
163 ("dsgetdc", &["guiddef", "minwindef", "ntsecapi", "winnt", "ws2def"], &["netapi32"]),
164 ("dsound", &["guiddef", "minwindef", "mmsystem", "unknwnbase", "windef", "winerror", "winnt"], &["dsound"]),
165 ("dsrole", &["guiddef", "minwindef", "winnt"], &["netapi32"]),
166 ("dvp", &[], &[]),
167 ("dwmapi", &["basetsd", "minwindef", "uxtheme", "windef", "winnt"], &["dwmapi"]),
168 ("dwrite", &["basetsd", "d2d1", "dcommon", "guiddef", "minwindef", "unknwnbase", "windef", "winerror", "wingdi", "winnt"], &["dwrite"]),
169 ("dwrite_1", &["basetsd", "dcommon", "dwrite", "minwindef", "winnt"], &[]),
170 ("dwrite_2", &["basetsd", "d3d9types", "dcommon", "dwrite", "dwrite_1", "minwindef", "unknwnbase", "winnt"], &[]),
171 ("dwrite_3", &["basetsd", "dcommon", "dwrite", "dwrite_1", "dwrite_2", "minwindef", "unknwnbase", "wingdi", "winnt"], &[]),
172 ("dxdiag", &[], &[]),
173 ("dxfile", &[], &[]),
174 ("dxgidebug", &["basetsd", "guiddef", "minwindef", "unknwnbase", "winnt"], &["dxgi"]),
175 ("dxva2api", &["basetsd", "d3d9", "d3d9types", "guiddef", "minwindef", "unknwnbase", "windef", "winnt"], &["dxva2"]),
176 ("dxvahd", &["d3d9", "d3d9types", "guiddef", "minwindef", "unknwnbase", "windef", "winnt"], &["dxva2"]),
177 ("endpointvolume", &["basetsd", "guiddef", "minwindef", "unknwnbase", "winnt"], &[]),
178 ("errhandlingapi", &["basetsd", "minwindef", "winnt"], &["kernel32"]),
179 ("evntcons", &["basetsd", "evntprov", "evntrace", "guiddef", "minwindef", "winnt"], &["advapi32"]),
180 ("exdisp", &["basetsd", "docobj", "oaidl", "ocidl", "winnt", "wtypes"], &[]),
181 ("fibersapi", &["minwindef", "winnt"], &["kernel32"]),
182 ("fileapi", &["minwinbase", "minwindef", "winnt"], &["kernel32"]),
183 ("gl-gl", &[], &["opengl32"]),
184 ("handleapi", &["minwindef", "winnt"], &["kernel32"]),
185 ("heapapi", &["basetsd", "minwinbase", "minwindef", "winnt"], &["kernel32"]),
186 ("highlevelmonitorconfigurationapi", &["minwindef", "physicalmonitorenumerationapi", "winnt"], &["dxva2"]),
187 ("http", &["guiddef", "minwinbase", "minwindef", "sspi", "winnt", "ws2def"], &["winhttp"]),
188 ("imm", &["minwindef", "windef"], &["imm32"]),
189 ("interlockedapi", &["minwindef", "winnt"], &["kernel32"]),
190 ("ioapiset", &["basetsd", "minwinbase", "minwindef", "winnt"], &["kernel32"]),
191 ("jobapi", &["minwindef", "winnt"], &["kernel32"]),
192 ("jobapi2", &["basetsd", "minwinbase", "minwindef", "ntdef", "winnt"], &["kernel32"]),
193 ("knownfolders", &[], &[]),
194 ("ktmw32", &["guiddef", "minwinbase", "minwindef", "winnt"], &["ktmw32"]),
195 ("libloaderapi", &["basetsd", "minwindef", "winnt"], &["kernel32", "user32"]),
196 ("lmaccess", &["basetsd", "lmcons", "minwindef", "winnt"], &["netapi32"]),
197 ("lmalert", &["lmcons", "minwindef", "winnt"], &["netapi32"]),
198 ("lmapibuf", &["lmcons", "minwindef"], &["netapi32"]),
199 ("lmat", &["basetsd", "lmcons", "minwindef", "winnt"], &["netapi32"]),
200 ("lmdfs", &["guiddef", "lmcons", "minwindef", "winnt"], &["netapi32"]),
201 ("lmerrlog", &["minwindef", "winnt"], &[]),
202 ("lmjoin", &["lmcons", "minwindef", "wincrypt", "winnt"], &["netapi32"]),
203 ("lmmsg", &["lmcons", "minwindef", "winnt"], &["netapi32"]),
204 ("lmremutl", &["lmcons", "minwindef", "winnt"], &["netapi32"]),
205 ("lmrepl", &["lmcons", "minwindef", "winnt"], &["netapi32"]),
206 ("lmserver", &["guiddef", "lmcons", "minwindef", "winnt", "winsvc"], &["advapi32", "netapi32"]),
207 ("lmshare", &["basetsd", "guiddef", "lmcons", "minwindef", "winnt"], &["netapi32"]),
208 ("lmstats", &["lmcons", "minwindef", "winnt"], &["netapi32"]),
209 ("lmsvc", &["lmcons", "minwindef", "winnt"], &["netapi32"]),
210 ("lmuse", &["lmcons", "minwindef", "winnt"], &["netapi32"]),
211 ("lmwksta", &["lmcons", "minwindef", "winnt"], &["netapi32"]),
212 ("lowlevelmonitorconfigurationapi", &["minwindef", "physicalmonitorenumerationapi", "winnt"], &["dxva2"]),
213 ("lsalookup", &["guiddef", "minwindef", "ntdef", "winnt"], &["advapi32"]),
214 ("memoryapi", &["basetsd", "minwinbase", "minwindef", "winnt"], &["kernel32"]),
215 ("minschannel", &["guiddef", "minwindef", "wincrypt", "winnt"], &[]),
216 ("minwinbase", &["basetsd", "minwindef", "ntstatus", "winnt"], &[]),
217 ("mmdeviceapi", &["guiddef", "minwindef", "propidl", "propsys", "unknwnbase", "winnt", "wtypes"], &["mmdevapi"]),
218 ("mmeapi", &["basetsd", "imm", "minwindef", "mmsystem", "winnt"], &["winmm"]),
219 ("mmsystem", &["basetsd", "minwindef", "mmreg", "winnt"], &[]),
220 ("msaatext", &[], &[]),
221 ("mscat", &["guiddef", "minwindef", "mssip", "wincrypt", "winnt"], &[]),
222 ("mschapp", &["basetsd", "minwindef", "winnt"], &["advapi32"]),
223 ("mssip", &["guiddef", "minwindef", "mscat", "wincrypt", "winnt"], &["crypt32"]),
224 ("namedpipeapi", &["minwinbase", "minwindef", "winnt"], &["advapi32", "kernel32"]),
225 ("namespaceapi", &["minwinbase", "minwindef", "ntdef", "winnt"], &["kernel32"]),
226 ("nb30", &["minwindef", "winnt"], &["netapi32"]),
227 ("ncrypt", &["basetsd", "bcrypt", "minwindef", "winnt"], &["ncrypt"]),
228 ("ntlsa", &["basetsd", "guiddef", "lsalookup", "minwindef", "ntdef", "ntsecapi", "subauth", "winnt"], &["advapi32"]),
229 ("ntsecapi", &["basetsd", "guiddef", "lsalookup", "minwindef", "ntdef", "sspi", "subauth", "winnt"], &["advapi32"]),
230 ("oaidl", &["basetsd", "guiddef", "minwindef", "rpcndr", "unknwnbase", "winnt", "wtypes", "wtypesbase"], &[]),
231 ("objbase", &["combaseapi", "minwindef", "winnt"], &["ole32"]),
232 ("objidl", &["basetsd", "guiddef", "minwindef", "ntdef", "objidlbase", "unknwnbase", "windef", "winnt", "wtypes", "wtypesbase"], &[]),
233 ("objidlbase", &["basetsd", "guiddef", "minwindef", "unknwnbase", "winnt", "wtypesbase"], &[]),
234 ("ocidl", &["guiddef", "minwindef", "ntdef", "oaidl", "unknwnbase", "wtypes", "wtypesbase"], &[]),
235 ("ole2", &["minwindef", "oleidl", "windef", "winnt"], &["ole32"]),
236 ("oleauto", &["basetsd", "minwinbase", "minwindef", "oaidl", "winnt", "wtypes", "wtypesbase"], &["oleaut32"]),
237 ("olectl", &["winerror", "winnt"], &[]),
238 ("oleidl", &["minwindef", "ntdef", "objidl", "unknwnbase", "windef"], &[]),
239 ("opmapi", &["basetsd", "d3d9", "d3d9types", "dxva2api", "guiddef", "minwindef", "unknwnbase", "windef", "winnt"], &["dxva2"]),
240 ("pdh", &["basetsd", "guiddef", "minwindef", "windef", "winnt"], &["pdh"]),
241 ("perflib", &["basetsd", "guiddef", "minwinbase", "minwindef", "winnt"], &["advapi32"]),
242 ("physicalmonitorenumerationapi", &["d3d9", "minwindef", "windef", "winnt"], &["dxva2"]),
243 ("playsoundapi", &["minwindef", "winnt"], &["winmm"]),
244 ("powerbase", &["minwindef", "winnt", "winuser"], &["powrprof"]),
245 ("powersetting", &["guiddef", "minwindef", "winnt", "winuser"], &["powrprof"]),
246 ("powrprof", &["guiddef", "minwindef", "winnt", "winreg"], &["powrprof"]),
247 ("processenv", &["minwindef", "winnt"], &["kernel32"]),
248 ("processsnapshot", &["basetsd", "minwindef", "winnt"], &["kernel32"]),
249 ("processthreadsapi", &["basetsd", "guiddef", "minwinbase", "minwindef", "winnt"], &["advapi32", "kernel32"]),
250 ("processtopologyapi", &["minwindef", "winnt"], &["kernel32"]),
251 ("profileapi", &["minwindef", "winnt"], &["kernel32"]),
252 ("propidl", &["minwindef", "wtypes"], &[]),
253 ("propkeydef", &["guiddef", "wtypes"], &[]),
254 ("propsys", &["minwindef", "propidl", "propkeydef", "unknwnbase", "winnt", "wtypes"], &[]),
255 ("prsht", &["basetsd", "minwindef", "windef", "winnt", "winuser"], &["comctl32"]),
256 ("psapi", &["basetsd", "minwindef", "winnt"], &["kernel32", "psapi"]),
257 ("realtimeapiset", &["basetsd", "minwindef", "winnt"], &["kernel32"]),
258 ("reason", &["minwindef"], &[]),
259 ("restartmanager", &["minwindef", "winnt"], &["rstrtmgr"]),
260 ("restrictederrorinfo", &["unknwnbase", "winnt", "wtypes"], &[]),
261 ("rmxfguid", &[], &[]),
262 ("sapi", &["guiddef", "minwindef", "sapi53", "unknwnbase", "winnt"], &[]),
263 ("sapi51", &["guiddef", "minwindef", "mmreg", "oaidl", "objidlbase", "rpcndr", "servprov", "unknwnbase", "windef", "winnt", "wtypes", "wtypesbase"], &[]),
264 ("sapi53", &["guiddef", "minwindef", "oaidl", "sapi51", "unknwnbase", "urlmon", "winnt", "wtypes"], &[]),
265 ("sapiddk", &["guiddef", "minwindef", "sapi", "sapiddk51", "unknwnbase", "winnt"], &[]),
266 ("sapiddk51", &["guiddef", "minwindef", "mmreg", "oaidl", "objidlbase", "sapi", "unknwnbase", "windef", "winnt"], &[]),
267 ("schannel", &["guiddef", "minwindef", "wincrypt", "windef", "winnt"], &[]),
268 ("securityappcontainer", &["minwindef", "winnt"], &["kernel32"]),
269 ("securitybaseapi", &["guiddef", "minwinbase", "minwindef", "winnt"], &["advapi32", "kernel32"]),
270 ("servprov", &["guiddef", "unknwnbase", "winnt"], &[]),
271 ("setupapi", &["basetsd", "commctrl", "devpropdef", "guiddef", "minwindef", "prsht", "spapidef", "windef", "winnt", "winreg"], &["setupapi"]),
272 ("shellapi", &["basetsd", "guiddef", "minwinbase", "minwindef", "processthreadsapi", "windef", "winnt", "winuser"], &["shell32", "shlwapi"]),
273 ("shellscalingapi", &["minwindef", "windef", "winnt"], &["shcore"]),
274 ("shlobj", &["guiddef", "minwinbase", "minwindef", "shtypes", "windef", "winnt"], &["shell32"]),
275 ("shobjidl", &["guiddef", "minwindef", "objidl", "propkeydef", "propsys", "shobjidl_core", "shtypes", "unknwnbase", "windef", "winnt"], &[]),
276 ("shobjidl_core", &["guiddef", "minwindef", "objidl", "unknwnbase", "windef", "winnt"], &[]),
277 ("shtypes", &["guiddef", "minwindef", "winnt"], &[]),
278 ("spapidef", &["minwindef", "winnt"], &[]),
279 ("sporder", &["guiddef", "minwindef"], &["sporder"]),
280 ("sql", &["sqltypes"], &["odbc32"]),
281 ("sqlext", &["sql", "sqltypes"], &[]),
282 ("sqltypes", &["basetsd", "guiddef", "windef"], &[]),
283 ("sqlucode", &["sqltypes"], &["odbc32"]),
284 ("stringapiset", &["minwindef", "winnls", "winnt"], &["kernel32"]),
285 ("strmif", &["winnt"], &[]),
286 ("subauth", &["minwindef", "winnt"], &[]),
287 ("synchapi", &["basetsd", "minwinbase", "minwindef", "winnt"], &["kernel32", "synchronization"]),
288 ("sysinfoapi", &["basetsd", "minwinbase", "minwindef", "winnt"], &["kernel32"]),
289 ("systemtopologyapi", &["minwindef", "winnt"], &["kernel32"]),
290 ("textstor", &[], &[]),
291 ("threadpoolapiset", &["basetsd", "minwinbase", "minwindef", "winnt"], &["kernel32"]),
292 ("threadpoollegacyapiset", &["minwinbase", "minwindef", "winnt"], &["kernel32"]),
293 ("timeapi", &["minwindef", "mmsystem"], &["winmm"]),
294 ("timezoneapi", &["minwinbase", "minwindef", "winnt"], &["advapi32", "kernel32"]),
295 ("tlhelp32", &["basetsd", "minwindef", "winnt"], &["kernel32"]),
296 ("unknwnbase", &["guiddef", "minwindef", "winnt"], &[]),
297 ("urlhist", &["docobj", "guiddef", "minwindef", "unknwnbase", "winnt", "wtypesbase"], &[]),
298 ("urlmon", &["minwindef", "unknwnbase", "winnt"], &[]),
299 ("userenv", &["minwindef", "winnt", "winreg"], &["userenv"]),
300 ("usp10", &["minwindef", "ntdef", "windef", "winerror", "wingdi", "winnt"], &["usp10"]),
301 ("utilapiset", &["minwindef", "ntdef"], &["kernel32"]),
302 ("uxtheme", &["commctrl", "minwindef", "windef", "wingdi", "winnt"], &["uxtheme"]),
303 ("vsbackup", &["guiddef", "minwindef", "unknwnbase", "vss", "vswriter", "winnt", "wtypes"], &["vssapi"]),
304 ("vss", &["guiddef", "minwindef", "unknwnbase", "winnt"], &[]),
305 ("vsserror", &["winnt"], &[]),
306 ("vswriter", &["minwindef", "unknwnbase", "vss", "winnt", "wtypes"], &[]),
307 ("wct", &["basetsd", "guiddef", "minwindef", "winnt"], &["advapi32"]),
308 ("werapi", &["minwindef", "winnt"], &["kernel32", "wer"]),
309 ("winbase", &["basetsd", "cfgmgr32", "fileapi", "guiddef", "libloaderapi", "minwinbase", "minwindef", "processthreadsapi", "vadefs", "windef", "winnt"], &["kernel32"]),
310 ("wincodec", &["basetsd", "d2d1", "d2d1_1", "dcommon", "dxgiformat", "dxgitype", "guiddef", "minwindef", "ntdef", "objidlbase", "ocidl", "propidl", "unknwnbase", "windef", "winerror", "winnt"], &["windowscodecs"]),
311 ("wincodecsdk", &["guiddef", "minwindef", "oaidl", "objidl", "objidlbase", "ocidl", "propidl", "unknwnbase", "wincodec", "winnt", "wtypes"], &["ole32", "oleaut32", "windowscodecs"]),
312 ("wincon", &["minwinbase", "minwindef", "windef", "wingdi", "winnt"], &["kernel32"]),
313 ("wincred", &["minwindef", "sspi", "windef", "winnt"], &["advapi32", "credui"]),
314 ("wincrypt", &["basetsd", "bcrypt", "guiddef", "minwinbase", "minwindef", "ncrypt", "vcruntime", "winnt"], &["advapi32", "crypt32", "cryptnet"]),
315 ("windowsceip", &["minwindef"], &["kernel32"]),
316 ("winefs", &["basetsd", "minwinbase", "minwindef", "wincrypt", "winnt"], &["advapi32"]),
317 ("winevt", &["basetsd", "guiddef", "minwinbase", "minwindef", "vcruntime", "winnt"], &["wevtapi"]),
318 ("wingdi", &["basetsd", "minwindef", "windef", "winnt"], &["gdi32", "msimg32", "opengl32", "winspool"]),
319 ("winhttp", &["basetsd", "minwinbase", "minwindef", "winnt"], &["winhttp"]),
320 ("wininet", &["basetsd", "minwinbase", "minwindef", "ntdef", "windef", "winineti", "winnt"], &["wininet"]),
321 ("winineti", &["minwindef"], &[]),
322 ("winioctl", &["basetsd", "devpropdef", "guiddef", "minwindef", "winnt"], &[]),
323 ("winnetwk", &["basetsd", "minwindef", "windef", "winerror", "winnt"], &["mpr"]),
324 ("winnls", &["basetsd", "guiddef", "minwinbase", "minwindef", "winnt"], &["kernel32"]),
325 ("winnt", &["basetsd", "excpt", "guiddef", "ktmtypes", "minwindef", "vcruntime"], &["kernel32"]),
326 ("winreg", &["basetsd", "minwinbase", "minwindef", "winnt"], &["advapi32"]),
327 ("winsafer", &["basetsd", "guiddef", "minwindef", "wincrypt", "windef", "winnt"], &["advapi32"]),
328 ("winscard", &["basetsd", "guiddef", "minwindef", "rpcdce", "windef", "winnt", "winsmcrd"], &["winscard"]),
329 ("winsmcrd", &["minwindef", "winioctl"], &[]),
330 ("winsock2", &["basetsd", "guiddef", "inaddr", "minwinbase", "minwindef", "qos", "winbase", "windef", "winerror", "winnt", "ws2def", "wtypesbase"], &["ws2_32"]),
331 ("winspool", &["guiddef", "minwinbase", "minwindef", "vcruntime", "windef", "winerror", "wingdi", "winnt"], &["winspool"]),
332 ("winsvc", &["minwindef", "winnt"], &["advapi32"]),
333 ("winusb", &["minwinbase", "minwindef", "usb", "usbspec", "winnt", "winusbio"], &["winusb"]),
334 ("winuser", &["basetsd", "guiddef", "limits", "minwinbase", "minwindef", "vadefs", "windef", "wingdi", "winnt"], &["user32"]),
335 ("winver", &["minwindef", "winnt"], &["kernel32", "version"]),
336 ("wow64apiset", &["minwindef", "winnt"], &["kernel32"]),
337 ("ws2spi", &["basetsd", "guiddef", "minwindef", "vcruntime", "windef", "winnt", "winsock2", "ws2def", "wtypesbase"], &["ws2_32"]),
338 ("ws2tcpip", &["guiddef", "minwinbase", "minwindef", "mstcpip", "vcruntime", "winerror", "winnt", "winsock2", "ws2def", "wtypesbase"], &["fwpuclnt", "ws2_32"]),
339 ("xinput", &["guiddef", "minwindef", "winnt"], &["xinput"]),
340 // vc
341 ("excpt", &[], &[]),
342 ("limits", &[], &[]),
343 ("vadefs", &[], &[]),
344 ("vcruntime", &[], &[]),
345 // winrt
346 ("activation", &["inspectable", "winnt"], &[]),
347 ("hstring", &["winnt"], &[]),
348 ("inspectable", &["guiddef", "hstring", "minwindef", "unknwnbase", "winnt"], &[]),
349 ("roapi", &["activation", "basetsd", "guiddef", "hstring", "inspectable", "objidl", "winnt"], &["runtimeobject"]),
350 ("robuffer", &["objidl", "winnt"], &["runtimeobject"]),
351 ("roerrorapi", &["basetsd", "hstring", "minwindef", "restrictederrorinfo", "unknwnbase", "winnt"], &["runtimeobject"]),
352 ("winstring", &["basetsd", "hstring", "minwindef", "winnt"], &["runtimeobject"]),
353 ];
354 struct Header {
355 required: bool,
356 included: Cell<bool>,
357 dependencies: &'static [&'static str],
358 libraries: &'static [&'static str],
359 }
360 struct Graph(HashMap<&'static str, Header>);
361 impl Graph {
generate() -> Graph362 fn generate() -> Graph {
363 Graph(DATA.iter().map(|&(name, dependencies, libraries)| {
364 let header = Header {
365 required: false,
366 included: Cell::new(false),
367 dependencies: dependencies,
368 libraries: libraries,
369 };
370 (name, header)
371 }).collect())
372 }
identify_required(&mut self)373 fn identify_required(&mut self) {
374 for (name, header) in &mut self.0 {
375 if let Ok(_) = var(&format!("CARGO_FEATURE_{}", name.to_uppercase())) {
376 header.required = true;
377 header.included.set(true);
378 }
379 }
380 }
check_everything(&self)381 fn check_everything(&self) {
382 if let Ok(_) = var("CARGO_FEATURE_EVERYTHING") {
383 for (_, header) in &self.0 {
384 header.included.set(true);
385 }
386 }
387 }
resolve_dependencies(&self)388 fn resolve_dependencies(&self) {
389 let mut done = false;
390 while !done {
391 done = true;
392 for (_, header) in &self.0 {
393 if header.included.get() {
394 for dep in header.dependencies {
395 let dep = &self.0.get(dep).expect(dep);
396 if !dep.included.get() {
397 done = false;
398 dep.included.set(true);
399 }
400 }
401 }
402 }
403 }
404 }
emit_features(&self)405 fn emit_features(&self) {
406 for (name, header) in &self.0 {
407 if header.included.get() && !header.required {
408 println!("cargo:rustc-cfg=feature=\"{}\"", name);
409 }
410 }
411 }
emit_libraries(&self)412 fn emit_libraries(&self) {
413 let mut libs = self.0.iter().filter(|&(_, header)| {
414 header.included.get()
415 }).flat_map(|(_, header)| {
416 header.libraries.iter()
417 }).collect::<Vec<_>>();
418 libs.sort();
419 libs.dedup();
420 let prefix = library_prefix();
421 let kind = library_kind();
422 for lib in libs {
423 println!("cargo:rustc-link-lib={}={}{}", kind, prefix, lib);
424 }
425 }
426 }
library_prefix() -> &'static str427 fn library_prefix() -> &'static str {
428 if var("TARGET").map(|target|
429 target == "i686-pc-windows-gnu" || target == "x86_64-pc-windows-gnu"
430 ).unwrap_or(false) && var("WINAPI_NO_BUNDLED_LIBRARIES").is_err() {
431 "winapi_"
432 } else {
433 ""
434 }
435 }
library_kind() -> &'static str436 fn library_kind() -> &'static str {
437 if var("WINAPI_STATIC_NOBUNDLE").is_ok() {
438 "static-nobundle"
439 } else {
440 "dylib"
441 }
442 }
try_everything()443 fn try_everything() {
444 let mut graph = Graph::generate();
445 graph.identify_required();
446 graph.check_everything();
447 graph.resolve_dependencies();
448 graph.emit_features();
449 graph.emit_libraries();
450 }
main()451 fn main() {
452 println!("cargo:rerun-if-changed=build.rs");
453 println!("cargo:rerun-if-env-changed=WINAPI_NO_BUNDLED_LIBRARIES");
454 println!("cargo:rerun-if-env-changed=WINAPI_STATIC_NOBUNDLE");
455 let target = var("TARGET").unwrap();
456 let target: Vec<_> = target.split('-').collect();
457 if target.get(2) == Some(&"windows") {
458 try_everything();
459 }
460 }
461