@@ -126,32 +126,30 @@ impl<'a> FlatpakManager<'a> {
126126 buildsystem,
127127 config_opts,
128128 build_commands,
129+ post_install,
129130 ..
130- } => match buildsystem. as_deref ( ) {
131- Some ( "meson" ) => self . run_meson ( repo_dir_str, config_opts. as_ref ( ) ) ?,
132- Some ( "cmake" ) | Some ( "cmake-ninja" ) => {
133- self . run_cmake ( repo_dir_str, config_opts. as_ref ( ) ) ?
131+ } => {
132+ match buildsystem. as_deref ( ) {
133+ Some ( "meson" ) => self . run_meson ( repo_dir_str, config_opts. as_ref ( ) ) ?,
134+ Some ( "cmake" ) | Some ( "cmake-ninja" ) => {
135+ self . run_cmake ( repo_dir_str, config_opts. as_ref ( ) ) ?
136+ }
137+ Some ( "simple" ) => self . run_simple ( repo_dir_str, build_commands. as_ref ( ) ) ?,
138+ _ => self . run_autotools ( repo_dir_str, config_opts. as_ref ( ) ) ?,
134139 }
135- Some ( "simple" ) => self . run_simple ( repo_dir_str, build_commands. as_ref ( ) ) ?,
136- _ => self . run_autotools ( repo_dir_str, config_opts. as_ref ( ) ) ?,
137- } ,
140+ if let Some ( post_install) = post_install {
141+ for command in post_install {
142+ let args: Vec < & str > = command. split_whitespace ( ) . collect ( ) ;
143+ run_command ( args[ 0 ] , & args[ 1 ..] , Some ( self . state . base_dir . as_path ( ) ) ) ?;
144+ }
145+ }
146+ }
138147 Module :: Reference ( _) => {
139148 // Skip string references for build_application
140149 }
141150 }
142151 }
143152
144- if let Some ( Module :: Object {
145- post_install : Some ( post_install) ,
146- ..
147- } ) = manifest. modules . last ( )
148- {
149- for command in post_install {
150- let args: Vec < & str > = command. split_whitespace ( ) . collect ( ) ;
151- run_command ( args[ 0 ] , & args[ 1 ..] , Some ( self . state . base_dir . as_path ( ) ) ) ?;
152- }
153- }
154-
155153 Ok ( ( ) )
156154 }
157155
@@ -377,31 +375,30 @@ impl<'a> FlatpakManager<'a> {
377375 let manifest = self . manifest . as_ref ( ) . unwrap ( ) ;
378376 let repo_dir = self . build_dir ( ) . join ( "repo" ) ;
379377
380- let mut args = vec ! [
381- "build" . to_string( ) ,
382- "--with-appdir" . to_string( ) ,
383- "--allow=devel" . to_string( ) ,
384- "--talk-name=org.freedesktop.portal.*" . to_string( ) ,
385- "--talk-name=org.a11y.Bus" . to_string( ) ,
386- ] ;
387-
388- for ( key, value) in get_host_env ( ) {
389- args. push ( format ! ( "--env={key}={value}" ) ) ;
390- }
378+ let mut args: Vec < String > = [
379+ "build" ,
380+ "--with-appdir" ,
381+ "--allow=devel" ,
382+ "--talk-name=org.freedesktop.portal.*" ,
383+ "--talk-name=org.a11y.Bus" ,
384+ ]
385+ . iter ( )
386+ . map ( |s| s. to_string ( ) )
387+ . collect ( ) ;
388+
389+ args. extend (
390+ get_host_env ( )
391+ . into_iter ( )
392+ . map ( |( key, value) | format ! ( "--env={key}={value}" ) ) ,
393+ ) ;
391394
392- for arg in get_a11y_bus_args ( ) {
393- args. push ( arg) ;
394- }
395+ args. extend ( get_a11y_bus_args ( ) ) ;
395396
396- for arg in & manifest. finish_args {
397- args. push ( arg. clone ( ) ) ;
398- }
397+ args. extend ( manifest. finish_args . clone ( ) ) ;
399398 args. push ( repo_dir. to_str ( ) . unwrap ( ) . to_string ( ) ) ;
400399 args. push ( manifest. command . clone ( ) ) ;
401400 if let Some ( x_run_args) = & manifest. x_run_args {
402- for arg in x_run_args {
403- args. push ( arg. clone ( ) ) ;
404- }
401+ args. extend ( x_run_args. clone ( ) ) ;
405402 }
406403
407404 let args_str: Vec < & str > = args. iter ( ) . map ( |s| s. as_str ( ) ) . collect ( ) ;
@@ -449,12 +446,10 @@ impl<'a> FlatpakManager<'a> {
449446 ) ?;
450447
451448 // Finalize build
452- let mut args = vec ! [ "build-finish" . to_string( ) ] ;
449+ let mut args: Vec < String > = vec ! [ "build-finish" . to_string( ) ] ;
453450
454- for arg in & manifest. finish_args {
455- args. push ( arg. clone ( ) ) ;
456- }
457- args. push ( format ! ( "--command={}" , manifest. command. clone( ) ) ) ;
451+ args. extend ( manifest. finish_args . clone ( ) ) ;
452+ args. push ( format ! ( "--command={}" , manifest. command) ) ;
458453 args. push ( finalized_repo_dir. to_str ( ) . unwrap ( ) . to_string ( ) ) ;
459454
460455 let args_str: Vec < & str > = args. iter ( ) . map ( |s| s. as_str ( ) ) . collect ( ) ;
@@ -556,22 +551,23 @@ impl<'a> FlatpakManager<'a> {
556551 return Ok ( ( ) ) ;
557552 }
558553
559- let mut default_selection = 0 ;
560554 let manifest_strings: Vec < String > = manifests
561555 . iter ( )
562- . enumerate ( )
563- . map ( |( i, p) | {
556+ . map ( |p| {
564557 let path_str = p. to_str ( ) . unwrap ( ) . to_string ( ) ;
565- if let Some ( active_manifest) = & self . state . active_manifest {
566- if active_manifest == p {
567- default_selection = i;
568- return format ! ( "{} {}" , "*" . green( ) . bold( ) , path_str) ;
569- }
558+ if self . state . active_manifest . as_ref ( ) == Some ( p) {
559+ format ! ( "{} {}" , "*" . green( ) . bold( ) , path_str)
560+ } else {
561+ format ! ( " {path_str}" )
570562 }
571- format ! ( " {path_str}" )
572563 } )
573564 . collect ( ) ;
574565
566+ let default_selection = manifests
567+ . iter ( )
568+ . position ( |p| self . state . active_manifest . as_ref ( ) == Some ( p) )
569+ . unwrap_or ( 0 ) ;
570+
575571 let theme = ColorfulTheme :: default ( ) ;
576572 let selection = Select :: with_theme ( & theme)
577573 . with_prompt ( "Select a manifest" )
0 commit comments