@@ -145,11 +145,36 @@ fn main() {
145
145
// Avoid unnecessary re-building.
146
146
println ! ( "cargo:rerun-if-changed=build.rs" ) ;
147
147
148
+ if std:: fs:: exists ( "../src-hotfix" ) . unwrap ( ) {
149
+ std:: fs:: remove_dir_all ( "../src-hotfix" ) . unwrap ( ) ;
150
+ }
151
+
152
+ // ctest2 cannot parse `crate::` in paths, so replace them with `::`
153
+ let re = regex:: bytes:: Regex :: new ( r"(?-u:\b)crate::" ) . unwrap ( ) ;
154
+ copy_dir_hotfix ( Path :: new ( "../src" ) , Path :: new ( "../src-hotfix" ) , & re, b"::" ) ;
155
+
148
156
do_cc ( ) ;
149
157
do_ctest ( ) ;
150
158
do_semver ( ) ;
151
159
}
152
160
161
+ fn copy_dir_hotfix ( src : & Path , dst : & Path , regex : & regex:: bytes:: Regex , replace : & [ u8 ] ) {
162
+ std:: fs:: create_dir ( & dst) . unwrap ( ) ;
163
+ for entry in src. read_dir ( ) . unwrap ( ) {
164
+ let entry = entry. unwrap ( ) ;
165
+ let src_path = entry. path ( ) ;
166
+ let dst_path = dst. join ( entry. file_name ( ) ) ;
167
+ if entry. file_type ( ) . unwrap ( ) . is_dir ( ) {
168
+ copy_dir_hotfix ( & src_path, & dst_path, regex, replace) ;
169
+ } else {
170
+ // Replace "crate::" with "::"
171
+ let src_data = std:: fs:: read ( & src_path) . unwrap ( ) ;
172
+ let dst_data = regex. replace_all ( & src_data, b"::" ) ;
173
+ std:: fs:: write ( & dst_path, & dst_data) . unwrap ( ) ;
174
+ }
175
+ }
176
+ }
177
+
153
178
macro_rules! headers {
154
179
( $cfg: ident: [ $m: expr] : $header: literal) => {
155
180
if $m {
@@ -442,7 +467,7 @@ fn test_apple(target: &str) {
442
467
"uuid_t" | "vol_capabilities_set_t" => true ,
443
468
_ => false ,
444
469
} ) ;
445
- cfg. generate ( "../src/lib.rs" , "main.rs" ) ;
470
+ cfg. generate ( "../src-hotfix /lib.rs" , "main.rs" ) ;
446
471
}
447
472
448
473
fn test_openbsd ( target : & str ) {
@@ -607,7 +632,7 @@ fn test_openbsd(target: &str) {
607
632
}
608
633
} ) ;
609
634
610
- cfg. generate ( "../src/lib.rs" , "main.rs" ) ;
635
+ cfg. generate ( "../src-hotfix /lib.rs" , "main.rs" ) ;
611
636
}
612
637
613
638
fn test_windows ( target : & str ) {
@@ -729,7 +754,7 @@ fn test_windows(target: &str) {
729
754
730
755
cfg. skip_fn ( |_| false ) ;
731
756
732
- cfg. generate ( "../src/lib.rs" , "main.rs" ) ;
757
+ cfg. generate ( "../src-hotfix /lib.rs" , "main.rs" ) ;
733
758
}
734
759
735
760
fn test_redox ( target : & str ) {
@@ -779,7 +804,7 @@ fn test_redox(target: &str) {
779
804
"wchar.h" ,
780
805
}
781
806
782
- cfg. generate ( "../src/lib.rs" , "main.rs" ) ;
807
+ cfg. generate ( "../src-hotfix /lib.rs" , "main.rs" ) ;
783
808
}
784
809
785
810
fn test_solarish ( target : & str ) {
@@ -1054,7 +1079,7 @@ fn test_solarish(target: &str) {
1054
1079
}
1055
1080
} ) ;
1056
1081
1057
- cfg. generate ( "../src/lib.rs" , "main.rs" ) ;
1082
+ cfg. generate ( "../src-hotfix /lib.rs" , "main.rs" ) ;
1058
1083
}
1059
1084
1060
1085
fn test_netbsd ( target : & str ) {
@@ -1267,7 +1292,7 @@ fn test_netbsd(target: &str) {
1267
1292
}
1268
1293
} ) ;
1269
1294
1270
- cfg. generate ( "../src/lib.rs" , "main.rs" ) ;
1295
+ cfg. generate ( "../src-hotfix /lib.rs" , "main.rs" ) ;
1271
1296
}
1272
1297
1273
1298
fn test_dragonflybsd ( target : & str ) {
@@ -1490,7 +1515,7 @@ fn test_dragonflybsd(target: &str) {
1490
1515
( struct_ == "sigevent" && field == "sigev_notify_thread_id" )
1491
1516
} ) ;
1492
1517
1493
- cfg. generate ( "../src/lib.rs" , "main.rs" ) ;
1518
+ cfg. generate ( "../src-hotfix /lib.rs" , "main.rs" ) ;
1494
1519
}
1495
1520
1496
1521
fn test_wasi ( target : & str ) {
@@ -1597,7 +1622,7 @@ fn test_wasi(target: &str) {
1597
1622
// doesn't support sizeof.
1598
1623
cfg. skip_field ( |s, field| s == "dirent" && field == "d_name" ) ;
1599
1624
1600
- cfg. generate ( "../src/lib.rs" , "main.rs" ) ;
1625
+ cfg. generate ( "../src-hotfix /lib.rs" , "main.rs" ) ;
1601
1626
}
1602
1627
1603
1628
fn test_android ( target : & str ) {
@@ -2090,7 +2115,7 @@ fn test_android(target: &str) {
2090
2115
}
2091
2116
} ) ;
2092
2117
2093
- cfg. generate ( "../src/lib.rs" , "main.rs" ) ;
2118
+ cfg. generate ( "../src-hotfix /lib.rs" , "main.rs" ) ;
2094
2119
2095
2120
test_linux_like_apis ( target) ;
2096
2121
}
@@ -2746,7 +2771,7 @@ fn test_freebsd(target: &str) {
2746
2771
} ) ;
2747
2772
}
2748
2773
2749
- cfg. generate ( "../src/lib.rs" , "main.rs" ) ;
2774
+ cfg. generate ( "../src-hotfix /lib.rs" , "main.rs" ) ;
2750
2775
}
2751
2776
2752
2777
fn test_emscripten ( target : & str ) {
@@ -2983,7 +3008,7 @@ fn test_emscripten(target: &str) {
2983
3008
] . contains ( & field) )
2984
3009
} ) ;
2985
3010
2986
- cfg. generate ( "../src/lib.rs" , "main.rs" ) ;
3011
+ cfg. generate ( "../src-hotfix /lib.rs" , "main.rs" ) ;
2987
3012
}
2988
3013
2989
3014
fn test_neutrino ( target : & str ) {
@@ -3233,7 +3258,7 @@ fn test_neutrino(target: &str) {
3233
3258
3234
3259
cfg. skip_static ( move |name| ( name == "__dso_handle" ) ) ;
3235
3260
3236
- cfg. generate ( "../src/lib.rs" , "main.rs" ) ;
3261
+ cfg. generate ( "../src-hotfix /lib.rs" , "main.rs" ) ;
3237
3262
}
3238
3263
3239
3264
fn test_vxworks ( target : & str ) {
@@ -3341,7 +3366,7 @@ fn test_vxworks(target: &str) {
3341
3366
_ => false ,
3342
3367
} ) ;
3343
3368
3344
- cfg. generate ( "../src/lib.rs" , "main.rs" ) ;
3369
+ cfg. generate ( "../src-hotfix /lib.rs" , "main.rs" ) ;
3345
3370
}
3346
3371
3347
3372
fn test_linux ( target : & str ) {
@@ -4462,7 +4487,7 @@ fn test_linux(target: &str) {
4462
4487
_ => false ,
4463
4488
} ) ;
4464
4489
4465
- cfg. generate ( "../src/lib.rs" , "main.rs" ) ;
4490
+ cfg. generate ( "../src-hotfix /lib.rs" , "main.rs" ) ;
4466
4491
4467
4492
test_linux_like_apis ( target) ;
4468
4493
}
@@ -4489,7 +4514,7 @@ fn test_linux_like_apis(target: &str) {
4489
4514
} )
4490
4515
. skip_const ( |_| true )
4491
4516
. skip_struct ( |_| true ) ;
4492
- cfg. generate ( "../src/lib.rs" , "linux_strerror_r.rs" ) ;
4517
+ cfg. generate ( "../src-hotfix /lib.rs" , "linux_strerror_r.rs" ) ;
4493
4518
}
4494
4519
4495
4520
if linux || android || emscripten {
@@ -4519,7 +4544,7 @@ fn test_linux_like_apis(target: &str) {
4519
4544
t => t. to_string ( ) ,
4520
4545
} ) ;
4521
4546
4522
- cfg. generate ( "../src/lib.rs" , "linux_fcntl.rs" ) ;
4547
+ cfg. generate ( "../src-hotfix /lib.rs" , "linux_fcntl.rs" ) ;
4523
4548
}
4524
4549
4525
4550
if linux || android {
@@ -4543,7 +4568,7 @@ fn test_linux_like_apis(target: &str) {
4543
4568
t if is_union => format ! ( "union {}" , t) ,
4544
4569
t => t. to_string ( ) ,
4545
4570
} ) ;
4546
- cfg. generate ( "../src/lib.rs" , "linux_termios.rs" ) ;
4571
+ cfg. generate ( "../src-hotfix /lib.rs" , "linux_termios.rs" ) ;
4547
4572
}
4548
4573
4549
4574
if linux || android {
@@ -4571,7 +4596,7 @@ fn test_linux_like_apis(target: &str) {
4571
4596
t if is_union => format ! ( "union {}" , t) ,
4572
4597
t => t. to_string ( ) ,
4573
4598
} ) ;
4574
- cfg. generate ( "../src/lib.rs" , "linux_ipv6.rs" ) ;
4599
+ cfg. generate ( "../src-hotfix /lib.rs" , "linux_ipv6.rs" ) ;
4575
4600
}
4576
4601
4577
4602
if linux || android {
@@ -4593,7 +4618,7 @@ fn test_linux_like_apis(target: &str) {
4593
4618
"Elf64_Phdr" | "Elf32_Phdr" => false ,
4594
4619
_ => true ,
4595
4620
} ) ;
4596
- cfg. generate ( "../src/lib.rs" , "linux_elf.rs" ) ;
4621
+ cfg. generate ( "../src-hotfix /lib.rs" , "linux_elf.rs" ) ;
4597
4622
}
4598
4623
4599
4624
if linux || android {
@@ -4608,7 +4633,7 @@ fn test_linux_like_apis(target: &str) {
4608
4633
} )
4609
4634
. skip_struct ( |_| true )
4610
4635
. skip_type ( |_| true ) ;
4611
- cfg. generate ( "../src/lib.rs" , "linux_if_arp.rs" ) ;
4636
+ cfg. generate ( "../src-hotfix /lib.rs" , "linux_if_arp.rs" ) ;
4612
4637
}
4613
4638
}
4614
4639
@@ -4964,5 +4989,5 @@ fn test_haiku(target: &str) {
4964
4989
s => s. to_string ( ) ,
4965
4990
}
4966
4991
} ) ;
4967
- cfg. generate ( "../src/lib.rs" , "main.rs" ) ;
4992
+ cfg. generate ( "../src-hotfix /lib.rs" , "main.rs" ) ;
4968
4993
}
0 commit comments