slight refactor

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.
This commit is contained in:
LotP1 2024-12-28 02:16:17 +01:00
parent 4e56b1493f
commit 8efefeaaca
3 changed files with 18 additions and 18 deletions

View file

@ -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...");
@ -23,6 +25,8 @@ namespace Ryujinx.BuildValidationTasks
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
{
@ -34,12 +38,7 @@ namespace Ryujinx.BuildValidationTasks
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;

View file

@ -12,28 +12,29 @@ namespace Ryujinx.BuildValidationTasks
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!");
}
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);
}
}
}

View file

@ -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);
}
}