File tree 1 file changed +0
-36
lines changed
1 file changed +0
-36
lines changed Original file line number Diff line number Diff line change 1
- use env:: consts:: { EXE_EXTENSION , EXE_SUFFIX } ;
2
1
use std:: env;
3
- use std:: ffi:: OsString ;
4
- use std:: path:: PathBuf ;
5
-
6
- /// Given an executable called `name`, return the filename for the
7
- /// executable for a particular target.
8
- pub fn exe ( name : & PathBuf ) -> PathBuf {
9
- if EXE_EXTENSION != "" && name. extension ( ) != Some ( EXE_EXTENSION . as_ref ( ) ) {
10
- let mut name: OsString = name. clone ( ) . into ( ) ;
11
- name. push ( EXE_SUFFIX ) ;
12
- name. into ( )
13
- } else {
14
- name. clone ( )
15
- }
16
- }
17
2
18
3
fn main ( ) {
19
4
let host = env:: var ( "HOST" ) . unwrap ( ) ;
20
5
println ! ( "cargo:rerun-if-changed=build.rs" ) ;
21
- println ! ( "cargo:rerun-if-env-changed=RUSTC" ) ;
22
6
println ! ( "cargo:rustc-env=BUILD_TRIPLE={}" , host) ;
23
-
24
- // This may not be a canonicalized path.
25
- let mut rustc = PathBuf :: from ( env:: var_os ( "RUSTC" ) . unwrap ( ) ) ;
26
-
27
- if rustc. is_relative ( ) {
28
- println ! ( "cargo:rerun-if-env-changed=PATH" ) ;
29
- for dir in env:: split_paths ( & env:: var_os ( "PATH" ) . unwrap_or_default ( ) ) {
30
- let absolute = dir. join ( & exe ( & rustc) ) ;
31
- if absolute. exists ( ) {
32
- rustc = absolute;
33
- break ;
34
- }
35
- }
36
- }
37
- assert ! ( rustc. is_absolute( ) ) ;
38
-
39
- // FIXME: if the path is not utf-8, this is going to break. Unfortunately
40
- // Cargo doesn't have a way for us to specify non-utf-8 paths easily, so
41
- // we'll need to invent some encoding scheme if this becomes a problem.
42
- println ! ( "cargo:rustc-env=RUSTC={}" , rustc. to_str( ) . unwrap( ) ) ;
43
7
}
You can’t perform that action at this time.
0 commit comments