Skip to content

Commit

Permalink
- Project name
Browse files Browse the repository at this point in the history
- Skips files that were already compiled
- Reports the number of succeded, failed and skipped compilations
  • Loading branch information
Sasino97 committed Apr 28, 2020
1 parent 976d1b0 commit 365d896
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
1 change: 1 addition & 0 deletions PawnMake/MakeFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
public class MakeFile
{
public string ProjectName { get; set; } = "project";
public BuildFolder[] BuildFolders { get; set; }
public string[] IncludeFolders { get; set; }
public string[] Files { get; set; }
Expand Down
44 changes: 40 additions & 4 deletions PawnMake/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public static void Main(string[] args)
Console.WriteLine("\n----- Starting build... -----");
#endif

int succeeded = 0;
int failed = 0;
int skipped = 0;

Console.WriteLine($"------ Build started - Project: {makeFile.ProjectName} ------");

foreach (string file in makeFile.Files)
{
foreach (BuildFolder build in makeFile.BuildFolders)
Expand All @@ -69,15 +75,27 @@ public static void Main(string[] args)
if (File.Exists(srcPath))
{
string outPath = Path.Combine(build.OutputFolder, Path.GetFileNameWithoutExtension(file) + ".amx");

// check last compile time
DateTime srcTime = File.GetLastWriteTime(srcPath);
DateTime outTime = File.GetLastWriteTime(outPath);

if (srcTime < outTime)
{
Console.WriteLine($"* Skipping {srcPath}");
skipped++;
continue;
}

string compilerArgs = $"\"{srcPath}\" -o\"{outPath}\" ";

foreach (string incPath in makeFile.IncludeFolders)
compilerArgs += $"-i\"{incPath}\" ";

if(!string.IsNullOrWhiteSpace(makeFile.Args))
if (!string.IsNullOrWhiteSpace(makeFile.Args))
compilerArgs += $"{makeFile.Args} ";

Console.WriteLine($"\nCompiling {srcPath} ...");
Console.WriteLine($"* Compiling {srcPath} -> {outPath}");

var pawnccOutput = new StringBuilder();
var startInfo = new ProcessStartInfo()
Expand Down Expand Up @@ -105,13 +123,31 @@ public static void Main(string[] args)

process.WaitForExit(5000);

Console.WriteLine(pawnccOutput.ToString());
string finalOutput = pawnccOutput
.ToString()
.Insert(0, " ")
.Replace("\n", "\n ")
.TrimEnd()
;

if (finalOutput.Contains(" Error.") || finalOutput.Contains(" Errors."))
failed++;
else
succeeded++;

if (finalOutput.Contains(" Error.") || finalOutput.Contains(" Errors.")
|| finalOutput.Contains(" Warning.") || finalOutput.Contains(" Warnings."))
{
Console.WriteLine(finalOutput + "\n");
}
}
}
}
}

if(args.Length > 1)
Console.WriteLine($"========== Build: {succeeded} succeeded, {failed} failed, {skipped} skipped ==========");

if (args.Length > 1)
{
string parameter = args[1];
if(parameter == "-r")
Expand Down
6 changes: 3 additions & 3 deletions PawnMake/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PawnMake")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyCopyright("Copyright © 2019 - 2020 Sasinosoft")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
// usando l'asterisco '*' come illustrato di seguito:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]

0 comments on commit 365d896

Please sign in to comment.