@@ -65,7 +65,10 @@ fn do_ctest() {
65
65
t if t. contains ( "solaris" ) => test_solarish ( t) ,
66
66
t if t. contains ( "illumos" ) => test_solarish ( t) ,
67
67
t if t. contains ( "wasi" ) => test_wasi ( t) ,
68
- t if t. contains ( "windows" ) => test_windows ( t) ,
68
+ t if t. contains ( "windows" ) => {
69
+ test_windows_next ( t) ;
70
+ test_windows ( t) ;
71
+ }
69
72
t if t. contains ( "vxworks" ) => test_vxworks ( t) ,
70
73
t if t. contains ( "nto-qnx" ) => test_neutrino ( t) ,
71
74
t if t. contains ( "aix" ) => return test_aix ( t) ,
@@ -77,6 +80,10 @@ fn ctest_cfg() -> ctest::TestGenerator {
77
80
ctest:: TestGenerator :: new ( )
78
81
}
79
82
83
+ fn ctest_next_cfg ( ) -> ctest_next:: TestGenerator {
84
+ ctest_next:: TestGenerator :: new ( )
85
+ }
86
+
80
87
fn do_semver ( ) {
81
88
let mut out = PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
82
89
out. push ( "semver.rs" ) ;
@@ -945,6 +952,123 @@ fn test_windows(target: &str) {
945
952
cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "main.rs" ) ;
946
953
}
947
954
955
+ fn test_windows_next ( target : & str ) {
956
+ assert ! ( target. contains( "windows" ) ) ;
957
+ let gnu = target. contains ( "gnu" ) ;
958
+ let i686 = target. contains ( "i686" ) ;
959
+
960
+ let mut cfg = ctest_next_cfg ( ) ;
961
+ if target. contains ( "msvc" ) {
962
+ cfg. flag ( "/wd4324" ) ;
963
+ }
964
+ cfg. define ( "_WIN32_WINNT" , Some ( "0x8000" ) ) ;
965
+
966
+ headers ! { cfg:
967
+ "direct.h" ,
968
+ "errno.h" ,
969
+ "fcntl.h" ,
970
+ "io.h" ,
971
+ "limits.h" ,
972
+ "locale.h" ,
973
+ "process.h" ,
974
+ "signal.h" ,
975
+ "stddef.h" ,
976
+ "stdint.h" ,
977
+ "stdio.h" ,
978
+ "stdlib.h" ,
979
+ "sys/stat.h" ,
980
+ "sys/types.h" ,
981
+ "sys/utime.h" ,
982
+ "time.h" ,
983
+ "wchar.h" ,
984
+ [ gnu] : "ws2tcpip.h" ,
985
+ [ !gnu] : "Winsock2.h" ,
986
+ }
987
+
988
+ cfg. rename_struct_ty ( |ty| {
989
+ match ty {
990
+ // Just pass all these through, no need for a "struct" prefix
991
+ "FILE" | "DIR" | "Dl_info" => ty. to_string ( ) . into ( ) ,
992
+ t if t. ends_with ( "_t" ) => t. to_string ( ) . into ( ) ,
993
+ // Windows uppercase structs don't have `struct` in fr.into()ont:
994
+ t if ty. chars ( ) . next ( ) . unwrap ( ) . is_uppercase ( ) => t. to_string ( ) . into ( ) ,
995
+ "stat" => "struct __stat64" . to_string ( ) . into ( ) ,
996
+ "utimbuf" => "struct __utimbuf64" . to_string ( ) . into ( ) ,
997
+ _ => None ,
998
+ }
999
+ } ) ;
1000
+ cfg. rename_type ( move |ty| {
1001
+ match ty {
1002
+ // FIXME(windows): these don't exist:
1003
+ "time64_t" => "__time64_t" . to_string ( ) . into ( ) ,
1004
+ "ssize_t" => "SSIZE_T" . to_string ( ) . into ( ) ,
1005
+
1006
+ "sighandler_t" if !gnu => "_crt_signal_t" . to_string ( ) . into ( ) ,
1007
+ "sighandler_t" if gnu => "__p_sig_fn_t" . to_string ( ) . into ( ) ,
1008
+ _ => None ,
1009
+ }
1010
+ } ) ;
1011
+
1012
+ cfg. rename_fn ( move |func| {
1013
+ func. link_name ( )
1014
+ . map ( |l| l. to_string ( ) )
1015
+ . or ( func. ident ( ) . to_string ( ) . into ( ) )
1016
+ } ) ;
1017
+
1018
+ cfg. skip_alias ( move |alias| match alias. ident ( ) {
1019
+ "SSIZE_T" if !gnu => true ,
1020
+ "ssize_t" if !gnu => true ,
1021
+ // FIXME(windows): The size and alignment of this type are incorrect
1022
+ "time_t" if gnu && i686 => true ,
1023
+ _ => false ,
1024
+ } ) ;
1025
+
1026
+ cfg. skip_struct ( move |struct_| {
1027
+ let ty = struct_. ident ( ) ;
1028
+ if ty. starts_with ( "__c_anonymous_" ) {
1029
+ return true ;
1030
+ }
1031
+ match ty {
1032
+ // FIXME(windows): The size and alignment of this struct are incorrect
1033
+ "timespec" if gnu && i686 => true ,
1034
+ _ => false ,
1035
+ }
1036
+ } ) ;
1037
+ cfg. skip_union ( move |union_| union_. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
1038
+
1039
+ cfg. skip_const ( move |constant| {
1040
+ match constant. ident ( ) {
1041
+ // FIXME(windows): API error:
1042
+ // SIG_ERR type is "void (*)(int)", not "int"
1043
+ "SIG_ERR" |
1044
+ // Similar for SIG_DFL/IGN/GET/SGE/ACK
1045
+ "SIG_DFL" | "SIG_IGN" | "SIG_GET" | "SIG_SGE" | "SIG_ACK" => true ,
1046
+ // FIXME(windows): newer windows-gnu environment on CI?
1047
+ "_O_OBTAIN_DIR" if gnu => true ,
1048
+ _ => false ,
1049
+ }
1050
+ } ) ;
1051
+
1052
+ cfg. skip_struct_field ( move |s, field| s. ident ( ) == "CONTEXT" && field. ident ( ) == "Fp" ) ;
1053
+ // FIXME(windows): All functions point to the wrong addresses?
1054
+ // cfg.skip_fn_ptr_check(|_| true);
1055
+
1056
+ cfg. skip_signededness ( move |c| {
1057
+ match c {
1058
+ // windows-isms
1059
+ n if n. starts_with ( "P" ) => true ,
1060
+ n if n. starts_with ( "H" ) => true ,
1061
+ n if n. starts_with ( "LP" ) => true ,
1062
+ "sighandler_t" if gnu => true ,
1063
+ _ => false ,
1064
+ }
1065
+ } ) ;
1066
+
1067
+ cfg. skip_fn ( |_| false ) ;
1068
+
1069
+ ctest_next:: generate_test ( & mut cfg, "../src/lib.rs" , "main.rs" ) . unwrap ( ) ;
1070
+ }
1071
+
948
1072
fn test_redox ( target : & str ) {
949
1073
assert ! ( target. contains( "redox" ) ) ;
950
1074
0 commit comments