File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ categories = ["development-tools::testing"]
66description = " Test harness for ui tests of compiler diagnostics"
77documentation = " https://docs.rs/trybuild"
88edition = " 2021"
9- exclude = [" screenshots/*" ]
9+ exclude = [" build.rs " , " screenshots/*" ]
1010keywords = [" macros" , " testing" , " dev-dependencies" ]
1111license = " MIT OR Apache-2.0"
1212repository = " https://github.com/dtolnay/trybuild"
@@ -24,6 +24,7 @@ glob = "0.3"
2424serde = " 1.0.194"
2525serde_derive = " 1.0.194"
2626serde_json = " 1.0.110"
27+ target-triple = " 0.1"
2728termcolor = " 1.0.4"
2829toml = " 0.8"
2930
Original file line number Diff line number Diff line change 1- use std:: env;
2- use std:: fs;
3- use std:: io;
4- use std:: path:: Path ;
1+ fn main ( ) {
2+ // Warning: build.rs is not published to crates.io.
53
6- fn main ( ) -> io:: Result < ( ) > {
74 println ! ( "cargo:rerun-if-changed=src/tests" ) ;
8-
95 println ! ( "cargo:rustc-check-cfg=cfg(trybuild_no_target)" ) ;
10- println ! ( "cargo:rustc-check-cfg=cfg(host_os, values(\" windows\" ))" ) ;
11-
12- let out_dir = env:: var_os ( "OUT_DIR" ) . unwrap ( ) ;
13- let target = env:: var ( "TARGET" ) . unwrap ( ) ;
14- let path = Path :: new ( & out_dir) . join ( "target" ) ;
15- let value = format ! ( r#""{}""# , target. escape_debug( ) ) ;
16- fs:: write ( path, value) ?;
17-
18- let host = env:: var_os ( "HOST" ) . unwrap ( ) ;
19- if let Some ( "windows" ) = host. to_str ( ) . unwrap ( ) . split ( '-' ) . nth ( 2 ) {
20- println ! ( "cargo:rustc-cfg=host_os=\" windows\" " ) ;
21- }
22-
23- Ok ( ( ) )
246}
Original file line number Diff line number Diff line change @@ -183,12 +183,6 @@ fn features(project: &Project) -> Vec<String> {
183183}
184184
185185fn target ( ) -> Vec < & ' static str > {
186- #[ cfg( not( host_os = "windows" ) ) ]
187- const TARGET : & str = include ! ( concat!( env!( "OUT_DIR" ) , "/target" ) ) ;
188-
189- #[ cfg( host_os = "windows" ) ]
190- const TARGET : & str = include ! ( concat!( env!( "OUT_DIR" ) , "\\ target" ) ) ;
191-
192186 // When --target flag is passed, cargo does not pass RUSTFLAGS to rustc when
193187 // building proc-macro and build script even if the host and target triples
194188 // are the same. Therefore, if we always pass --target to cargo, tools such
@@ -205,6 +199,6 @@ fn target() -> Vec<&'static str> {
205199 if cfg ! ( trybuild_no_target) {
206200 vec ! [ ]
207201 } else {
208- vec ! [ "--target" , TARGET ]
202+ vec ! [ "--target" , target_triple :: TARGET ]
209203 }
210204}
You can’t perform that action at this time.
0 commit comments