no more submodule
This commit is contained in:
80
GtkSharp/CakeScripts/GAssembly.cake
Normal file
80
GtkSharp/CakeScripts/GAssembly.cake
Normal file
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using P = System.IO.Path;
|
||||
using F = System.IO.File;
|
||||
|
||||
public class GAssembly
|
||||
{
|
||||
private ICakeContext Cake;
|
||||
|
||||
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; }
|
||||
public string ExtraArgs { get; set; }
|
||||
|
||||
public GAssembly(string name)
|
||||
{
|
||||
Cake = Settings.Cake;
|
||||
Deps = new string[0];
|
||||
|
||||
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.xml";
|
||||
Metadata = temppath + ".metadata";
|
||||
}
|
||||
|
||||
public void Prepare()
|
||||
{
|
||||
Cake.CreateDirectory(GDir);
|
||||
var tempapi = P.Combine(GDir, Name + "-api.xml");
|
||||
Cake.CopyFile(RawApi, tempapi);
|
||||
|
||||
// Metadata file found, time to generate some stuff!!!
|
||||
if (Cake.FileExists(Metadata))
|
||||
{
|
||||
// Fixup API file
|
||||
var symfile = P.Combine(Dir, Name + "-symbols.xml");
|
||||
Cake.DotNetExecute("BuildOutput/Tools/GapiFixup.dll",
|
||||
"--metadata=" + Metadata + " " + "--api=" + tempapi +
|
||||
(Cake.FileExists(symfile) ? " --symbols=" + symfile : string.Empty)
|
||||
);
|
||||
|
||||
var extraargs = ExtraArgs + " ";
|
||||
|
||||
// Locate APIs to include
|
||||
foreach(var dep in Deps)
|
||||
{
|
||||
var ipath = P.Combine("Source", "Libs", dep, "Generated", dep + "-api.xml");
|
||||
|
||||
if (Cake.FileExists(ipath))
|
||||
extraargs += " --include=" + ipath + " ";
|
||||
}
|
||||
|
||||
// Generate code
|
||||
Cake.DotNetExecute("BuildOutput/Tools/GapiCodegen.dll",
|
||||
"--outdir=" + GDir + " " +
|
||||
"--schema=Source/Libs/Shared/Gapi.xsd " +
|
||||
extraargs + " " +
|
||||
"--assembly-name=" + Name + " " +
|
||||
"--generate=" + tempapi
|
||||
);
|
||||
}
|
||||
|
||||
Init = true;
|
||||
}
|
||||
|
||||
public void Clean()
|
||||
{
|
||||
if (Cake.DirectoryExists(GDir))
|
||||
Cake.DeleteDirectory(GDir, new DeleteDirectorySettings { Recursive = true, Force = true });
|
||||
}
|
||||
}
|
||||
49
GtkSharp/CakeScripts/Settings.cake
Normal file
49
GtkSharp/CakeScripts/Settings.cake
Normal file
@@ -0,0 +1,49 @@
|
||||
|
||||
class Settings
|
||||
{
|
||||
public static ICakeContext Cake { get; set; }
|
||||
public static string Version { get; set; }
|
||||
public static string BuildTarget { get; set; }
|
||||
public static string Assembly { get; set; }
|
||||
public static List<GAssembly> AssemblyList { get; set; }
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
AssemblyList = new List<GAssembly>()
|
||||
{
|
||||
new GAssembly("GLibSharp"),
|
||||
new GAssembly("GioSharp")
|
||||
{
|
||||
Deps = new[] { "GLibSharp" },
|
||||
},
|
||||
new GAssembly("AtkSharp")
|
||||
{
|
||||
Deps = new[] { "GLibSharp" },
|
||||
ExtraArgs = "--abi-cs-usings=Atk,GLib"
|
||||
},
|
||||
new GAssembly("CairoSharp"),
|
||||
new GAssembly("PangoSharp")
|
||||
{
|
||||
Deps = new[] { "GLibSharp", "CairoSharp" }
|
||||
},
|
||||
new GAssembly("GdkSharp")
|
||||
{
|
||||
Deps = new[] { "GLibSharp", "GioSharp", "CairoSharp", "PangoSharp" }
|
||||
},
|
||||
new GAssembly("GtkSharp")
|
||||
{
|
||||
Deps = new[] { "GLibSharp", "GioSharp", "AtkSharp", "CairoSharp", "PangoSharp", "GdkSharp" },
|
||||
ExtraArgs = "--abi-cs-usings=Gtk,GLib"
|
||||
},
|
||||
new GAssembly("GtkSourceSharp")
|
||||
{
|
||||
Deps = new[] { "GLibSharp", "GtkSharp", "GioSharp", "CairoSharp", "PangoSharp", "GdkSharp" },
|
||||
},
|
||||
new GAssembly("WebkitGtkSharp")
|
||||
{
|
||||
Deps = new[] { "GtkSharp","GLibSharp", "GioSharp", "AtkSharp", "CairoSharp", "PangoSharp", "GdkSharp" },
|
||||
ExtraArgs = "--abi-cs-usings=Webkit,Gtk,GLib,Gdk,Atk,Pango,Cairo"
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
211
GtkSharp/CakeScripts/TargetEnvironment.cake
Normal file
211
GtkSharp/CakeScripts/TargetEnvironment.cake
Normal file
@@ -0,0 +1,211 @@
|
||||
#addin "nuget:?package=Microsoft.Win32.Registry&version=5.0.0"
|
||||
using System;
|
||||
using D = System.IO.Directory;
|
||||
using F = System.IO.File;
|
||||
using P = System.IO.Path;
|
||||
using Pr = System.Diagnostics.Process;
|
||||
using PSI = System.Diagnostics.ProcessStartInfo;
|
||||
using R = Microsoft.Win32.Registry;
|
||||
using RI = System.Runtime.InteropServices.RuntimeInformation;
|
||||
using Z = System.IO.Compression.ZipFile;
|
||||
|
||||
class TargetEnvironment
|
||||
{
|
||||
public static string DotNetInstallPath { get; private set; }
|
||||
public static string DotNetInstalledWorkloadsMetadataPath { get; private set; }
|
||||
public static string DotNetInstallerTypeMetadataPath { get; private set; }
|
||||
public static string DotNetManifestPath { get; private set; }
|
||||
public static string DotNetPacksPath { get; private set; }
|
||||
public static string DotNetTemplatePacksPath { get; private set; }
|
||||
|
||||
public static string DotNetCliPath { get; private set; }
|
||||
public static string DotNetCliFeatureBand { get; private set; }
|
||||
|
||||
static TargetEnvironment()
|
||||
{
|
||||
DotNetInstallPath = Environment.GetEnvironmentVariable("DOTNET_ROOT");
|
||||
if (DotNetInstallPath == null)
|
||||
{
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
DotNetInstallPath = P.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "dotnet");
|
||||
}
|
||||
else if (OperatingSystem.IsLinux())
|
||||
{
|
||||
DotNetInstallPath = "/usr/share/dotnet";
|
||||
}
|
||||
else if (OperatingSystem.IsMacOS())
|
||||
{
|
||||
DotNetInstallPath = "/usr/local/share/dotnet";
|
||||
}
|
||||
}
|
||||
|
||||
DotNetCliPath = P.Combine(DotNetInstallPath, "dotnet");
|
||||
|
||||
var proc = Pr.Start(new PSI()
|
||||
{
|
||||
FileName = DotNetCliPath,
|
||||
Arguments = "--version",
|
||||
RedirectStandardOutput = true,
|
||||
});
|
||||
|
||||
proc.WaitForExit();
|
||||
|
||||
DotNetCliFeatureBand = proc.StandardOutput.ReadToEnd().Trim();
|
||||
DotNetCliFeatureBand = DotNetCliFeatureBand.Substring(0, DotNetCliFeatureBand.Length - 2) + "00";
|
||||
|
||||
DotNetInstalledWorkloadsMetadataPath = P.Combine(DotNetInstallPath, "metadata", "workloads", DotNetCliFeatureBand, "InstalledWorkloads");
|
||||
DotNetInstallerTypeMetadataPath = P.Combine(DotNetInstallPath, "metadata", "workloads", DotNetCliFeatureBand, "InstallerType");
|
||||
DotNetManifestPath = P.Combine(DotNetInstallPath, "sdk-manifests", DotNetCliFeatureBand);
|
||||
DotNetPacksPath = P.Combine(DotNetInstallPath, "packs");
|
||||
DotNetTemplatePacksPath = P.Combine(DotNetInstallPath, "template-packs");
|
||||
}
|
||||
|
||||
public static void RegisterInstalledWorkload(string workloadName)
|
||||
{
|
||||
D.CreateDirectory(DotNetInstalledWorkloadsMetadataPath);
|
||||
F.WriteAllText(P.Combine(DotNetInstalledWorkloadsMetadataPath, workloadName), string.Empty);
|
||||
if (F.Exists(P.Combine(DotNetInstallerTypeMetadataPath, "msi")))
|
||||
{
|
||||
//HKLM:\SOFTWARE\Microsoft\dotnet\InstalledWorkloads\Standalone\x64\6.0.300\gtk
|
||||
|
||||
// TODO: Check for other Windows architectures (x86 and arm64)
|
||||
var archString = RI.OSArchitecture.ToString().ToLower();
|
||||
|
||||
var hklm = R.LocalMachine;
|
||||
var software = hklm.CreateSubKey("SOFTWARE");
|
||||
var microsoft = software.CreateSubKey("Microsoft");
|
||||
var dotnet = microsoft.CreateSubKey("dotnet");
|
||||
var installedWorkloads = dotnet.CreateSubKey("InstalledWorkloads");
|
||||
var standalone = installedWorkloads.CreateSubKey("Standalone");
|
||||
var arch = standalone.CreateSubKey(archString);
|
||||
var version = arch.CreateSubKey(DotNetCliFeatureBand);
|
||||
var workload = version.CreateSubKey(workloadName);
|
||||
|
||||
workload.Close();
|
||||
version.Close();
|
||||
arch.Close();
|
||||
standalone.Close();
|
||||
installedWorkloads.Close();
|
||||
dotnet.Close();
|
||||
microsoft.Close();
|
||||
software.Close();
|
||||
hklm.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnregisterInstalledWorkload(string workloadName)
|
||||
{
|
||||
F.Delete(P.Combine(DotNetInstalledWorkloadsMetadataPath, workloadName));
|
||||
if (F.Exists(P.Combine(DotNetInstallerTypeMetadataPath, "msi")))
|
||||
{
|
||||
var archString = RI.OSArchitecture.ToString().ToLower();
|
||||
|
||||
var hklm = R.LocalMachine;
|
||||
var software = hklm.CreateSubKey("SOFTWARE");
|
||||
var microsoft = software.CreateSubKey("Microsoft");
|
||||
var dotnet = microsoft.CreateSubKey("dotnet");
|
||||
var installedWorkloads = dotnet.CreateSubKey("InstalledWorkloads");
|
||||
var standalone = installedWorkloads.CreateSubKey("Standalone");
|
||||
var arch = standalone.CreateSubKey(archString);
|
||||
var version = arch.CreateSubKey(DotNetCliFeatureBand);
|
||||
|
||||
version.DeleteSubKey(workloadName, false);
|
||||
|
||||
version.Close();
|
||||
arch.Close();
|
||||
standalone.Close();
|
||||
installedWorkloads.Close();
|
||||
dotnet.Close();
|
||||
microsoft.Close();
|
||||
software.Close();
|
||||
hklm.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public static void InstallManifests(string manifestName, string manifestPackPath)
|
||||
{
|
||||
var targetDirectory = P.Combine(DotNetManifestPath, manifestName);
|
||||
var tempDirectory = P.Combine(targetDirectory, "temp");
|
||||
|
||||
// Delete existing installations to avoid conflict.
|
||||
if (D.Exists(targetDirectory))
|
||||
{
|
||||
D.Delete(targetDirectory, true);
|
||||
}
|
||||
|
||||
// Also creates the target
|
||||
D.CreateDirectory(tempDirectory);
|
||||
|
||||
Z.ExtractToDirectory(manifestPackPath, tempDirectory);
|
||||
var tempDataDirectory = P.Combine(tempDirectory, "data");
|
||||
|
||||
foreach (var filePath in D.GetFiles(tempDataDirectory))
|
||||
{
|
||||
var targetFilePath = P.Combine(targetDirectory, P.GetFileName(filePath));
|
||||
F.Copy(filePath, targetFilePath, true);
|
||||
}
|
||||
|
||||
D.Delete(tempDirectory, true);
|
||||
}
|
||||
|
||||
public static void UninstallManifests(string manifestName)
|
||||
{
|
||||
var targetDirectory = P.Combine(DotNetManifestPath, manifestName);
|
||||
if (D.Exists(targetDirectory))
|
||||
{
|
||||
D.Delete(targetDirectory, true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void InstallPack(string name, string version, string packPath)
|
||||
{
|
||||
var targetDirectory = P.Combine(DotNetPacksPath, name, version);
|
||||
|
||||
if (D.Exists(targetDirectory))
|
||||
{
|
||||
D.Delete(targetDirectory, true);
|
||||
}
|
||||
|
||||
D.CreateDirectory(targetDirectory);
|
||||
|
||||
Z.ExtractToDirectory(packPath, targetDirectory);
|
||||
}
|
||||
|
||||
public static void UninstallPack(string name, string version)
|
||||
{
|
||||
var packInstallDirectory = P.Combine(DotNetPacksPath, name);
|
||||
|
||||
var targetDirectory = P.Combine(packInstallDirectory, version);
|
||||
if (D.Exists(targetDirectory))
|
||||
{
|
||||
D.Delete(targetDirectory, true);
|
||||
}
|
||||
|
||||
// Clean up the template if no other verions exist.
|
||||
try
|
||||
{
|
||||
D.Delete(packInstallDirectory, false);
|
||||
}
|
||||
catch (System.IO.IOException)
|
||||
{
|
||||
// Silently fail. Mostly because the directory is not empty (there are other verions installed).
|
||||
}
|
||||
}
|
||||
|
||||
public static void InstallTemplatePack(string packName, string packPath)
|
||||
{
|
||||
D.CreateDirectory(DotNetTemplatePacksPath);
|
||||
var targetPath = P.Combine(DotNetTemplatePacksPath, packName);
|
||||
F.Copy(packPath, targetPath, true);
|
||||
}
|
||||
|
||||
public static void UninstallTemplatePack(string packName)
|
||||
{
|
||||
var targetPath = P.Combine(DotNetTemplatePacksPath, packName);
|
||||
if (F.Exists(targetPath))
|
||||
{
|
||||
F.Delete(targetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user