File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -2,11 +2,22 @@ extern crate bindgen;
2
2
3
3
use std:: process:: Command ;
4
4
use std:: env;
5
- use std:: path:: PathBuf ;
5
+ use std:: path:: { Path , PathBuf } ;
6
6
7
7
fn main ( ) {
8
- let xgb_root = std:: fs:: canonicalize ( "xgboost" ) . unwrap ( ) ;
9
8
let target = env:: var ( "TARGET" ) . unwrap ( ) ;
9
+ let out_dir = env:: var ( "OUT_DIR" ) . unwrap ( ) ;
10
+ let xgb_root = Path :: new ( & out_dir) . join ( "xgboost" ) ;
11
+
12
+ // copy source code into OUT_DIR for compilation if it doesn't exist
13
+ if !xgb_root. exists ( ) {
14
+ Command :: new ( "cp" )
15
+ . args ( & [ "-r" , "xgboost" , xgb_root. to_str ( ) . unwrap ( ) ] )
16
+ . status ( )
17
+ . unwrap_or_else ( |e| {
18
+ panic ! ( "Failed to copy ./xgboost to {}: {}" , xgb_root. display( ) , e) ;
19
+ } ) ;
20
+ }
10
21
11
22
// TODO: allow for dynamic/static linking
12
23
// TODO: check whether rabit should be built/linked
@@ -19,6 +30,8 @@ fn main() {
19
30
. expect ( "Failed to execute XGBoost build.sh script." ) ;
20
31
}
21
32
33
+ let xgb_root = xgb_root. canonicalize ( ) . unwrap ( ) ;
34
+
22
35
let bindings = bindgen:: Builder :: default ( )
23
36
. header ( "wrapper.h" )
24
37
. clang_arg ( format ! ( "-I{}" , xgb_root. join( "include" ) . display( ) ) )
You can’t perform that action at this time.
0 commit comments