File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ fn main() -> io::Result<()> {
77 println ! ( "cargo:rerun-if-changed=src/tests" ) ;
88
99 println ! ( "cargo:rustc-check-cfg=cfg(trybuild_no_target)" ) ;
10+ println ! ( "cargo:rustc-check-cfg=cfg(host_os, values(\" windows\" ))" ) ;
1011
1112 let out_dir = env:: var_os ( "OUT_DIR" ) . unwrap ( ) ;
1213 let target = env:: var ( "TARGET" ) . ok ( ) ;
@@ -15,5 +16,12 @@ fn main() -> io::Result<()> {
1516 Some ( target) => format ! ( r#"Some("{}")"# , target. escape_debug( ) ) ,
1617 None => "None" . to_owned ( ) ,
1718 } ;
18- fs:: write ( path, value)
19+ fs:: write ( path, value) ?;
20+
21+ let host = env:: var_os ( "HOST" ) . unwrap ( ) ;
22+ if let Some ( "windows" ) = host. to_str ( ) . unwrap ( ) . split ( '-' ) . nth ( 2 ) {
23+ println ! ( "cargo:rustc-cfg=host_os=\" windows\" " ) ;
24+ }
25+
26+ Ok ( ( ) )
1927}
Original file line number Diff line number Diff line change @@ -183,8 +183,12 @@ fn features(project: &Project) -> Vec<String> {
183183}
184184
185185fn target ( ) -> Vec < & ' static str > {
186+ #[ cfg( not( host_os = "windows" ) ) ]
186187 const TARGET : Option < & str > = include ! ( concat!( env!( "OUT_DIR" ) , "/target" ) ) ;
187188
189+ #[ cfg( host_os = "windows" ) ]
190+ const TARGET : Option < & str > = include ! ( concat!( env!( "OUT_DIR" ) , "\\ target" ) ) ;
191+
188192 // When --target flag is passed, cargo does not pass RUSTFLAGS to rustc when
189193 // building proc-macro and build script even if the host and target triples
190194 // are the same. Therefore, if we always pass --target to cargo, tools such
You can’t perform that action at this time.
0 commit comments