Skip to content

Commit 68bd71a

Browse files
committed
Assembly stores are the only way to embed assemblies in the apk now
1 parent 417f8ba commit 68bd71a

File tree

9 files changed

+42
-152
lines changed

9 files changed

+42
-152
lines changed

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AotTests.cs

+6-12
Original file line numberDiff line numberDiff line change
@@ -137,34 +137,30 @@ public void BuildAotApplicationWithSpecialCharactersInProject (string testName,
137137
new object[] {
138138
/* supportedAbis */ "arm64-v8a",
139139
/* enableLLVM */ false,
140-
/* usesAssemblyBlobs */ false,
141140
},
142141
new object[] {
143142
/* supportedAbis */ "armeabi-v7a;x86",
144143
/* enableLLVM */ true,
145-
/* usesAssemblyBlobs */ true,
146144
},
147145
new object[] {
148146
/* supportedAbis */ "armeabi-v7a;arm64-v8a;x86;x86_64",
149147
/* enableLLVM */ false,
150-
/* usesAssemblyBlobs */ true,
151148
},
152149
new object[] {
153150
/* supportedAbis */ "armeabi-v7a;arm64-v8a;x86;x86_64",
154151
/* enableLLVM */ true,
155-
/* usesAssemblyBlobs */ false,
156152
},
157153
};
158154

