@@ -21,7 +21,7 @@ use tauri_bundler::bundle::{bundle_project, PackageType};
2121#[ derive( Debug , Parser ) ]
2222#[ clap( about = "Tauri build" ) ]
2323pub struct Options {
24- /// Binary to use to build the application
24+ /// Binary to use to build the application, defaults to `cargo`
2525 #[ clap( short, long) ]
2626 runner : Option < String > ,
2727 /// Builds with the debug flag
@@ -44,6 +44,8 @@ pub struct Options {
4444 /// JSON string or path to JSON file to merge with tauri.conf.json
4545 #[ clap( short, long) ]
4646 config : Option < String > ,
47+ /// Command line arguments passed to the runner
48+ args : Vec < String > ,
4749}
4850
4951pub fn command ( options : Options ) -> Result < ( ) > {
@@ -136,9 +138,23 @@ pub fn command(options: Options) -> Result<()> {
136138 . or ( runner_from_config)
137139 . unwrap_or_else ( || "cargo" . to_string ( ) ) ;
138140
139- let mut cargo_features = config_. build . features . clone ( ) . unwrap_or_default ( ) ;
140- if let Some ( features) = options. features {
141- cargo_features. extend ( features) ;
141+ let mut features = config_. build . features . clone ( ) . unwrap_or_default ( ) ;
142+ if let Some ( list) = options. features {
143+ features. extend ( list) ;
144+ }
145+
146+ let mut args = Vec :: new ( ) ;
147+ if !options. args . is_empty ( ) {
148+ args. extend ( options. args ) ;
149+ }
150+
151+ if !features. is_empty ( ) {
152+ args. push ( "--features" . into ( ) ) ;
153+ args. push ( features. join ( "," ) ) ;
154+ }
155+
156+ if !options. debug {
157+ args. push ( "--release" . into ( ) ) ;
142158 }
143159
144160 let app_settings = crate :: interface:: rust:: AppSettings :: new ( config_) ?;
@@ -166,13 +182,11 @@ pub fn command(options: Options) -> Result<()> {
166182 . arg ( "-output" )
167183 . arg ( out_dir. join ( & bin_name) ) ;
168184 for triple in [ "aarch64-apple-darwin" , "x86_64-apple-darwin" ] {
169- crate :: interface:: rust:: build_project (
170- runner. clone ( ) ,
171- & Some ( triple. into ( ) ) ,
172- cargo_features. clone ( ) ,
173- options. debug ,
174- )
175- . with_context ( || format ! ( "failed to build {} binary" , triple) ) ?;
185+ let mut args_ = args. clone ( ) ;
186+ args_. push ( "--target" . into ( ) ) ;
187+ args_. push ( triple. into ( ) ) ;
188+ crate :: interface:: rust:: build_project ( runner. clone ( ) , args_)
189+ . with_context ( || format ! ( "failed to build {} binary" , triple) ) ?;
176190 let triple_out_dir = app_settings
177191 . get_out_dir ( Some ( triple. into ( ) ) , options. debug )
178192 . with_context ( || format ! ( "failed to get {} out dir" , triple) ) ?;
@@ -187,8 +201,11 @@ pub fn command(options: Options) -> Result<()> {
187201 ) ) ) ;
188202 }
189203 } else {
190- crate :: interface:: rust:: build_project ( runner, & options. target , cargo_features, options. debug )
191- . with_context ( || "failed to build app" ) ?;
204+ if let Some ( target) = & options. target {
205+ args. push ( "--target" . into ( ) ) ;
206+ args. push ( target. clone ( ) ) ;
207+ }
208+ crate :: interface:: rust:: build_project ( runner, args) . with_context ( || "failed to build app" ) ?;
192209 }
193210
194211 #[ cfg( unix) ]
0 commit comments