Skip to content

Commit 7b9412e

Browse files
committed
Remove $(AndroidCreatePackagePerAbi)
1 parent 23e12b4 commit 7b9412e

4 files changed

Lines changed: 19 additions & 55 deletions

File tree

src/Xamarin.Android.Build.Tasks/Tasks/BuildApkTemporary.cs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ public class BuildApkTemporary : AndroidTask
6868
[Required]
6969
public string [] SupportedAbis { get; set; }
7070

71-
public bool CreatePackagePerAbi { get; set; }
72-
7371
public bool EmbedAssemblies { get; set; }
7472

7573
public bool BundleAssemblies { get; set; }
@@ -154,11 +152,11 @@ protected virtual void FixupArchive (ZipArchiveFileListBuilder zip) { }
154152

155153
List<Regex> includePatterns = new List<Regex> ();
156154

157-
void ExecuteWithAbi (DSOWrapperGenerator.Config dsoWrapperConfig, string [] supportedAbis, string apkInputPath, string apkOutputPath, bool debug, bool compress, IDictionary<AndroidTargetArch, Dictionary<string, CompressedAssemblyInfo>> compressedAssembliesInfo, string assemblyStoreApkName, string? abiMetadata)
155+
void ExecuteWithAbi (DSOWrapperGenerator.Config dsoWrapperConfig, string [] supportedAbis, string apkInputPath, string apkOutputPath, bool debug, bool compress, IDictionary<AndroidTargetArch, Dictionary<string, CompressedAssemblyInfo>> compressedAssembliesInfo, string assemblyStoreApkName)
158156
{
159157
ArchiveFileList files = new ArchiveFileList ();
160158

161-
using (var apk = new ZipArchiveFileListBuilder (apkOutputPath, File.Exists (apkOutputPath) ? FileMode.Open : FileMode.Create, abiMetadata)) {
159+
using (var apk = new ZipArchiveFileListBuilder (apkOutputPath, File.Exists (apkOutputPath) ? FileMode.Open : FileMode.Create)) {
162160

163161
// Add classes.dx
164162
CompressionMethod dexCompressionMethod = GetCompressionMethod (".dex");
@@ -302,21 +300,8 @@ public override bool RunTask ()
302300
}
303301

304302
DSOWrapperGenerator.Config dsoWrapperConfig = DSOWrapperGenerator.GetConfig (Log, AndroidBinUtilsDirectory, IntermediateOutputPath);
305-
ExecuteWithAbi (dsoWrapperConfig, SupportedAbis, ApkInputPath, ApkOutputPath, debug, compress, compressedAssembliesInfo, assemblyStoreApkName: null, abiMetadata: "all");
303+
ExecuteWithAbi (dsoWrapperConfig, SupportedAbis, ApkInputPath, ApkOutputPath, debug, compress, compressedAssembliesInfo, assemblyStoreApkName: null);
306304
outputFiles.Add ("all", ApkOutputPath);
307-
if (CreatePackagePerAbi && SupportedAbis.Length > 1) {
308-
var abiArray = new string[] { String.Empty };
309-
foreach (var abi in SupportedAbis) {
310-
existingEntries.Clear ();
311-
var path = Path.GetDirectoryName (ApkOutputPath);
312-
var apk = Path.GetFileNameWithoutExtension (ApkOutputPath);
313-
abiArray[0] = abi;
314-
ExecuteWithAbi (dsoWrapperConfig, abiArray, String.Format ("{0}-{1}", ApkInputPath, abi),
315-
Path.Combine (path, String.Format ("{0}-{1}.apk", apk, abi)),
316-
debug, compress, compressedAssembliesInfo, assemblyStoreApkName: abi, abiMetadata: abi);
317-
outputFiles.Add (abi, Path.Combine (path, String.Format ("{0}-{1}.apk", apk, abi)));
318-
}
319-
}
320305

321306
OutputFiles = outputFiles.Select (a => new TaskItem (a.Value, new Dictionary<string, string> () { { "Abi", a.Key } })).ToArray ();
322307

src/Xamarin.Android.Build.Tasks/Tasks/BuildApkArchive.cs renamed to src/Xamarin.Android.Build.Tasks/Tasks/BuildArchive.cs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,22 @@
88
using Microsoft.Build.Framework;
99
using Xamarin.Tools.Zip;
1010

11-
// TODO: Need to handle BuildBaseAppBundle.FixupArchive somewhere.
12-
1311
namespace Xamarin.Android.Tasks;
1412

1513
/// <summary>
1614
/// Takes a list of files and adds them to an APK archive. If the APK archive already
1715
/// exists, files are only added if they were changed.
1816
/// </summary>
19-
public class BuildApkArchive : AndroidTask
17+
public class BuildArchive : AndroidTask
2018
{
2119
public override string TaskPrefix => "BAA";
2220

23-
[Required]
24-
public string Abi { get;set; } = null!; // NRT enforced by [Required]
25-
2621
public string? AndroidPackageFormat { get; set; }
2722

2823
public string? ApkInputPath { get; set; }
2924

3025
[Required]
31-
public ITaskItem [] ApkOutputPaths { get; set; } = null!; // NRT enforced by [Required]
26+
public string ApkOutputPath { get; set; } = null!; // NRT enforced by [Required]
3227

3328
[Required]
3429
public ITaskItem [] FilesToAddToApk { get; set; } = null!; // NRT enforced by [Required]
@@ -42,7 +37,7 @@ public class BuildApkArchive : AndroidTask
4237
readonly HashSet<string> uncompressedFileExtensions;
4338
readonly CompressionMethod uncompressedMethod = CompressionMethod.Store;
4439

45-
public BuildApkArchive ()
40+
public BuildArchive ()
4641
{
4742
uncompressedFileExtensions = new HashSet<string> (StringComparer.OrdinalIgnoreCase);
4843

@@ -69,18 +64,15 @@ public override bool RunTask ()
6964
{
7065
var refresh = true;
7166

72-
// Find the output apk filename
73-
var apk_output_path = ApkOutputPaths.Single (i => i.GetMetadataOrDefault ("Abi", string.Empty) == Abi).ItemSpec;
74-
7567
// If we have an input apk but no output apk, copy it to the output
7668
// so we don't modify the original.
77-
if (ApkInputPath is not null && File.Exists (ApkInputPath) && !File.Exists (apk_output_path)) {
78-
Log.LogDebugMessage ($"Copying {ApkInputPath} to {apk_output_path}");
79-
File.Copy (ApkInputPath, apk_output_path, overwrite: true);
69+
if (ApkInputPath is not null && File.Exists (ApkInputPath) && !File.Exists (ApkOutputPath)) {
70+
Log.LogDebugMessage ($"Copying {ApkInputPath} to {ApkOutputPath}");
71+
File.Copy (ApkInputPath, ApkOutputPath, overwrite: true);
8072
refresh = false;
8173
}
8274

83-
using var apk = new ZipArchiveEx (apk_output_path, FileMode.Open);
75+
using var apk = new ZipArchiveEx (ApkOutputPath, FileMode.Open);
8476

8577
// Set up AutoFlush
8678
if (int.TryParse (ZipFlushFilesLimit, out int flushFilesLimit)) {
@@ -107,7 +99,7 @@ public override bool RunTask ()
10799
// of date entries in the output APK from the input APK.
108100
if (ApkInputPath is not null && File.Exists (ApkInputPath) && refresh) {
109101

110-
var lastWriteOutput = File.Exists (apk_output_path) ? File.GetLastWriteTimeUtc (apk_output_path) : DateTime.MinValue;
102+
var lastWriteOutput = File.Exists (ApkOutputPath) ? File.GetLastWriteTimeUtc (ApkOutputPath) : DateTime.MinValue;
111103
var lastWriteInput = File.GetLastWriteTimeUtc (ApkInputPath);
112104

113105
using (var packaged = new ZipArchiveEx (ApkInputPath, FileMode.Open)) {

src/Xamarin.Android.Build.Tasks/Utilities/ZipArchiveFileListBuilder.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@ namespace Xamarin.Android.Tasks;
1212
// reviewed easier. This class should not exist in this form in the final state.
1313
public class ZipArchiveFileListBuilder : IDisposable
1414
{
15-
readonly string? abi;
16-
1715
public List<ITaskItem> ApkFiles { get; } = [];
1816

19-
public ZipArchiveFileListBuilder (string archive, FileMode filemode, string? abi)
17+
public ZipArchiveFileListBuilder (string archive, FileMode filemode)
2018
{
21-
this.abi = abi;
2219
}
2320

2421
public void Dispose ()
@@ -38,9 +35,6 @@ public void AddFileAndFlush (string filename, string archiveFileName, Compressio
3835
item.SetMetadata ("ApkPath", archiveFileName);
3936
item.SetMetadata ("Compression", compressionMethod.ToString ());
4037

41-
if (abi.HasValue ())
42-
item.SetMetadata ("Abi", abi);
43-
4438
ApkFiles.Add (item);
4539
}
4640

@@ -51,9 +45,6 @@ public void AddJavaEntryAndFlush (string javaFilename, string javaEntryName, str
5145
item.SetMetadata ("ApkPath", archiveFileName);
5246
item.SetMetadata ("JavaArchiveEntry", javaEntryName);
5347

54-
if (abi.HasValue ())
55-
item.SetMetadata ("Abi", abi);
56-
5748
ApkFiles.Add (item);
5849
}
5950

src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
3131
<UsingTask TaskName="Xamarin.Android.Tasks.Aot" AssemblyFile="Xamarin.Android.Build.Tasks.dll" />
3232
<UsingTask TaskName="Xamarin.Android.Tasks.CilStrip" AssemblyFile="Xamarin.Android.Build.Tasks.dll" />
3333
<UsingTask TaskName="Xamarin.Android.Tasks.BuildApk" AssemblyFile="Xamarin.Android.Build.Tasks.dll" />
34-
<UsingTask TaskName="Xamarin.Android.Tasks.BuildApkArchive" AssemblyFile="Xamarin.Android.Build.Tasks.dll" />
3534
<UsingTask TaskName="Xamarin.Android.Tasks.BuildApkTemporary" AssemblyFile="Xamarin.Android.Build.Tasks.dll" />
35+
<UsingTask TaskName="Xamarin.Android.Tasks.BuildArchive" AssemblyFile="Xamarin.Android.Build.Tasks.dll" />
3636
<UsingTask TaskName="Xamarin.Android.Tasks.BuildBaseAppBundle" AssemblyFile="Xamarin.Android.Build.Tasks.dll" />
3737
<UsingTask TaskName="Xamarin.Android.Tasks.BuildAppBundle" AssemblyFile="Xamarin.Android.Build.Tasks.dll" />
3838
<UsingTask TaskName="Xamarin.Android.Tasks.BuildApkSet" AssemblyFile="Xamarin.Android.Build.Tasks.dll" />
@@ -2097,7 +2097,6 @@ because xbuild doesn't support framework reference assemblies.
20972097
EmbeddedNativeLibraryAssemblies="$(OutDir)$(TargetFileName);@(_ReferencePath);@(_ReferenceDependencyPaths)"
20982098
DalvikClasses="@(_DexFile)"
20992099
SupportedAbis="@(_BuildTargetAbis)"
2100-
CreatePackagePerAbi="$(_AndroidCreatePackagePerAbi)"
21012100
Debug="$(AndroidIncludeDebugSymbols)"
21022101
EnableCompression="$(AndroidEnableAssemblyCompression)"
21032102
JavaSourceFiles="@(AndroidJavaSource)"
@@ -2125,12 +2124,11 @@ because xbuild doesn't support framework reference assemblies.
21252124
<Output TaskParameter="DSODirectoriesToDelete" ItemName="DSODirectoriesToDelete" />
21262125
</BuildApkTemporary>
21272126

2128-
<!-- This task uses MSBuild task batching. It will be called once for each unique '%(FilesToAddToApk.Abi)'. -->
2129-
<BuildApkArchive
2130-
Abi="%(FilesToAddToApk.Abi)"
2127+
<!-- Create the actual zip archive -->
2128+
<BuildArchive
21312129
AndroidPackageFormat="$(AndroidPackageFormat)"
21322130
ApkInputPath="$(_PackagedResources)"
2133-
ApkOutputPaths="@(ApkFiles)"
2131+
ApkOutputPath="$(_ApkOutputPath)"
21342132
FilesToAddToApk="@(FilesToAddToApk)"
21352133
UncompressedFileExtensions="$(AndroidStoreUncompressedFileExtensions)"
21362134
ZipFlushFilesLimit="$(_ZipFlushFilesLimit)"
@@ -2218,7 +2216,6 @@ because xbuild doesn't support framework reference assemblies.
22182216
DalvikClasses="@(_DalvikClasses)"
22192217
SupportedAbis="@(_BuildTargetAbis)"
22202218
AndroidSequencePointsMode="$(_SequencePointsMode)"
2221-
CreatePackagePerAbi="$(_AndroidCreatePackagePerAbi)"
22222219
Debug="$(AndroidIncludeDebugSymbols)"
22232220
EnableCompression="$(AndroidEnableAssemblyCompression)"
22242221
TypeMappings="@(_AndroidTypeMaps)"
@@ -2244,12 +2241,11 @@ because xbuild doesn't support framework reference assemblies.
22442241
<Output TaskParameter="DSODirectoriesToDelete" ItemName="DSODirectoriesToDelete" />
22452242
</BuildApkTemporary>
22462243

2247-
<!-- This task uses MSBuild task batching. It will be called once for each unique '%(FilesToAddToApk.Abi)'. -->
2248-
<BuildApkArchive
2249-
Abi="%(FilesToAddToApk.Abi)"
2244+
<!-- Create the actual zip archive -->
2245+
<BuildArchive
22502246
AndroidPackageFormat="$(AndroidPackageFormat)"
22512247
ApkInputPath="$(_PackagedResources)"
2252-
ApkOutputPaths="@(ApkFiles)"
2248+
ApkOutputPath="$(_ApkOutputPath)"
22532249
FilesToAddToApk="@(FilesToAddToApk)"
22542250
UncompressedFileExtensions="$(AndroidStoreUncompressedFileExtensions)"
22552251
ZipFlushFilesLimit="$(_ZipFlushFilesLimit)"

0 commit comments

Comments
 (0)