v4
This commit is contained in:
parent
1bac6ab19e
commit
8c0a82bb6e
@ -1,22 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using Microsoft.Build.Utilities;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using Microsoft.Build.Framework;
|
|
||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
|
|
||||||
namespace Ryujinx.BuildValidationTasks
|
namespace Ryujinx.BuildValidationTasks
|
||||||
{
|
{
|
||||||
public class LocalesValidationTask : Task
|
public class LocalesValidationTask : ValidationTask
|
||||||
{
|
{
|
||||||
public string Path { get; set; }
|
public static bool Execute(string projectPath)
|
||||||
|
|
||||||
public override bool Execute()
|
|
||||||
{
|
{
|
||||||
string path = Path;
|
string path = projectPath + "src\\Ryujinx\\Assets\\locales.json";
|
||||||
|
|
||||||
string data;
|
string data;
|
||||||
|
|
||||||
using (StreamReader sr = new(path))
|
using (StreamReader sr = new(path))
|
||||||
@ -34,7 +29,7 @@ namespace Ryujinx.BuildValidationTasks
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.LogError($"Json Validation failed! {e.Message}");
|
//Log.LogError($"Json Validation failed! {e.Message}");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -47,7 +42,7 @@ namespace Ryujinx.BuildValidationTasks
|
|||||||
foreach (string langCode in json.Languages.Where(it => !locale.Translations.ContainsKey(it)))
|
foreach (string langCode in json.Languages.Where(it => !locale.Translations.ContainsKey(it)))
|
||||||
{
|
{
|
||||||
locale.Translations.Add(langCode, string.Empty);
|
locale.Translations.Add(langCode, string.Empty);
|
||||||
Log.LogMessage(MessageImportance.High, $"Added '{langCode}' to Locale '{locale.ID}'");
|
//Log.LogMessage(MessageImportance.High, $"Added '{langCode}' to Locale '{locale.ID}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
locale.Translations = locale.Translations.OrderBy(pair => pair.Key).ToDictionary(pair => pair.Key, pair => pair.Value);
|
locale.Translations = locale.Translations.OrderBy(pair => pair.Key).ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||||
|
@ -1,60 +1,23 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
|
|
||||||
<temp_assemblies>$(MSBuildThisFileDirectory)temp_assemblies/</temp_assemblies>
|
<temp_assemblies>$(MSBuildThisFileDirectory)temp_assemblies/</temp_assemblies>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.Build.Tasks.Core" />
|
|
||||||
<PackageReference Include="Microsoft.Build.Utilities.Core" />
|
|
||||||
<PackageReference Include="Microsoft.Build.Framework" />
|
|
||||||
<PackageReference Include="System.Text.Json" GeneratePathProperty="true" />
|
|
||||||
<PackageReference Include="System.Text.Encodings.Web" GeneratePathProperty="true" />
|
|
||||||
<PackageReference Include="System.Memory" GeneratePathProperty="true" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<Target Name="ValidationTask">
|
|
||||||
<Message Text="Restoring Packages..." Importance="high" />
|
|
||||||
<CallTarget Targets="restore" />
|
|
||||||
<CallTarget Targets="ResolveReferences" />
|
|
||||||
|
|
||||||
<Message Text="Running Validations..." Importance="high" />
|
|
||||||
|
|
||||||
<!--Run Validation Targets Here-->
|
|
||||||
<CallTarget Targets="MasterLocalesValidationTask" />
|
|
||||||
|
|
||||||
<Message Text="Validations Succeeded!" Importance="high" />
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
<!--__________________________________________________Start LocalesValidation Task__________________________________________________-->
|
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!--Name of Validation Task. <Name> refers to this name-->
|
<OutputType>Exe</OutputType>
|
||||||
<Name>LocalesValidation</Name>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuildTarget" DependsOnTargets="AfterBuild">
|
||||||
|
<Message Text="Running Validation Project" Importance="high" />
|
||||||
|
|
||||||
<UsingTask TaskName="Ryujinx.BuildValidationTasks.$(Name)Task" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
|
<Exec WorkingDirectory="$(ProjectDir)bin\Debug\$(TargetFramework)\"
|
||||||
<ParameterGroup>
|
Command="Ryujinx.BuildValidationTasks.exe $(ProjectDir)..\..\"
|
||||||
<Path Required="true" />
|
ConsoleToMsBuild="true"
|
||||||
</ParameterGroup>
|
/>
|
||||||
<Task>
|
|
||||||
<Reference Include="$(PkgSystem_Text_Json)/lib/netstandard2.0/System.Text.Json.dll" />
|
|
||||||
<Reference Include="$(PkgSystem_Text_Encodings_Web)/lib/netstandard2.0/System.Text.Encodings.Web.dll" />
|
|
||||||
<Reference Include="$(PkgSystem_Memory)/lib/netstandard2.0/System.Memory.dll" Version="4.6.0" />
|
|
||||||
<Code Language="cs" Source="$(MSBuildThisFileDirectory)$(Name)Task.cs" />
|
|
||||||
</Task>
|
|
||||||
</UsingTask>
|
|
||||||
|
|
||||||
<!--Name should be "Master<Name>Task"-->
|
|
||||||
<Target Name="MasterLocalesValidationTask">
|
|
||||||
<Message Text="Running $(Name)Task... " Importance="high" />
|
|
||||||
<Message Text="Running $(PkgSystem_Text_Json)" Importance="high" />
|
|
||||||
<!--Should call "Ryujinx.BuildValidationTasks.<Name>Task"-->
|
|
||||||
<Ryujinx.BuildValidationTasks.LocalesValidationTask Path="$(MSBuildThisFileDirectory)../Ryujinx/Assets/locales.json" />
|
|
||||||
<Message Text="$(Name)Task finished!" Importance="high" />
|
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
13
src/Ryujinx.BuildValidationTasks/ValidationTask.cs
Normal file
13
src/Ryujinx.BuildValidationTasks/ValidationTask.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Ryujinx.BuildValidationTasks
|
||||||
|
{
|
||||||
|
public interface ValidationTask
|
||||||
|
{
|
||||||
|
public static bool Execute(string projectPath) { return true; }
|
||||||
|
}
|
||||||
|
}
|
33
src/Ryujinx.BuildValidationTasks/program.cs
Normal file
33
src/Ryujinx.BuildValidationTasks/program.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Ryujinx.BuildValidationTasks
|
||||||
|
{
|
||||||
|
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 (string.IsNullOrEmpty(args[0]))
|
||||||
|
throw new ArgumentException("Error: path is null or empty!");
|
||||||
|
|
||||||
|
if (!Path.Exists(args[0]))
|
||||||
|
throw new ArgumentException("Error: path does not exist!");
|
||||||
|
|
||||||
|
Console.WriteLine(args[0]);
|
||||||
|
Console.WriteLine(Path.GetFullPath(args[0]));
|
||||||
|
LocalesValidationTask.Execute(args[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -14,8 +14,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Target Name="BuildValidationProj" BeforeTargets="BeforeBuild">
|
<Target Name="BuildValidationProj" BeforeTargets="BeforeBuild">
|
||||||
<MSBuild Projects="..\Ryujinx.BuildValidationTasks\Ryujinx.BuildValidationTasks.csproj" Targets="ValidationTask" >
|
<Message Text="Building Validation Project for $(TargetFramework)" Importance="high" />
|
||||||
</MSBuild>
|
<MSBuild Projects="..\Ryujinx.BuildValidationTasks\Ryujinx.BuildValidationTasks.csproj" Properties="Configuration=Debug" Targets="PostBuildTarget" />
|
||||||
|
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="$([MSBuild]::IsOSPlatform('OSX'))">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="$([MSBuild]::IsOSPlatform('OSX'))">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user