Skip to content

Commit

Permalink
slight refactor
Browse files Browse the repository at this point in the history
isGitRunner is now a variable passed to all tasks.
Validation project can now accept more arguments, only the first argument is used at the moment.
Execute is no longer static, and you can now pass extra data to the task constructor if needed.
  • Loading branch information
LotP1 committed Dec 28, 2024
1 parent 4e56b14 commit 8efefea
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
11 changes: 5 additions & 6 deletions src/Ryujinx.BuildValidationTasks/LocalesValidationTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ namespace Ryujinx.BuildValidationTasks
{
public class LocalesValidationTask : ValidationTask
{
public static bool Execute(string projectPath)
public LocalesValidationTask() { }

public bool Execute(string projectPath, bool isGitRunner)
{
Console.WriteLine("Running Locale Validation Task...");

Expand All @@ -23,6 +25,8 @@ public static bool Execute(string projectPath)

LocalesJson json;

if (isGitRunner && data.Contains("\r\n"))
throw new FormatException("locales.json is using CRLF line endings! It should be using LF line endings, build locally to fix...");

try
{
Expand All @@ -34,12 +38,7 @@ public static bool Execute(string projectPath)
throw new JsonException(e.Message); //shorter and easier stacktrace
}

bool isGitRunner = path.Contains("runner") || path.Contains("D:\\a\\Ryujinx\\Ryujinx");
if (isGitRunner)
Console.WriteLine("Is Git Runner!");

if (isGitRunner && data.Contains("\r\n"))
throw new FormatException("locales.json is using CRLF line endings! It should be using LF line endings, build locally to fix...");

bool encounteredIssue = false;

Expand Down
23 changes: 12 additions & 11 deletions src/Ryujinx.BuildValidationTasks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,29 @@ public class Program
static void Main(string[] args)
{
// Display the number of command line arguments.
if (args.Length != 1)
{
if (args.Length == 0)
throw new ArgumentException("Error: too few arguments!");
else
throw new ArgumentException("Error: too many arguments!");
}
if (args.Length == 0)
throw new ArgumentException("Error: too few arguments!");

string path = args[0];

if (string.IsNullOrEmpty(path))
throw new ArgumentException("Error: path is null or empty!");

if (!Path.Exists(args[0]))
throw new ArgumentException($"path {{{path}}} does not exist!");
if (!Path.Exists(path))
throw new FileLoadException($"path {{{path}}} does not exist!");

path = Path.GetFullPath(path);

if (!Directory.GetDirectories(path).Contains($"{path}src"))
throw new ArgumentException($"path {{{path}}} is not a valid ryujinx project!");
throw new FileLoadException($"path {{{path}}} is not a valid ryujinx project!");

LocalesValidationTask.Execute(path);
bool isGitRunner = path.Contains("runner") || path.Contains("D:\\a\\Ryujinx\\Ryujinx");
if (isGitRunner)
Console.WriteLine("Is Git Runner!");

// Run tasks
// Pass extra info needed in the task constructors
new LocalesValidationTask().Execute(path, isGitRunner);
}
}
}
2 changes: 1 addition & 1 deletion src/Ryujinx.BuildValidationTasks/ValidationTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ namespace Ryujinx.BuildValidationTasks
{
public interface ValidationTask
{
public static bool Execute(string projectPath) { return true; }
public bool Execute(string projectPath, bool isGitRunner);
}
}

0 comments on commit 8efefea

Please sign in to comment.