@@ -246,24 +246,44 @@ public List<string> BuildObjFiles(){
246246 string compiler_instructions ;
247247 List < string > compiled_oFiles = new List < String > ( ) ;
248248 checks . IsOFileDirExists ( this . build_dir ) ;
249- foreach ( var cFile in this . tcbInfo . c_files ) {
250- string oFile = cFile . Replace ( ".c" , ".o" ) ;
251- //check if C file exists
252- if ( ! File . Exists ( this . source_dir + cFile ) ) {
253- Log . AddToLog ( this . logfile_name , ARTTCBLOGTYPE . ERROR , $ "Something went wrong, when building the object (*.o) files.", ( bool ) this . tcbInfo . generate_log ) ;
254- ClearBuild ( ) ;
255- System . Environment . Exit ( 1 ) ;
249+ int size_cFiles = this . tcbInfo . c_files . Count ( ) ;
250+ if ( size_cFiles == 1 && this . tcbInfo . c_files [ 0 ] == "*" ) {
251+ string [ ] cfiles = Directory . GetFiles ( this . source_dir , "*.c" , SearchOption . AllDirectories ) ;
252+ foreach ( string cfile in cfiles ) {
253+ //check if C file exists
254+ if ( ! File . Exists ( cfile ) ) {
255+ Log . AddToLog ( this . logfile_name , ARTTCBLOGTYPE . ERROR , $ "Something went wrong, when building the object (*.o) files.", ( bool ) this . tcbInfo . generate_log ) ;
256+ ClearBuild ( ) ;
257+ System . Environment . Exit ( 1 ) ;
258+ }
259+ string compiler_args = "" ;
260+ foreach ( var compiler_params in this . tcbInfo . compiler_params ) {
261+ compiler_args += compiler_params + " " ;
262+ }
263+ string ofile_rebase = Path . GetFileName ( cfile . Replace ( ".c" , ".o" ) ) ;
264+ compiler_instructions = $ "-O2 -I { this . includes_dir } -c { cfile } -o { this . object_dir } { ofile_rebase } { compiler_args } ";
265+ ExecuteBuildOnGCC ( ofile_rebase , compiler_instructions ) ;
266+ compiled_oFiles . Add ( ofile_rebase ) ;
256267 }
257- //Check if folder structure is the same in Object folder, otherwise create needed to ensure compilation (better organization)
258- string compiler_args = "" ;
259- foreach ( var compiler_params in this . tcbInfo . compiler_params ) {
260- compiler_args += compiler_params + " " ;
268+ } else {
269+ foreach ( var cFile in this . tcbInfo . c_files ) {
270+ string oFile = cFile . Replace ( ".c" , ".o" ) ;
271+ //check if C file exists
272+ if ( ! File . Exists ( this . source_dir + cFile ) ) {
273+ Log . AddToLog ( this . logfile_name , ARTTCBLOGTYPE . ERROR , $ "Something went wrong, when building the object (*.o) files.", ( bool ) this . tcbInfo . generate_log ) ;
274+ ClearBuild ( ) ;
275+ System . Environment . Exit ( 1 ) ;
276+ }
277+ string compiler_args = "" ;
278+ foreach ( var compiler_params in this . tcbInfo . compiler_params ) {
279+ compiler_args += compiler_params + " " ;
280+ }
281+ string ofile_rebase = Path . GetFileName ( oFile ) ;
282+ compiler_instructions = $ "-O2 -I { this . includes_dir } -c { this . source_dir } { cFile } -o { this . object_dir } { ofile_rebase } { compiler_args } ";
283+ // Console.WriteLine(compiler_instructions); // Debug
284+ ExecuteBuildOnGCC ( ofile_rebase , compiler_instructions ) ;
285+ compiled_oFiles . Add ( oFile ) ;
261286 }
262- string ofile_rebase = Path . GetFileName ( oFile ) ;
263- compiler_instructions = $ "-O2 -I { this . includes_dir } -c { this . source_dir } { cFile } -o { this . object_dir } { ofile_rebase } { compiler_args } ";
264- // Console.WriteLine(compiler_instructions); // Debug
265- ExecuteBuildOnGCC ( ofile_rebase , compiler_instructions ) ;
266- compiled_oFiles . Add ( oFile ) ;
267287 }
268288 return compiled_oFiles ;
269289 }
0 commit comments