Ryujinx-GtkSharp/CakeScripts/GAssembly.cs

80 lines
2.3 KiB
C#
Raw Normal View History

2017-10-23 01:25:13 +02:00
using System;
using P = System.IO.Path;
public class GAssembly
{
private ICakeContext Cake;
2017-10-23 01:25:13 +02:00
public bool Init { get; private set; }
public string Name { get; private set; }
public string Dir { get; private set; }
public string GDir { get; private set; }
public string Csproj { get; private set; }
public string RawApi { get; private set; }
public string Metadata { get; private set; }
public string[] Deps { get; set; }
2017-10-23 01:25:13 +02:00
public string ExtraArgs { get; set; }
public GAssembly(string name)
{
Cake = Settings.Cake;
Deps = new string[0];
2017-10-23 01:25:13 +02:00
Name = name;
Dir = P.Combine("Source", "Libs", name);
GDir = P.Combine(Dir, "Generated");
var temppath = P.Combine(Dir, name);
Csproj = temppath + ".csproj";
RawApi = temppath + "-api.raw";
Metadata = temppath + ".metadata";
}
public void Prepare()
{
Cake.CreateDirectory(GDir);
2017-10-23 01:25:13 +02:00
// Raw API file found, time to generate some stuff!!!
if (Cake.FileExists(RawApi))
{
// Fixup API file
var tempapi = P.Combine(GDir, Name + "-api.xml");
var symfile = P.Combine(Dir, Name + "-symbols.xml");
Cake.CopyFile(RawApi, tempapi);
GapiFixup.Run(tempapi, Metadata, Cake.FileExists(symfile) ? symfile : string.Empty);
var extraargs = ExtraArgs + " ";
2017-10-23 01:25:13 +02:00
// Locate APIs to include
foreach(var dep in Deps)
2017-10-23 01:25:13 +02:00
{
var ipath = P.Combine("Source", "Libs", dep, dep + "-api.xml");
if (!Cake.FileExists(ipath))
ipath = P.Combine("Source", "Libs", dep, "Generated", dep + "-api.xml");
if (Cake.FileExists(ipath))
extraargs += " --include=" + ipath + " ";
2017-10-23 01:25:13 +02:00
}
// Generate code
Cake.DotNetCoreExecute("BuildOutput/Generator/GapiCodegen.dll",
2017-10-23 01:25:13 +02:00
"--outdir=" + GDir + " " +
"--schema=Source/Libs/Gapi.xsd " +
extraargs + " " +
2017-10-23 01:25:13 +02:00
"--assembly-name=" + Name + " " +
"--generate=" + tempapi
);
}
Init = true;
}
public void Clean()
{
if (Cake.DirectoryExists(GDir))
Cake.DeleteDirectory(GDir, new DeleteDirectorySettings { Recursive = true, Force = true });
2017-10-23 01:25:13 +02:00
}
}