@@ -13,6 +13,7 @@ use colored::Colorize;
1313use crate :: {
1414 config:: { ProjectConfig , compile:: BuildSystem } ,
1515 shell:: { Shell , check_porgram, metadata} ,
16+ step:: UbootConfig ,
1617} ;
1718
1819#[ derive( Default ) ]
@@ -68,6 +69,42 @@ impl Project {
6869 Ok ( ( ) )
6970 }
7071
72+ pub fn board_test_config ( & mut self ) -> Result < ( ) > {
73+ let meta = metadata ( self . workdir ( ) ) ;
74+ let config_path = meta. workspace_root . as_std_path ( ) . join ( ".project.toml" ) ;
75+ let board_toml_path = meta. workspace_root . as_std_path ( ) . join ( ".board.toml" ) ;
76+
77+ let mut config: ProjectConfig ;
78+ if !config_path. try_exists ( ) ? {
79+ panic ! ( ".project.toml file not found!" ) ;
80+ } else {
81+ let content = fs:: read_to_string ( & config_path) . unwrap ( ) ;
82+ config = toml:: from_str ( & content) . expect ( ".project.toml file not found!!" ) ;
83+
84+ config. include = Some ( vec ! [ board_toml_path. clone( ) ] ) ;
85+ if let Some ( include_files) = & config. include {
86+ for board_toml in include_files {
87+ if board_toml_path. exists ( ) {
88+ let board_content = fs:: read_to_string ( & board_toml_path) . unwrap ( ) ;
89+ let board_config: UbootConfig =
90+ toml:: from_str ( & board_content) . expect ( ".board.toml file not found!" ) ;
91+ // Merge the board-specific settings into the UbootConfig
92+ config. uboot = Some ( board_config) ;
93+ } else {
94+ println ! (
95+ "Warning: Include file does not exist: {}" ,
96+ board_toml_path. display( )
97+ ) ;
98+ }
99+ }
100+ }
101+ }
102+
103+ self . arch = Some ( Arch :: from_target ( & config. compile . target ) . unwrap ( ) ) ;
104+ self . config = Some ( config) ;
105+ Ok ( ( ) )
106+ }
107+
71108 pub fn config_ref ( & self ) -> & ProjectConfig {
72109 self . config . as_ref ( ) . unwrap ( )
73110 }
0 commit comments