File tree 1 file changed +29
-2
lines changed
1 file changed +29
-2
lines changed Original file line number Diff line number Diff line change
1
+ use std:: env;
2
+ use std:: path:: Path ;
3
+ use std:: process:: Command ;
4
+
1
5
fn main ( ) {
2
- /* println!("cargo:rustc-link-search=native=./");
3
- println!("cargo:rustc-link-lib=k"); */
6
+ let out_dir = env:: var ( "OUT_DIR" ) . unwrap ( ) ;
7
+ let cbqn_dir = Path :: new ( & out_dir) . join ( "CBQN" ) ;
8
+
9
+ if !cbqn_dir. exists ( ) {
10
+ Command :: new ( "git" )
11
+ . args ( [
12
+ "clone" ,
13
+ "https://github.com/dzaima/CBQN.git" ,
14
+ cbqn_dir. to_str ( ) . unwrap ( ) ,
15
+ ] )
16
+ . status ( )
17
+ . expect ( "cargo:warning=Failed to clone CBQN repository" ) ;
18
+ }
19
+
20
+ Command :: new ( "make" )
21
+ . current_dir ( & cbqn_dir)
22
+ . arg ( "static-lib" )
23
+ . arg ( "FFI=0" )
24
+ . status ( )
25
+ . expect ( "cargo:warning=Failed to build CBQN static library" ) ;
26
+
27
+ println ! ( "cargo:rustc-link-search=native={}" , cbqn_dir. display( ) ) ;
28
+ println ! ( "cargo:rustc-link-lib=static=cbqn" ) ;
29
+
30
+ println ! ( "cargo:rerun-if-changed={}" , cbqn_dir. join( "src" ) . display( ) ) ;
4
31
}
You can’t perform that action at this time.
0 commit comments