Improve the API diff logic a bit more

This commit is contained in:
Matthew Leibowitz 2018-07-17 01:27:43 +02:00
Родитель 26a423d783
Коммит 23fc8accbc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 3650EBE4AA155AF9
1 изменённых файлов: 46 добавлений и 13 удалений

Просмотреть файл

@ -1,9 +1,7 @@
#addin nuget:?package=Cake.Xamarin&version=2.0.1
#addin nuget:?package=Cake.XCode&version=3.0.0
#addin nuget:?package=Cake.FileHelpers&version=2.0.0
#addin nuget:?package=Cake.MonoApiTools&version=2.0.0
#tool nuget:?package=Cake.MonoApiTools&version=2.0.0
#addin nuget:https://ci.appveyor.com/nuget/cake-monoapitools-gunq9ba46ljl?package=Cake.MonoApiTools&version=2.0.0-preview2
#reference "tools/SharpCompress/lib/net45/SharpCompress.dll"
#reference "tools/Newtonsoft.Json/lib/net45/Newtonsoft.Json.dll"
@ -380,10 +378,18 @@ Task ("nuget")
Task ("api-diff")
.Does (() =>
{
var ids = new List<string> {
"skiasharp",
// "skiasharp.views",
// "skiasharp.views.forms",
// "harfbuzzsharp",
// "skiasharp.harfbuzz",
};
try {
var nuget = "SkiaSharp";
var pathToAssembly = "lib/netstandard1.3/SkiaSharp.dll";
foreach (var nuget in ids) {
Information ($"Comparing the assemblies in '{nuget}'...");
// find the latest version for this id
var version = "0.0";
@ -396,7 +402,7 @@ Task ("api-diff")
}
// download nugets
var tempPath = $"./externals/api-diff/{nuget}";
var tempPath = $"./externals/api-diff/{nuget}.{version}";
var oldDest = $"{tempPath}/{nuget}.{version}.nupkg";
if (!FileExists (oldDest)) {
CleanDirectories (tempPath);
@ -407,16 +413,43 @@ Task ("api-diff")
Unzip (oldDest, tempPath);
}
// run the diff
// find the dlls
var oldDlls = GetFiles ($"{tempPath}/lib/*/*.dll");
var newDlls = GetFiles ($"./output/{nuget}/nuget/lib/*/*.dll");
var oldPlatforms = oldDlls.Select (p => $"{p.GetDirectory ().GetDirectoryName ()}/{p.GetFilename ()}".ToLower ()).ToArray ();
var newPlatforms = newDlls.Select (p => $"{p.GetDirectory ().GetDirectoryName ()}/{p.GetFilename ()}".ToLower ()).ToArray ();
var missing = oldPlatforms.Except (newPlatforms);
foreach (var miss in missing) {
Warning ($"The '{miss}' dll is missing from the new '{nuget}' package.");
}
var added = newPlatforms.Except (oldPlatforms);
foreach (var add in added) {
Warning ($"The '{add}' dll was added to the new '{nuget}' package.");
}
var intersection = newPlatforms.Intersect (oldPlatforms);
// run the diff on each dll
var outPath = $"./output/{nuget}/api-diff";
var oldApi = $"{outPath}/{nuget}.api-info.old.xml";
var newApi = $"{outPath}/{nuget}.api-info.new.xml";
EnsureDirectoryExists (outPath);
CleanDirectories (outPath);
MonoApiInfo ($"{tempPath}/{pathToAssembly}", oldApi);
MonoApiInfo ($"./output/{nuget}/nuget/{pathToAssembly}", newApi);
MonoApiDiff (oldApi, newApi, $"{outPath}/{nuget}.api-info.diff.xml");
MonoApiHtml (oldApi, newApi, $"{outPath}/{nuget}.api-info.diff.html");
foreach (var match in intersection) {
Information ($"Comparing the '{match}' assembly...");
var assembly = (FilePath)$"{outPath}/{match}";
EnsureDirectoryExists (assembly.GetDirectory ());
var oldApi = $"{outPath}/{match}.api-info.old.xml";
var newApi = $"{outPath}/{match}.api-info.new.xml";
var pathToAssembly = $"lib/{match}";
MonoApiInfo ($"{tempPath}/{pathToAssembly}", oldApi);
MonoApiInfo ($"./output/{nuget}/nuget/{pathToAssembly}", newApi);
MonoApiDiff (oldApi, newApi, $"{outPath}/{match}.api-info.diff.xml");
MonoApiHtmlColorized (oldApi, newApi, $"{outPath}/{match}.api-info.diff.html");
MonoApiMarkdownColorized (oldApi, newApi, $"{outPath}/{match}.api-info.diff.md");
}
}
} catch (AggregateException ex) {
Error ("{0}", ex.InnerException);