Skip to content

Commit 9610b45

Browse files
committed
Use "*" to ref. all *.c files in "c_files" on "buildme.tcb file"
[ NEW ] * You can now use "*" in the first "c_files" array to build all *.c files inside source folder "code_main_dir"; + OBS: You can continue using per-file reference if you desire;
1 parent 64e46a1 commit 9610b45

3 files changed

Lines changed: 42 additions & 22 deletions

File tree

ARTTCBConsole/ARTTCBConsole.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
<RepositoryUrl>https://github.com/ArTDsL/ARTTCB/</RepositoryUrl>
1717
<RepositoryType>git</RepositoryType>
1818
<NeutralLanguage>en</NeutralLanguage>
19-
<AssemblyVersion>1.2.1</AssemblyVersion>
20-
<FileVersion>1.2.1</FileVersion>
19+
<AssemblyVersion>2.0.0</AssemblyVersion>
20+
<FileVersion>2.0.0</FileVersion>
2121
<PackageLicenseFile>LICENSE</PackageLicenseFile>
2222
<StartupObject>ConsoleMain</StartupObject>
23-
<Version>1.2.1</Version>
23+
<Version>2.0.0</Version>
2424
<PackAsTool>True</PackAsTool>
2525
</PropertyGroup>
2626

ARTTCBLib/ARTTCB.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
<Product>ART Tiny C Builder (ARTTCB)</Product>
1818
<Company>https://github.com/ArTDsL/</Company>
1919
<Description>ART Tiny C Builder (ARTTCB) - Library</Description>
20-
<FileVersion>1.2.1</FileVersion>
21-
<AssemblyVersion>1.2.1</AssemblyVersion>
20+
<FileVersion>2.0.0</FileVersion>
21+
<AssemblyVersion>2.0.0</AssemblyVersion>
2222
<NeutralLanguage>en</NeutralLanguage>
2323
<PackageLicenseFile>LICENSE</PackageLicenseFile>
24-
<Version>1.2.1</Version>
24+
<Version>2.0.0</Version>
2525
</PropertyGroup>
2626

2727
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

ARTTCBLib/Build.cs

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)