@@ -14,6 +14,9 @@ pub use self::Version::*;
1414pub struct Build {
1515 out_dir : Option < PathBuf > ,
1616 target : Option < String > ,
17+ host : Option < String > ,
18+ opt_level : Option < String > ,
19+ debug : Option < bool > ,
1720}
1821
1922pub struct Artifacts {
@@ -27,6 +30,9 @@ impl Default for Build {
2730 Build {
2831 out_dir : env:: var_os ( "OUT_DIR" ) . map ( PathBuf :: from) ,
2932 target : env:: var ( "TARGET" ) . ok ( ) ,
33+ host : None ,
34+ opt_level : None ,
35+ debug : None ,
3036 }
3137 }
3238}
@@ -46,6 +52,21 @@ impl Build {
4652 self
4753 }
4854
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+
4970 pub fn build ( & mut self , version : Version ) -> Artifacts {
5071 let target = & self . target . as_ref ( ) . expect ( "TARGET is not set" ) [ ..] ;
5172 let out_dir = self . out_dir . as_ref ( ) . expect ( "OUT_DIR is not set" ) ;
@@ -120,8 +141,17 @@ impl Build {
120141 config. define ( "LUA_UCID" , None ) ;
121142 }
122143
123- if cfg ! ( debug_assertions) {
144+ if self . debug . unwrap_or ( cfg ! ( debug_assertions) ) {
124145 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) ;
125155 }
126156
127157 config
0 commit comments