159155
[Test]
160156
[TestCaseSource (nameof (AotChecks))]
161-
public void BuildAotApplicationWithNdkAndBundleAndÜmläüts (string supportedAbis, bool enableLLVM, bool usesAssemblyBlobs)
157+
public void BuildAotApplicationWithNdkAndBundleAndÜmläüts (string supportedAbis, bool enableLLVM)
162158
{
163159
if (IsWindows)
164160
Assert.Ignore ("https://github.com/dotnet/runtime/issues/88625");
165161

166162
var abisSanitized = supportedAbis.Replace (";", "").Replace ("-", "").Replace ("_", "");
167-
var path = Path.Combine ("temp", string.Format ("BuildAotNdk AndÜmläüts_{0}_{1}_{2}", abisSanitized, enableLLVM, usesAssemblyBlobs));
163+
var path = Path.Combine ("temp", string.Format ("BuildAotNdk AndÜmläüts_{0}_{1}", abisSanitized, enableLLVM));
168164
var proj = new XamarinAndroidApplicationProject () {
169165
IsRelease = true,
170166
AotAssemblies = true,
@@ -174,7 +170,6 @@ public void BuildAotApplicationWithNdkAndBundleAndÜmläüts (string supportedAb
174170
proj.SetProperty ("AndroidNdkDirectory", AndroidNdkPath);
175171
proj.SetRuntimeIdentifiers (supportedAbis.Split (';'));
176172
proj.SetProperty ("EnableLLVM", enableLLVM.ToString ());
177-
proj.SetProperty ("AndroidUseAssemblyStore", usesAssemblyBlobs.ToString ());
178173
bool checkMinLlvmPath = enableLLVM && (supportedAbis == "armeabi-v7a" || supportedAbis == "x86");
179174
if (checkMinLlvmPath) {
180175
// Set //uses-sdk/@android:minSdkVersion so that LLVM uses the right libc.so
@@ -195,7 +190,7 @@ public void BuildAotApplicationWithNdkAndBundleAndÜmläüts (string supportedAb
195190
var apk = Path.Combine (Root, b.ProjectDirectory,
196191
proj.OutputPath, $"{proj.PackageName}-Signed.apk");
197192

198-
var helper = new ArchiveAssemblyHelper (apk, usesAssemblyBlobs);
193+
var helper = new ArchiveAssemblyHelper (apk);
199194
Assert.IsTrue (helper.Exists ($"assemblies/{abi}/UnnamedProject.dll"), $"{abi}/UnnamedProject.dll should be in {proj.PackageName}-Signed.apk");
200195
using (var zipFile = ZipHelper.OpenZip (apk)) {
201196
Assert.IsNotNull (ZipHelper.ReadFileFromZip (zipFile,
@@ -215,21 +210,20 @@ public void BuildAotApplicationWithNdkAndBundleAndÜmläüts (string supportedAb
215210

216211
[Test]
217212
[TestCaseSource (nameof (AotChecks))]
218-
public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableLLVM, bool usesAssemblyBlobs)
213+
public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableLLVM)
219214
{
220215
if (IsWindows)
221216
Assert.Ignore ("https://github.com/dotnet/runtime/issues/88625");
222217

223218
var abisSanitized = supportedAbis.Replace (";", "").Replace ("-", "").Replace ("_", "");
224-
var path = Path.Combine ("temp", string.Format ("BuildAot AndÜmläüts_{0}_{1}_{2}", abisSanitized, enableLLVM, usesAssemblyBlobs));
219+
var path = Path.Combine ("temp", string.Format ("BuildAot AndÜmläüts_{0}_{1}", abisSanitized, enableLLVM));
225220
var proj = new XamarinAndroidApplicationProject () {
226221
IsRelease = true,
227222
AotAssemblies = true,
228223
PackageName = "com.xamarin.buildaotappandbundlewithspecialchars",
229224
};
230225
proj.SetRuntimeIdentifiers (supportedAbis.Split (';'));
231226
proj.SetProperty ("EnableLLVM", enableLLVM.ToString ());
232-
proj.SetProperty ("AndroidUseAssemblyStore", usesAssemblyBlobs.ToString ());
233227
using (var b = CreateApkBuilder (path)) {
234228
b.ThrowOnBuildFailure = false;
235229
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
@@ -240,7 +234,7 @@ public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableL
240234
var apk = Path.Combine (Root, b.ProjectDirectory,
241235
proj.OutputPath, $"{proj.PackageName}-Signed.apk");
242236

243-
var helper = new ArchiveAssemblyHelper (apk, usesAssemblyBlobs);
237+
var helper = new ArchiveAssemblyHelper (apk);
244238
Assert.IsTrue (helper.Exists ($"assemblies/{abi}/UnnamedProject.dll"), $"{abi}/UnnamedProject.dll should be in {proj.PackageName}-Signed.apk");
245239
using (var zipFile = ZipHelper.OpenZip (apk)) {
246240
Assert.IsNotNull (ZipHelper.ReadFileFromZip (zipFile,

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.TestCaseSource.cs

-16
Original file line numberDiff line numberDiff line change
@@ -16,97 +16,81 @@ public partial class BuildTest : BaseTest
1616
/* runtimeIdentifiers */ "android-arm",
1717
/* isRelease */ false,
1818
/* aot */ false,
19-
/* usesAssemblyStore */ false,
2019
},
2120
new object [] {
2221
/* runtimeIdentifiers */ "android-arm",
2322
/* isRelease */ false,
2423
/* aot */ false,
25-
/* usesAssemblyStore */ true,
2624
},
2725
new object [] {
2826
/* runtimeIdentifiers */ "android-arm64",
2927
/* isRelease */ false,
3028
/* aot */ false,
31-
/* usesAssemblyStore */ false,
3229
},
3330
new object [] {
3431
/* runtimeIdentifiers */ "android-x86",
3532
/* isRelease */ false,
3633
/* aot */ false,
37-
/* usesAssemblyStore */ false,
3834
},
3935
new object [] {
4036
/* runtimeIdentifiers */ "android-x64",
4137
/* isRelease */ false,
4238
/* aot */ false,
43-
/* usesAssemblyStore */ false,
4439
},
4540
new object [] {
4641
/* runtimeIdentifiers */ "android-arm",
4742
/* isRelease */ true,
4843
/* aot */ false,
49-
/* usesAssemblyStore */ false,
5044
},
5145
new object [] {
5246
/* runtimeIdentifiers */ "android-arm",
5347
/* isRelease */ true,
5448
/* aot */ false,
55-
/* usesAssemblyStore */ true,
5649
},
5750
new object [] {
5851
/* runtimeIdentifiers */ "android-arm",
5952
/* isRelease */ true,
6053
/* aot */ true,
61-
/* usesAssemblyStore */ false,
6254
},
6355
new object [] {
6456
/* runtimeIdentifiers */ "android-arm",
6557
/* isRelease */ true,
6658
/* aot */ true,
67-
/* usesAssemblyStore */ true,
6859
},
6960
new object [] {
7061
/* runtimeIdentifiers */ "android-arm64",
7162
/* isRelease */ true,
7263
/* aot */ false,
73-
/* usesAssemblyStore */ false,
7464
},
7565
new object [] {
7666
/* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64",
7767
/* isRelease */ false,
7868
/* aot */ false,
79-
/* usesAssemblyStore */ false,
8069
},
8170
new object [] {
8271
/* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64",
8372
/* isRelease */ false,
8473
/* aot */ false,
85-
/* usesAssemblyStore */ true,
8674
},
8775
new object [] {
8876
/* runtimeIdentifiers */ "android-arm;android-arm64;android-x86",
8977
/* isRelease */ true,
9078
/* aot */ false,
91-
/* usesAssemblyStore */ false,
9279
},
9380
new object [] {
9481
/* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64",
9582
/* isRelease */ true,
9683
/* aot */ false,
97-
/* usesAssemblyStore */ false,
9884
},
9985
new object [] {
10086
/* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64",
10187
/* isRelease */ true,
10288
/* aot */ false,
103-
/* usesAssemblyStore */ true,
10489
},
10590
new object [] {
10691
/* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64",
10792
/* isRelease */ true,
10893
/* aot */ true,
109-
/* usesAssemblyStore */ false,
11094
},
11195
};
11296

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs

+3-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public partial class BuildTest : BaseTest
2626
[Category ("SmokeTests")]
2727
[TestCaseSource (nameof (DotNetBuildSource))]
2828
[NonParallelizable] // On MacOS, parallel /restore causes issues
29-
public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bool usesAssemblyStore)
29+
public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot)
3030
{
3131
var proj = new XamarinAndroidApplicationProject {
3232
IsRelease = isRelease,
@@ -63,7 +63,6 @@ public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bo
6363
};
6464
proj.MainActivity = proj.DefaultMainActivity.Replace (": Activity", ": AndroidX.AppCompat.App.AppCompatActivity")
6565
.Replace ("//${AFTER_ONCREATE}", @"button.Text = Resource.CancelButton;");
66-
proj.SetProperty ("AndroidUseAssemblyStore", usesAssemblyStore.ToString ());
6766
proj.SetProperty ("RunAOTCompilation", aot.ToString ());
6867
proj.OtherBuildItems.Add (new AndroidItem.InputJar ("javaclasses.jar") {
6968
BinaryContent = () => ResourceData.JavaSourceJarTestJar,
@@ -158,7 +157,7 @@ public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bo
158157
bool expectEmbeddedAssembies = !(TestEnvironment.CommercialBuildAvailable && !isRelease);
159158
var apkPath = Path.Combine (outputPath, $"{proj.PackageName}-Signed.apk");
160159
FileAssert.Exists (apkPath);
161-
var helper = new ArchiveAssemblyHelper (apkPath, usesAssemblyStore, rids);
160+
var helper = new ArchiveAssemblyHelper (apkPath, rids);
162161
helper.AssertContainsEntry ($"assemblies/{proj.ProjectName}.dll", shouldContainEntry: expectEmbeddedAssembies);
163162
helper.AssertContainsEntry ($"assemblies/{proj.ProjectName}.pdb", shouldContainEntry: !TestEnvironment.CommercialBuildAvailable && !isRelease);
164163
helper.AssertContainsEntry ($"assemblies/Mono.Android.dll", shouldContainEntry: expectEmbeddedAssembies);
@@ -262,7 +261,6 @@ public void CheckAssemblyCounts (bool isRelease, bool aot)
262261

263262
var abis = new [] { "armeabi-v7a", "x86" };
264263
proj.SetRuntimeIdentifiers (abis);
265-
proj.SetProperty (proj.ActiveConfigurationProperties, "AndroidUseAssemblyStore", "True");
266264

267265
using (var b = CreateApkBuilder ()) {
268266
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
@@ -279,7 +277,7 @@ public void CheckAssemblyCounts (bool isRelease, bool aot)
279277
}
280278

281279
string apk = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}-Signed.apk");
282-
var helper = new ArchiveAssemblyHelper (apk, useAssemblyStores: true);
280+
var helper = new ArchiveAssemblyHelper (apk);
283281

284282
foreach (string abi in abis) {
285283
AndroidTargetArch arch = MonoAndroidHelper.AbiToTargetArch (abi);

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ public void BuildReleaseArm64 ([Values (false, true)] bool forms)
154154
proj.AotAssemblies = false; // Release defaults to Profiled AOT for .NET 6
155155
proj.SetAndroidSupportedAbis ("arm64-v8a");
156156
proj.SetProperty ("LinkerDumpDependencies", "True");
157-
proj.SetProperty ("AndroidUseAssemblyStore", "False");
158157

159158
var flavor = (forms ? "XForms" : "Simple") + "DotNet";
160159
var apkDescFilename = $"BuildReleaseArm64{flavor}.apkdesc";
@@ -319,7 +318,7 @@ public void XA1037PropertyDeprecatedWarning (string property, string value, bool
319318
XamarinAndroidProject proj = isBindingProject ? new XamarinAndroidBindingProject () : new XamarinAndroidApplicationProject ();
320319
proj.IsRelease = isRelease;
321320
proj.SetProperty (property, value);
322-
321+
323322
using (ProjectBuilder b = isBindingProject ? CreateDllBuilder (Path.Combine ("temp", TestName)) : CreateApkBuilder (Path.Combine ("temp", TestName))) {
324323
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
325324
Assert.IsTrue (StringAssertEx.ContainsText (b.LastBuildOutput, $"The '{property}' MSBuild property is deprecated and will be removed"),
@@ -1369,7 +1368,7 @@ public Class2 ()
13691368
};
13701369

13711370
string apkPath = Path.Combine (outputPath, proj.PackageName + "-Signed.apk");
1372-
var helper = new ArchiveAssemblyHelper (apkPath, useAssemblyStores: false, proj.GetRuntimeIdentifiers ().ToArray ());
1371+
var helper = new ArchiveAssemblyHelper (apkPath, proj.GetRuntimeIdentifiers ().ToArray ());
13731372
foreach (string abi in proj.GetRuntimeIdentifiersAsAbis ()) {
13741373
foreach ((string fileName, bool existsInBin) in fileNames) {
13751374
EnsureFilesAreTheSame (intermediate, existsInBin ? outputPath : null, fileName, abi, helper, uncompressIfNecessary: fileName.EndsWith (".dll", StringComparison.Ordinal));

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void CheckR8InfoMessagesToNotBreakTheBuild ()
5858

5959
[Test]
6060
[NonParallelizable] // Commonly fails NuGet restore
61-
public void CheckIncludedAssemblies ([Values (false, true)] bool usesAssemblyStores)
61+
public void CheckIncludedAssemblies ()
6262
{
6363
var proj = new XamarinAndroidApplicationProject {
6464
IsRelease = true
@@ -68,7 +68,6 @@ public void CheckIncludedAssemblies ([Values (false, true)] bool usesAssemblySto
6868
AndroidTargetArch.Arm,
6969
};
7070

71-
proj.SetProperty ("AndroidUseAssemblyStore", usesAssemblyStores.ToString ());
7271
proj.SetRuntimeIdentifiers (supportedArches);
7372
proj.PackageReferences.Add (new Package {
7473
Id = "Humanizer.Core",
@@ -111,7 +110,7 @@ public void CheckIncludedAssemblies ([Values (false, true)] bool usesAssemblySto
111110
Assert.IsTrue (b.Build (proj), "build should have succeeded.");
112111
var apk = Path.Combine (Root, b.ProjectDirectory,
113112
proj.OutputPath, $"{proj.PackageName}-Signed.apk");
114-
var helper = new ArchiveAssemblyHelper (apk, usesAssemblyStores);
113+
var helper = new ArchiveAssemblyHelper (apk);
115114
List<string> existingFiles;
116115
List<string> missingFiles;
117116
List<string> additionalFiles;

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/LinkerTests.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -261,21 +261,20 @@ public void WarnAboutAppDomains ([Values (true, false)] bool isRelease)
261261
}
262262

263263
[Test]
264-
public void RemoveDesigner ([Values (true, false)] bool useAssemblyStore)
264+
public void RemoveDesigner ()
265265
{
266266
var proj = new XamarinAndroidApplicationProject {
267267
IsRelease = true,
268268
};
269269
proj.SetProperty ("AndroidEnableAssemblyCompression", "False");
270270
proj.SetProperty ("AndroidLinkResources", "True");
271-
proj.SetProperty ("AndroidUseAssemblyStore", useAssemblyStore.ToString ());
272271
string assemblyName = proj.ProjectName;
273272

274273
using var b = CreateApkBuilder ();
275274
Assert.IsTrue (b.Build (proj), "build should have succeeded.");
276275
var apk = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}-Signed.apk");
277276
FileAssert.Exists (apk);
278-
var helper = new ArchiveAssemblyHelper (apk, useAssemblyStore);
277+
var helper = new ArchiveAssemblyHelper (apk);
279278
foreach (string abi in proj.GetRuntimeIdentifiersAsAbis ()) {
280279
Assert.IsTrue (helper.Exists ($"assemblies/{abi}/{assemblyName}.dll"), $"{assemblyName}.dll should exist in apk!");
281280

@@ -297,7 +296,7 @@ public void RemoveDesigner ([Values (true, false)] bool useAssemblyStore)
297296
}
298297

299298
[Test]
300-
public void LinkDescription ([Values (true, false)] bool useAssemblyStore)
299+
public void LinkDescription ()
301300
{
302301
string assembly_name = "System.Console";
303302
string linker_xml = "<linker/>";
@@ -312,7 +311,6 @@ public void LinkDescription ([Values (true, false)] bool useAssemblyStore)
312311
};
313312
// So we can use Mono.Cecil to open assemblies directly
314313
proj.SetProperty ("AndroidEnableAssemblyCompression", "False");
315-
proj.SetProperty ("AndroidUseAssemblyStore", useAssemblyStore.ToString ());
316314

317315
using (var b = CreateApkBuilder ()) {
318316
Assert.IsTrue (b.Build (proj), "first build should have succeeded.");
@@ -331,7 +329,7 @@ public void LinkDescription ([Values (true, false)] bool useAssemblyStore)
331329

332330
var apk = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}-Signed.apk");
333331
FileAssert.Exists (apk);
334-
var helper = new ArchiveAssemblyHelper (apk, useAssemblyStore);
332+
var helper = new ArchiveAssemblyHelper (apk);
335333
foreach (string abi in proj.GetRuntimeIdentifiersAsAbis ()) {
336334
Assert.IsTrue (helper.Exists ($"assemblies/{abi}/{assembly_name}.dll"), $"{assembly_name}.dll should exist in apk!");
337335
}

0 commit comments

Comments
 (0)