File tree 1 file changed +10
-2
lines changed 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 1
1
extern crate cc;
2
2
3
3
use std:: env;
4
+ use std:: path:: Path ;
4
5
5
- fn main ( ) {
6
+ // Must be public so the build script of `std` can call it.
7
+ pub fn main ( ) {
6
8
match env:: var ( "CARGO_CFG_TARGET_OS" ) . unwrap_or_default ( ) . as_str ( ) {
7
9
"android" => build_android ( ) ,
8
10
_ => { }
9
11
}
10
12
}
11
13
12
14
fn build_android ( ) {
13
- let expansion = match cc:: Build :: new ( ) . file ( "src/android-api.c" ) . try_expand ( ) {
15
+ // Resolve `src/android-api.c` relative to this file.
16
+ // Required to support calling this from the `std` build script.
17
+ let android_api_c = Path :: new ( file ! ( ) )
18
+ . parent ( )
19
+ . unwrap ( )
20
+ . join ( "src/android-api.c" ) ;
21
+ let expansion = match cc:: Build :: new ( ) . file ( android_api_c) . try_expand ( ) {
14
22
Ok ( result) => result,
15
23
Err ( e) => {
16
24
println ! ( "failed to run C compiler: {}" , e) ;
You can’t perform that action at this time.
0 commit comments