@@ -4,6 +4,7 @@ use std::error::Error;
4
4
use std:: fs;
5
5
use std:: io:: { BufRead , BufReader } ;
6
6
use std:: path:: { Path , PathBuf } ;
7
+ use std:: process:: Command ;
7
8
8
9
fn main ( ) -> Result < ( ) , Box < dyn Error > > {
9
10
let conf = {
@@ -12,7 +13,14 @@ fn main() -> Result<(), Box<dyn Error>> {
12
13
let f = fs:: File :: open ( "conf.pri" ) ?;
13
14
let reader = BufReader :: new ( f) ;
14
15
15
- const CONF_VARS : & [ & str ] = & [ "APP_VERSION" , "CONFIGDIR" , "LIBDIR" , "QT_INSTALL_LIBS" ] ;
16
+ const CONF_VARS : & [ & str ] = & [
17
+ "APP_VERSION" ,
18
+ "CONFIGDIR" ,
19
+ "LIBDIR" ,
20
+ "QT_INSTALL_LIBS" ,
21
+ "QMAKE_PATH" ,
22
+ "MAKETOOL" ,
23
+ ] ;
16
24
17
25
for line in reader. lines ( ) {
18
26
let line = line?;
@@ -35,9 +43,25 @@ fn main() -> Result<(), Box<dyn Error>> {
35
43
let config_dir = conf. get ( "CONFIGDIR" ) . unwrap ( ) ;
36
44
let lib_dir = conf. get ( "LIBDIR" ) . unwrap ( ) ;
37
45
let qt_install_libs = conf. get ( "QT_INSTALL_LIBS" ) . unwrap ( ) ;
46
+ let qmake_path = fs:: canonicalize ( conf. get ( "QMAKE_PATH" ) . unwrap ( ) ) ?;
47
+ let maketool = fs:: canonicalize ( conf. get ( "MAKETOOL" ) . unwrap ( ) ) ?;
38
48
39
- let cpp_lib_dir =
40
- PathBuf :: from ( env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) . join ( Path :: new ( "target/cpp" ) ) ;
49
+ let root_dir = PathBuf :: from ( env:: var ( "CARGO_MANIFEST_DIR" ) ?) ;
50
+ let cpp_src_dir = root_dir. join ( Path :: new ( "src/cpp" ) ) ;
51
+ let cpp_lib_dir = root_dir. join ( Path :: new ( "target/cpp" ) ) ;
52
+
53
+ if !cpp_src_dir. join ( "Makefile" ) . try_exists ( ) ? {
54
+ assert ! ( Command :: new( qmake_path)
55
+ . args( [ "-o" , "Makefile" , "cpp.pro" ] )
56
+ . current_dir( & cpp_src_dir)
57
+ . status( ) ?
58
+ . success( ) ) ;
59
+ }
60
+
61
+ assert ! ( Command :: new( maketool)
62
+ . current_dir( & cpp_src_dir)
63
+ . status( ) ?
64
+ . success( ) ) ;
41
65
42
66
println ! ( "cargo:rustc-env=APP_VERSION={}" , app_version) ;
43
67
println ! ( "cargo:rustc-env=CONFIG_DIR={}" , config_dir) ;
@@ -53,14 +77,6 @@ fn main() -> Result<(), Box<dyn Error>> {
53
77
54
78
println ! ( "cargo:rerun-if-changed=conf.pri" ) ;
55
79
println ! ( "cargo:rerun-if-changed=src" ) ;
56
- println ! (
57
- "cargo:rerun-if-changed={}/libpushpin-cpp.a" ,
58
- cpp_lib_dir. display( )
59
- ) ;
60
- println ! (
61
- "cargo:rerun-if-changed={}/libpushpin-cpptest.a" ,
62
- cpp_lib_dir. display( )
63
- ) ;
64
80
65
81
Ok ( ( ) )
66
82
}
0 commit comments