Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit ad2b73c

Browse files
authored
Use the assemblies instaed of api-info (#160)
* Updated the logic to use the assembly and not the api-info * Now using the merged dll from CI
1 parent 35c1e15 commit ad2b73c

File tree

4 files changed

+172
-101
lines changed

4 files changed

+172
-101
lines changed

build.cake

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ var REF_DOCS_URL = "https://bosstoragemirror.blob.core.windows.net/android-docs-
3636
// We grab the previous release's api-info.xml to use as a comparison for this build's generated info to make an api-diff
3737
var BASE_API_INFO_URL = EnvironmentVariable("MONO_API_INFO_XML_URL") ?? "https://github.com/xamarin/AndroidSupportComponents/releases/download/28.0.0.1/api-info.xml";
3838

39+
// In order to create the type mapping, we need to get the AndroidSupport.Merged.dll
40+
var SUPPORT_MERGED_DLL_BUILD_ID = EnvironmentVariable("SUPPORT_MERGED_DLL_BUILD_ID") ?? "652";
41+
var SUPPORT_MERGED_DLL_ZIP_URL = EnvironmentVariable("SUPPORT_MERGED_DLL_ZIP_URL") ?? $"https://dev.azure.com/xamarin/6fd3d886-57a5-4e31-8db7-52a1b47c07a8/_apis/build/builds/{SUPPORT_MERGED_DLL_BUILD_ID}/artifacts?artifactName=nuget&%24format=zip&api-version=5.0";
42+
3943
var MONODROID_BASE_PATH = (DirectoryPath)"/Library/Frameworks/Xamarin.Android.framework/Versions/Current/lib/xbuild-frameworks/MonoAndroid/";
4044
if (IsRunningOnWindows ()) {
4145
var vsInstallPath = VSWhereLatest (new VSWhereLatestSettings { Requires = "Component.Xamarin" });
@@ -239,16 +243,22 @@ Task ("diff")
239243
Task ("generate-mapping")
240244
.IsDependentOn ("androidxmapper")
241245
.IsDependentOn ("merge")
242-
.IsDependentOn ("diff")
243246
.Does (() =>
244247
{
245-
EnsureDirectoryExists("./output/");
246-
DownloadFile (BASE_API_INFO_URL, "./output/api-info.previous.xml");
248+
// download the AndroidSupport.Merged.dll from a past build
249+
if (!FileExists ("./output/AndroidSupport.Merged.dll")) {
250+
EnsureDirectoryExists ("./output/temp/");
251+
CleanDirectories ("./output/temp");
252+
DownloadFile (SUPPORT_MERGED_DLL_ZIP_URL, "./output/temp/AndroidSupport.NuGet.zip");
253+
Unzip ("./output/temp/AndroidSupport.NuGet.zip", "./output/temp/");
254+
CopyFileToDirectory ("./output/temp/nuget/AndroidSupport.Merged.dll", "./output/");
255+
DeleteDirectory ("./output/temp", true);
256+
}
247257

248258
var result = StartProcess(ANDROIDX_MAPPER_EXE,
249259
$"generate -v " +
250-
$" -s " + MakeAbsolute((FilePath)"./output/api-info.previous.xml") +
251-
$" -x " + MakeAbsolute((FilePath)"./output/api-info.xml") +
260+
$" -s " + MakeAbsolute((FilePath)"./output/AndroidSupport.Merged.dll") +
261+
$" -x " + MakeAbsolute((FilePath)"./output/AndroidX.Merged.dll") +
252262
$" -j " + MakeAbsolute((FilePath)"./util/AndroidXMapper/Resources/androidx-class-mapping.csv") +
253263
$" -m " + MakeAbsolute((FilePath)"./util/AndroidXMapper/Resources/override-mapping.csv") +
254264
$" -o " + MakeAbsolute((FilePath)"./output/androidx-mapping.csv"));

util/AndroidXMapper/AndroidXMapper/GenerateCommand.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public GenerateCommand()
1616
"",
1717
Help,
1818
"",
19-
{ "s|support=", "The path to the merged Android.Support api-info.xml", v => AndroidSupportApi = v },
20-
{ "x|androidx=", "The path to the merged AndroidX api-info.xml", v => AndroidXApi = v },
19+
{ "s|support=", "The path to the merged Android.Support assembly", v => AndroidSupportAssembly = v },
20+
{ "x|androidx=", "The path to the merged AndroidX assembly", v => AndroidXAssembly = v },
2121
{ "j|java=", "The path to the Java mapping csv", v => JavaTypeMapping = v },
2222
{ "m|override=", "The path to the mapping overides csv", v => OverrideMapping = v },
2323
{ "o|output=", "The output path to use for the generated mapping", v => SetOutputPath(v) },
@@ -45,9 +45,9 @@ private void SetOutputPath(string path)
4545

4646
public bool ExcludeWarnings { get; private set; }
4747

48-
public string AndroidSupportApi { get; private set; }
48+
public string AndroidSupportAssembly { get; private set; }
4949

50-
public string AndroidXApi { get; private set; }
50+
public string AndroidXAssembly { get; private set; }
5151

5252
public string JavaTypeMapping { get; private set; }
5353

@@ -76,7 +76,7 @@ public override int Invoke(IEnumerable<string> args)
7676
? Console.Out
7777
: (writer = new StreamWriter(OutputPath));
7878

79-
var generator = new MappingGenerator(AndroidSupportApi, AndroidXApi, OverrideMapping, JavaTypeMapping);
79+
var generator = new MappingGenerator(AndroidSupportAssembly, AndroidXAssembly, OverrideMapping, JavaTypeMapping);
8080
generator.Generate(outputWriter, !ExcludeWarnings);
8181

8282
return 0;
@@ -98,25 +98,25 @@ private bool ValidateArguments()
9898
{
9999
var hasError = false;
100100

101-
if (string.IsNullOrEmpty(AndroidSupportApi))
101+
if (string.IsNullOrEmpty(AndroidSupportAssembly))
102102
{
103103
Console.Error.WriteLine($"{Program.Name}: Missing required argument `--support=PATH`.");
104104
hasError = true;
105105
}
106-
else if (!File.Exists(AndroidSupportApi))
106+
else if (!File.Exists(AndroidSupportAssembly))
107107
{
108-
Console.Error.WriteLine($"{Program.Name}: File does not exist: `{AndroidSupportApi}`.");
108+
Console.Error.WriteLine($"{Program.Name}: File does not exist: `{AndroidSupportAssembly}`.");
109109
hasError = true;
110110
}
111111

112-
if (string.IsNullOrEmpty(AndroidXApi))
112+
if (string.IsNullOrEmpty(AndroidXAssembly))
113113
{
114114
Console.Error.WriteLine($"{Program.Name}: Missing required argument `--androidx=PATH`.");
115115
hasError = true;
116116
}
117-
else if (!File.Exists(AndroidXApi))
117+
else if (!File.Exists(AndroidXAssembly))
118118
{
119-
Console.Error.WriteLine($"{Program.Name}: File does not exist: `{AndroidXApi}`.");
119+
Console.Error.WriteLine($"{Program.Name}: File does not exist: `{AndroidXAssembly}`.");
120120
hasError = true;
121121
}
122122

0 commit comments

Comments
 (0)