File tree Expand file tree Collapse file tree 4 files changed +28
-7
lines changed Expand file tree Collapse file tree 4 files changed +28
-7
lines changed Original file line number Diff line number Diff line change 1
- [submodule "xgboost-sys/xgboost "]
2
- path = xgboost-sys/xgboost
3
- url = https://github.com/dmlc/xgboost.git
Original file line number Diff line number Diff line change @@ -13,3 +13,4 @@ libc = "0.2"
13
13
14
14
[build-dependencies ]
15
15
bindgen = " 0.36"
16
+ git2 = " 0.7"
Original file line number Diff line number Diff line change 1
1
extern crate bindgen;
2
+ extern crate git2;
2
3
3
4
use std:: process:: Command ;
4
5
use std:: env;
5
6
use std:: path:: PathBuf ;
6
- use std:: fs:: canonicalize;
7
+
8
+ // Contains symlinks, so cannot be included as a git submodule and packaged with cargo. Downloaded
9
+ // at build time instead.
10
+ static XGBOOST_SRC : & str = "https://github.com/dmlc/xgboost.git" ;
11
+ static XGBOOST_SPEC : & str = "refs/tags/v0.80" ;
7
12
8
13
fn main ( ) {
9
- let target = env:: var ( "TARGET" ) . unwrap ( ) ;
10
- let xgb_root = canonicalize ( "xgboost" ) . unwrap ( ) ;
14
+ let target = env:: var ( "TARGET" ) . expect ( "Failed to read TARGET environment variable" ) ;
15
+
16
+ let xgb_root = std:: path:: Path :: new ( "xgboost" ) ;
17
+
18
+ let repo = {
19
+ if !xgb_root. exists ( ) {
20
+ match git2:: Repository :: clone_recurse ( XGBOOST_SRC , "xgboost" ) {
21
+ Ok ( repo) => repo,
22
+ Err ( e) => panic ! ( "failed to clone: {}" , e) ,
23
+ }
24
+ } else {
25
+ match git2:: Repository :: open ( "xgboost" ) {
26
+ Ok ( repo) => repo,
27
+ Err ( e) => panic ! ( "failed to open: {}" , e) ,
28
+ }
29
+ }
30
+ } ;
31
+
32
+ repo. set_head ( XGBOOST_SPEC ) . expect ( "failed to set head" ) ;
33
+
34
+ let xgb_root = xgb_root. canonicalize ( ) . unwrap ( ) ;
11
35
12
36
// TODO: allow for dynamic/static linking
13
37
// TODO: check whether rabit should be built/linked
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments