@@ -14,6 +14,9 @@ pub use self::Version::*;
14
14
pub struct Build {
15
15
out_dir : Option < PathBuf > ,
16
16
target : Option < String > ,
17
+ host : Option < String > ,
18
+ opt_level : Option < String > ,
19
+ debug : Option < bool > ,
17
20
}
18
21
19
22
pub struct Artifacts {
@@ -27,6 +30,9 @@ impl Default for Build {
27
30
Build {
28
31
out_dir : env:: var_os ( "OUT_DIR" ) . map ( PathBuf :: from) ,
29
32
target : env:: var ( "TARGET" ) . ok ( ) ,
33
+ host : None ,
34
+ opt_level : None ,
35
+ debug : None ,
30
36
}
31
37
}
32
38
}
@@ -46,6 +52,21 @@ impl Build {
46
52
self
47
53
}
48
54
55
+ pub fn host ( & mut self , host : & str ) -> & mut Build {
56
+ self . host = Some ( host. to_string ( ) ) ;
57
+ self
58
+ }
59
+
60
+ pub fn opt_level ( & mut self , opt_level : & str ) -> & mut Build {
61
+ self . opt_level = Some ( opt_level. to_string ( ) ) ;
62
+ self
63
+ }
64
+
65
+ pub fn debug ( & mut self , debug : bool ) -> & mut Build {
66
+ self . debug = Some ( debug) ;
67
+ self
68
+ }
69
+
49
70
pub fn build ( & mut self , version : Version ) -> Artifacts {
50
71
let target = & self . target . as_ref ( ) . expect ( "TARGET is not set" ) [ ..] ;
51
72
let out_dir = self . out_dir . as_ref ( ) . expect ( "OUT_DIR is not set" ) ;
@@ -120,8 +141,17 @@ impl Build {
120
141
config. define ( "LUA_UCID" , None ) ;
121
142
}
122
143
123
- if cfg ! ( debug_assertions) {
144
+ if self . debug . unwrap_or ( cfg ! ( debug_assertions) ) {
124
145
config. define ( "LUA_USE_APICHECK" , None ) ;
146
+ config. debug ( true ) ;
147
+ }
148
+
149
+ if let Some ( host) = & self . host {
150
+ config. host ( host) ;
151
+ }
152
+
153
+ if let Some ( opt_level) = & self . opt_level {
154
+ config. opt_level_str ( opt_level) ;
125
155
}
126
156
127
157
config
0 commit comments