@@ -165,6 +165,109 @@ pub enum CfgEntry {
165
165
Version ( Option < RustcVersion > , Span ) ,
166
166
}
167
167
168
+ /// Different ways that the PE Format can decorate a symbol name.
169
+ /// From <https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-name-type>
170
+ #[ derive(
171
+ Copy ,
172
+ Clone ,
173
+ Debug ,
174
+ Encodable ,
175
+ Decodable ,
176
+ HashStable_Generic ,
177
+ PartialEq ,
178
+ Eq ,
179
+ PrintAttribute
180
+ ) ]
181
+ pub enum PeImportNameType {
182
+ /// IMPORT_ORDINAL
183
+ /// Uses the ordinal (i.e., a number) rather than the name.
184
+ Ordinal ( u16 ) ,
185
+ /// Same as IMPORT_NAME
186
+ /// Name is decorated with all prefixes and suffixes.
187
+ Decorated ,
188
+ /// Same as IMPORT_NAME_NOPREFIX
189
+ /// Prefix (e.g., the leading `_` or `@`) is skipped, but suffix is kept.
190
+ NoPrefix ,
191
+ /// Same as IMPORT_NAME_UNDECORATE
192
+ /// Prefix (e.g., the leading `_` or `@`) and suffix (the first `@` and all
193
+ /// trailing characters) are skipped.
194
+ Undecorated ,
195
+ }
196
+
197
+ #[ derive(
198
+ Copy ,
199
+ Clone ,
200
+ Debug ,
201
+ PartialEq ,
202
+ Eq ,
203
+ PartialOrd ,
204
+ Ord ,
205
+ Hash ,
206
+ Encodable ,
207
+ Decodable ,
208
+ PrintAttribute
209
+ ) ]
210
+ #[ derive( HashStable_Generic ) ]
211
+ pub enum NativeLibKind {
212
+ /// Static library (e.g. `libfoo.a` on Linux or `foo.lib` on Windows/MSVC)
213
+ Static {
214
+ /// Whether to bundle objects from static library into produced rlib
215
+ bundle : Option < bool > ,
216
+ /// Whether to link static library without throwing any object files away
217
+ whole_archive : Option < bool > ,
218
+ } ,
219
+ /// Dynamic library (e.g. `libfoo.so` on Linux)
220
+ /// or an import library corresponding to a dynamic library (e.g. `foo.lib` on Windows/MSVC).
221
+ Dylib {
222
+ /// Whether the dynamic library will be linked only if it satisfies some undefined symbols
223
+ as_needed : Option < bool > ,
224
+ } ,
225
+ /// Dynamic library (e.g. `foo.dll` on Windows) without a corresponding import library.
226
+ /// On Linux, it refers to a generated shared library stub.
227
+ RawDylib ,
228
+ /// A macOS-specific kind of dynamic libraries.
229
+ Framework {
230
+ /// Whether the framework will be linked only if it satisfies some undefined symbols
231
+ as_needed : Option < bool > ,
232
+ } ,
233
+ /// Argument which is passed to linker, relative order with libraries and other arguments
234
+ /// is preserved
235
+ LinkArg ,
236
+
237
+ /// Module imported from WebAssembly
238
+ WasmImportModule ,
239
+
240
+ /// The library kind wasn't specified, `Dylib` is currently used as a default.
241
+ Unspecified ,
242
+ }
243
+
244
+ impl NativeLibKind {
245
+ pub fn has_modifiers ( & self ) -> bool {
246
+ match self {
247
+ NativeLibKind :: Static { bundle, whole_archive } => {
248
+ bundle. is_some ( ) || whole_archive. is_some ( )
249
+ }
250
+ NativeLibKind :: Dylib { as_needed } | NativeLibKind :: Framework { as_needed } => {
251
+ as_needed. is_some ( )
252
+ }
253
+ NativeLibKind :: RawDylib
254
+ | NativeLibKind :: Unspecified
255
+ | NativeLibKind :: LinkArg
256
+ | NativeLibKind :: WasmImportModule => false ,
257
+ }
258
+ }
259
+
260
+ pub fn is_statically_included ( & self ) -> bool {
261
+ matches ! ( self , NativeLibKind :: Static { .. } )
262
+ }
263
+
264
+ pub fn is_dllimport ( & self ) -> bool {
265
+ matches ! (
266
+ self ,
267
+ NativeLibKind :: Dylib { .. } | NativeLibKind :: RawDylib | NativeLibKind :: Unspecified
268
+ )
269
+ }
270
+ }
168
271
/// Represents parsed *built-in* inert attributes.
169
272
///
170
273
/// ## Overview
0 commit comments