Ryujinx-GtkSharp/build.cake

256 lines
8.3 KiB
Plaintext
Raw Normal View History

#load CakeScripts\GAssembly.cake
#load CakeScripts\Settings.cake
#load CakeScripts\TargetEnvironment.cake
2022-01-26 18:50:22 +01:00
#addin "Cake.FileHelpers&version=5.0.0"
#addin "Cake.Incubator&version=7.0.0"
2017-10-23 01:25:13 +02:00
// VARS
Settings.Cake = Context;
2021-03-07 12:31:19 +01:00
Settings.Version = Argument("BuildVersion", "3.24.24.1");
Settings.BuildTarget = Argument("BuildTarget", "Default");
Settings.Assembly = Argument("Assembly", "");
2019-05-21 19:21:51 +02:00
var configuration = Argument("Configuration", "Release");
2017-10-23 01:25:13 +02:00
var msbuildsettings = new DotNetMSBuildSettings();
var list = new List<GAssembly>();
var supportedVersionBands = new List<string>() {"6.0.100", "6.0.200", "6.0.300"};
2017-10-23 01:25:13 +02:00
// TASKS
Task("Init")
.Does(() =>
{
if (!string.IsNullOrEmpty(EnvironmentVariable("GITHUB_ACTIONS")))
{
Settings.Version = "3.24.24." + EnvironmentVariable("GITHUB_RUN_NUMBER");
if (EnvironmentVariable("GITHUB_REF") != "refs/heads/master")
Settings.Version += "-develop";
}
Console.WriteLine("Version: " + Settings.Version);
2022-01-26 18:50:22 +01:00
2017-10-29 15:28:44 +01:00
// Assign some common properties
2017-10-30 14:52:48 +01:00
msbuildsettings = msbuildsettings.WithProperty("Version", Settings.Version);
2017-10-29 15:28:44 +01:00
msbuildsettings = msbuildsettings.WithProperty("Authors", "'GtkSharp Contributors'");
msbuildsettings = msbuildsettings.WithProperty("PackageLicenseUrl", "'https://github.com/GtkSharp/GtkSharp/blob/cakecore/LICENSE'");
// Add stuff to list
2017-10-29 15:28:44 +01:00
Settings.Init();
2017-10-29 00:57:52 +02:00
foreach(var gassembly in Settings.AssemblyList)
if(string.IsNullOrEmpty(Settings.Assembly) || Settings.Assembly == gassembly.Name)
list.Add(gassembly);
});
2017-10-23 01:25:13 +02:00
Task("Prepare")
.IsDependentOn("Clean")
2017-10-23 01:25:13 +02:00
.Does(() =>
{
// Build tools
DotNetRestore("Source/Tools/Tools.sln");
DotNetBuild("Source/Tools/Tools.sln", new DotNetBuildSettings {
Verbosity = DotNetVerbosity.Minimal,
2019-05-21 19:21:51 +02:00
Configuration = configuration
2017-10-23 01:25:13 +02:00
});
// Generate code and prepare libs projects
foreach(var gassembly in list)
2017-10-23 01:25:13 +02:00
gassembly.Prepare();
DotNetRestore("Source/GtkSharp.sln");
2018-02-28 18:55:16 +01:00
// Addin
DotNetRestore("Source/Addins/MonoDevelop.GtkSharp.Addin/MonoDevelop.GtkSharp.Addin.sln");
});
2017-10-23 01:25:13 +02:00
Task("Clean")
.IsDependentOn("Init")
2017-10-23 01:25:13 +02:00
.Does(() =>
{
foreach(var gassembly in list)
2017-10-23 01:25:13 +02:00
gassembly.Clean();
});
Task("FullClean")
.IsDependentOn("Clean")
.Does(() =>
{
2021-03-07 12:31:19 +01:00
DeleteDirectory("BuildOutput", new DeleteDirectorySettings {
Recursive = true,
Force = true
});
});
2017-10-23 01:25:13 +02:00
Task("Build")
.IsDependentOn("Prepare")
.Does(() =>
{
var settings = new DotNetBuildSettings
2017-10-23 01:25:13 +02:00
{
2019-05-21 19:21:51 +02:00
Configuration = configuration,
MSBuildSettings = msbuildsettings
};
2017-10-29 00:57:52 +02:00
if (list.Count == Settings.AssemblyList.Count)
DotNetBuild("Source/GtkSharp.sln", settings);
else
{
foreach(var gassembly in list)
DotNetBuild(gassembly.Csproj, settings);
}
});
2018-01-17 23:35:07 +01:00
Task("RunSamples")
.IsDependentOn("Build")
.Does(() =>
{
var settings = new DotNetBuildSettings
2018-01-17 23:35:07 +01:00
{
2019-05-21 19:21:51 +02:00
Configuration = configuration,
2018-01-17 23:35:07 +01:00
MSBuildSettings = msbuildsettings
};
DotNetBuild("Source/Samples/Samples.csproj", settings);
DotNetRun("Source/Samples/Samples.csproj");
2018-01-17 23:35:07 +01:00
});
Task("PackageNuGet")
.IsDependentOn("Build")
.Does(() =>
{
var settings = new DotNetPackSettings
{
MSBuildSettings = msbuildsettings,
2019-05-21 19:21:51 +02:00
Configuration = configuration,
OutputDirectory = "BuildOutput/NugetPackages",
NoBuild = true
};
foreach(var gassembly in list)
DotNetPack(gassembly.Csproj, settings);
2017-10-23 01:25:13 +02:00
});
Task("PackageWorkload")
.IsDependentOn("Build")
.Does(() =>
{
var packSettings = new DotNetPackSettings
{
MSBuildSettings = msbuildsettings,
Configuration = configuration,
OutputDirectory = "BuildOutput/NugetPackages",
// Some of the nugets here depend on output generated during build.
NoBuild = false
};
DotNetPack("Source/Workload/GtkSharp.Workload.Template.CSharp/GtkSharp.Workload.Template.CSharp.csproj", packSettings);
DotNetPack("Source/Workload/GtkSharp.Workload.Template.FSharp/GtkSharp.Workload.Template.FSharp.csproj", packSettings);
DotNetPack("Source/Workload/GtkSharp.Workload.Template.VBNet/GtkSharp.Workload.Template.VBNet.csproj", packSettings);
DotNetPack("Source/Workload/GtkSharp.Ref/GtkSharp.Ref.csproj", packSettings);
DotNetPack("Source/Workload/GtkSharp.Runtime/GtkSharp.Runtime.csproj", packSettings);
DotNetPack("Source/Workload/GtkSharp.Sdk/GtkSharp.Sdk.csproj", packSettings);
foreach (var band in supportedVersionBands)
{
packSettings.MSBuildSettings = packSettings.MSBuildSettings.WithProperty("_GtkSharpManifestVersionBand", band);
DotNetPack("Source/Workload/GtkSharp.NET.Sdk.Gtk/GtkSharp.NET.Sdk.Gtk.csproj", packSettings);
}
});
2017-10-29 01:35:22 +02:00
Task("PackageTemplates")
.IsDependentOn("Init")
.Does(() =>
{
var settings = new DotNetPackSettings
2017-10-29 01:35:22 +02:00
{
MSBuildSettings = msbuildsettings,
Configuration = configuration,
OutputDirectory = "BuildOutput/NugetPackages"
2017-10-29 01:35:22 +02:00
};
DotNetPack("Source/Templates/GtkSharp.Template.CSharp/GtkSharp.Template.CSharp.csproj", settings);
DotNetPack("Source/Templates/GtkSharp.Template.FSharp/GtkSharp.Template.FSharp.csproj", settings);
DotNetPack("Source/Templates/GtkSharp.Template.VBNet/GtkSharp.Template.VBNet.csproj", settings);
2017-10-29 01:35:22 +02:00
});
const string manifestName = "GtkSharp.NET.Sdk.Gtk";
var manifestPack = $"{manifestName}.Manifest-{TargetEnvironment.DotNetCliFeatureBand}.{Settings.Version}.nupkg";
var manifestPackPath = $"BuildOutput/NugetPackages/{manifestPack}";
var packNames = new List<string>()
{
"GtkSharp.Ref",
"GtkSharp.Runtime",
"GtkSharp.Sdk"
};
var templateLanguages = new List<string>()
{
"CSharp",
"FSharp",
"VBNet"
};
Task("InstallWorkload")
.IsDependentOn("PackageWorkload")
.IsDependentOn("PackageTemplates")
.Does(() =>
{
Console.WriteLine($"Installing workload for SDK version {TargetEnvironment.DotNetCliFeatureBand}, at {TargetEnvironment.DotNetInstallPath}");
Console.WriteLine($"Installing manifests to {TargetEnvironment.DotNetManifestPath}");
TargetEnvironment.InstallManifests(manifestName, manifestPackPath);
Console.WriteLine($"Installing packs to {TargetEnvironment.DotNetPacksPath}");
foreach (var name in packNames)
{
Console.WriteLine($"Installing {name}");
var pack = $"{name}.{Settings.Version}.nupkg";
var packPath = $"BuildOutput/NugetPackages/{pack}";
TargetEnvironment.InstallPack(name, Settings.Version, packPath);
}
Console.WriteLine($"Installing templates to {TargetEnvironment.DotNetTemplatePacksPath}");
foreach (var language in templateLanguages)
{
Console.WriteLine($"Installing {language} templates");
var pack = $"GtkSharp.Workload.Template.{language}.{Settings.Version}.nupkg";
var packPath = $"BuildOutput/NugetPackages/{pack}";
TargetEnvironment.InstallTemplatePack(pack, packPath);
}
Console.WriteLine($"Registering \"gtk\" installed workload...");
TargetEnvironment.RegisterInstalledWorkload("gtk");
});
Task("UninstallWorkload")
.Does(() =>
{
Console.WriteLine($"Uninstalling workload for SDK version {TargetEnvironment.DotNetCliFeatureBand}, at {TargetEnvironment.DotNetInstallPath}");
Console.WriteLine($"Removing manifests from {TargetEnvironment.DotNetManifestPath}");
TargetEnvironment.UninstallManifests(manifestName);
Console.WriteLine($"Removing packs from {TargetEnvironment.DotNetPacksPath}");
foreach (var name in packNames)
{
Console.WriteLine($"Removing {name}");
TargetEnvironment.UninstallPack(name, Settings.Version);
}
Console.WriteLine($"Removing templates from {TargetEnvironment.DotNetTemplatePacksPath}");
foreach (var language in templateLanguages)
{
Console.WriteLine($"Removing {language} templates");
var pack = $"GtkSharp.Workload.Template.{language}.{Settings.Version}.nupkg";
TargetEnvironment.UninstallTemplatePack(pack);
}
Console.WriteLine($"Unregistering \"gtk\" installed workload...");
TargetEnvironment.UnregisterInstalledWorkload("gtk");
});
2017-10-23 01:25:13 +02:00
// TASK TARGETS
Task("Default")
2022-01-26 18:50:22 +01:00
.IsDependentOn("Build")
2017-11-12 02:32:36 +01:00
.IsDependentOn("PackageNuGet")
.IsDependentOn("PackageWorkload")
2021-03-07 12:31:19 +01:00
.IsDependentOn("PackageTemplates");
2017-10-23 01:25:13 +02:00
// EXECUTION
RunTarget(Settings.BuildTarget);