1
1
use std:: collections:: HashMap ;
2
+ use std:: hash:: { DefaultHasher , Hash , Hasher } ;
2
3
use std:: io:: Read ;
3
4
use std:: path:: { Path , PathBuf } ;
4
5
use std:: sync:: atomic:: { AtomicBool , Ordering } ;
@@ -235,6 +236,7 @@ struct FingerPrint {
235
236
build_targets : BuildTargets ,
236
237
install_paths : InstallPaths ,
237
238
static_libs : String ,
239
+ hasher : DefaultHasher ,
238
240
}
239
241
240
242
#[ derive( serde:: Serialize , serde:: Deserialize ) ]
@@ -249,21 +251,24 @@ impl FingerPrint {
249
251
root_output : & Path ,
250
252
build_targets : & BuildTargets ,
251
253
install_paths : & InstallPaths ,
254
+ capi_config : & CApiConfig ,
252
255
) -> Self {
256
+ let mut hasher = DefaultHasher :: new ( ) ;
257
+
258
+ capi_config. hash ( & mut hasher) ;
259
+
253
260
Self {
254
261
id : id. to_owned ( ) ,
255
262
root_output : root_output. to_owned ( ) ,
256
263
build_targets : build_targets. clone ( ) ,
257
264
install_paths : install_paths. clone ( ) ,
258
265
static_libs : String :: new ( ) ,
266
+ hasher,
259
267
}
260
268
}
261
269
262
270
fn hash ( & self ) -> anyhow:: Result < Option < String > > {
263
- use std:: collections:: hash_map:: DefaultHasher ;
264
- use std:: hash:: { Hash , Hasher } ;
265
-
266
- let mut hasher = DefaultHasher :: new ( ) ;
271
+ let mut hasher = self . hasher . clone ( ) ;
267
272
self . install_paths . hash ( & mut hasher) ;
268
273
269
274
let mut paths: Vec < & PathBuf > = Vec :: new ( ) ;
@@ -324,23 +329,23 @@ impl FingerPrint {
324
329
}
325
330
}
326
331
327
- #[ derive( Debug ) ]
332
+ #[ derive( Debug , Hash ) ]
328
333
pub struct CApiConfig {
329
334
pub header : HeaderCApiConfig ,
330
335
pub pkg_config : PkgConfigCApiConfig ,
331
336
pub library : LibraryCApiConfig ,
332
337
pub install : InstallCApiConfig ,
333
338
}
334
339
335
- #[ derive( Debug ) ]
340
+ #[ derive( Debug , Hash ) ]
336
341
pub struct HeaderCApiConfig {
337
342
pub name : String ,
338
343
pub subdirectory : String ,
339
344
pub generation : bool ,
340
345
pub enabled : bool ,
341
346
}
342
347
343
- #[ derive( Debug ) ]
348
+ #[ derive( Debug , Hash ) ]
344
349
pub struct PkgConfigCApiConfig {
345
350
pub name : String ,
346
351
pub filename : String ,
@@ -351,14 +356,14 @@ pub struct PkgConfigCApiConfig {
351
356
pub strip_include_path_components : usize ,
352
357
}
353
358
354
- #[ derive( Debug ) ]
359
+ #[ derive( Debug , Hash ) ]
355
360
pub enum VersionSuffix {
356
361
Major ,
357
362
MajorMinor ,
358
363
MajorMinorPatch ,
359
364
}
360
365
361
- #[ derive( Debug ) ]
366
+ #[ derive( Debug , Hash ) ]
362
367
pub struct LibraryCApiConfig {
363
368
pub name : String ,
364
369
pub version : Version ,
@@ -388,19 +393,19 @@ impl LibraryCApiConfig {
388
393
}
389
394
}
390
395
391
- #[ derive( Debug , Default ) ]
396
+ #[ derive( Debug , Default , Hash ) ]
392
397
pub struct InstallCApiConfig {
393
398
pub include : Vec < InstallTarget > ,
394
399
pub data : Vec < InstallTarget > ,
395
400
}
396
401
397
- #[ derive( Debug ) ]
402
+ #[ derive( Debug , Hash ) ]
398
403
pub enum InstallTarget {
399
404
Asset ( InstallTargetPaths ) ,
400
405
Generated ( InstallTargetPaths ) ,
401
406
}
402
407
403
- #[ derive( Clone , Debug ) ]
408
+ #[ derive( Clone , Debug , Hash ) ]
404
409
pub struct InstallTargetPaths {
405
410
/// pattern to feed to glob::glob()
406
411
///
@@ -980,7 +985,13 @@ impl CPackage {
980
985
args. get_flag ( "meson" ) ,
981
986
) ?;
982
987
983
- let finger_print = FingerPrint :: new ( & id, root_output, & build_targets, & install_paths) ;
988
+ let finger_print = FingerPrint :: new (
989
+ & id,
990
+ root_output,
991
+ & build_targets,
992
+ & install_paths,
993
+ & capi_config,
994
+ ) ;
984
995
985
996
Ok ( CPackage {
986
997
version,
0 commit comments