Skip to content

Commit

Permalink
Always use assembly stores when assemblies are to be embedded
Browse files Browse the repository at this point in the history
All the non-fastdev builds will use assembly stores unconditionally
now.
  • Loading branch information
grendello committed Oct 24, 2024
1 parent be53aed commit 9bb00af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 57 deletions.
54 changes: 2 additions & 52 deletions src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ public class BuildApk : AndroidTask

public string RuntimeConfigBinFilePath { get; set; }

public bool UseAssemblyStore { get; set; }

public string ZipFlushFilesLimit { get; set; }

public string ZipFlushSizeLimit { get; set; }
Expand Down Expand Up @@ -423,24 +421,15 @@ void AddRuntimeConfigBlob (DSOWrapperGenerator.Config dsoWrapperConfig, ZipArchi
void AddAssemblies (DSOWrapperGenerator.Config dsoWrapperConfig, ZipArchiveEx apk, bool debug, bool compress, IDictionary<AndroidTargetArch, Dictionary<string, CompressedAssemblyInfo>> compressedAssembliesInfo, string assemblyStoreApkName)
{
string sourcePath;
AssemblyCompression.AssemblyData compressedAssembly = null;
string compressedOutputDir = Path.GetFullPath (Path.Combine (Path.GetDirectoryName (ApkOutputPath), "..", "lz4"));
AssemblyStoreBuilder? storeBuilder = null;

if (UseAssemblyStore) {
storeBuilder = new AssemblyStoreBuilder (Log);
}
var storeBuilder = new AssemblyStoreBuilder (Log);

// Add user assemblies
AssemblyPackagingHelper.AddAssembliesFromCollection (Log, SupportedAbis, ResolvedUserAssemblies, DoAddAssembliesFromArchCollection);

// Add framework assemblies
AssemblyPackagingHelper.AddAssembliesFromCollection (Log, SupportedAbis, ResolvedFrameworkAssemblies, DoAddAssembliesFromArchCollection);

if (!UseAssemblyStore) {
return;
}

Dictionary<AndroidTargetArch, string> assemblyStorePaths = storeBuilder.Generate (AppSharedLibrariesDir);

if (assemblyStorePaths.Count == 0) {
Expand All @@ -467,46 +456,7 @@ void DoAddAssembliesFromArchCollection (TaskLoggingHelper log, AndroidTargetArch
// Thus, we no longer just store them in the apk but we call the `GetCompressionMethod` method to find out whether
// or not we're supposed to compress .so files.
sourcePath = CompressAssembly (assembly);
if (UseAssemblyStore) {
storeBuilder.AddAssembly (sourcePath, assembly, includeDebugSymbols: debug);
return;
}

// Add assembly
(string assemblyPath, string assemblyDirectory) = GetInArchiveAssemblyPath (assembly);
string wrappedSourcePath = DSOWrapperGenerator.WrapIt (Log, dsoWrapperConfig, arch, sourcePath, Path.GetFileName (assemblyPath));
AddFileToArchiveIfNewer (apk, wrappedSourcePath, assemblyPath, compressionMethod: GetCompressionMethod (assemblyPath));

// Try to add config if exists
var config = Path.ChangeExtension (assembly.ItemSpec, "dll.config");
AddAssemblyConfigEntry (dsoWrapperConfig, apk, arch, assemblyDirectory, config);

// Try to add symbols if Debug
if (!debug) {
return;
}

string symbols = Path.ChangeExtension (assembly.ItemSpec, "pdb");
if (!File.Exists (symbols)) {
return;
}

string archiveSymbolsPath = assemblyDirectory + MonoAndroidHelper.MakeDiscreteAssembliesEntryName (Path.GetFileName (symbols));
string wrappedSymbolsPath = DSOWrapperGenerator.WrapIt (Log, dsoWrapperConfig, arch, symbols, Path.GetFileName (archiveSymbolsPath));
AddFileToArchiveIfNewer (
apk,
wrappedSymbolsPath,
archiveSymbolsPath,
compressionMethod: GetCompressionMethod (archiveSymbolsPath)
);
}

void EnsureCompressedAssemblyData (string sourcePath, uint descriptorIndex)
{
if (compressedAssembly == null)
compressedAssembly = new AssemblyCompression.AssemblyData (sourcePath, descriptorIndex);
else
compressedAssembly.SetData (sourcePath, descriptorIndex);
storeBuilder.AddAssembly (sourcePath, assembly, includeDebugSymbols: debug);
}

string CompressAssembly (ITaskItem assembly)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.

<PropertyGroup>
<_AndroidAotStripLibraries Condition=" '$(_AndroidAotStripLibraries)' == '' And '$(AndroidIncludeDebugSymbols)' != 'true' ">True</_AndroidAotStripLibraries>
<AndroidUseAssemblyStore Condition=" '$(AndroidUseAssemblyStore)' == '' and ('$(EmbedAssembliesIntoApk)' != 'true' or '$(AndroidIncludeDebugSymbols)' == 'true') ">false</AndroidUseAssemblyStore>
<AndroidUseAssemblyStore Condition=" '$(AndroidUseAssemblyStore)' == '' ">true</AndroidUseAssemblyStore>
<AndroidUseAssemblyStore Condition=" '$(EmbedAssembliesIntoApk)' != 'true' ">false</AndroidUseAssemblyStore>
<AndroidUseAssemblyStore Condition=" '$(EmbedAssembliesIntoApk)' != 'true' ">true</AndroidUseAssemblyStore>
<AndroidAotEnableLazyLoad Condition=" '$(AndroidAotEnableLazyLoad)' == '' And '$(AotAssemblies)' == 'true' And '$(AndroidIncludeDebugSymbols)' != 'true' ">True</AndroidAotEnableLazyLoad>
<AndroidEnableMarshalMethods Condition=" '$(AndroidEnableMarshalMethods)' == '' and ('$(UsingMicrosoftNETSdkRazor)' == 'true') ">False</AndroidEnableMarshalMethods>
<AndroidEnableMarshalMethods Condition=" '$(AndroidEnableMarshalMethods)' == '' ">False</AndroidEnableMarshalMethods>
Expand Down Expand Up @@ -1588,7 +1588,6 @@ because xbuild doesn't support framework reference assemblies.
<PropertyGroup>
<AndroidStoreUncompressedFileExtensions Condition=" '$(_EmbeddedDSOsEnabled)' == 'True' ">.so;$(AndroidStoreUncompressedFileExtensions)</AndroidStoreUncompressedFileExtensions>
<AndroidStoreUncompressedFileExtensions Condition=" '$(_UseEmbeddedDex)' == 'True' ">.dex;$(AndroidStoreUncompressedFileExtensions)</AndroidStoreUncompressedFileExtensions>
<AndroidStoreUncompressedFileExtensions Condition=" '$(AndroidUseAssemblyStore)' == 'True' ">.blob;$(AndroidStoreUncompressedFileExtensions)</AndroidStoreUncompressedFileExtensions>
</PropertyGroup>
</Target>

Expand Down Expand Up @@ -2108,7 +2107,6 @@ because xbuild doesn't support framework reference assemblies.
ZipFlushFilesLimit="$(_ZipFlushFilesLimit)"
ZipFlushSizeLimit="$(_ZipFlushSizeLimit)"
ZipAlignmentPages="$(AndroidZipAlignment)"
UseAssemblyStore="$(AndroidUseAssemblyStore)"
AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)"
IntermediateOutputPath="$(IntermediateOutputPath)">
<Output TaskParameter="OutputFiles" ItemName="ApkFiles" />
Expand Down Expand Up @@ -2148,7 +2146,6 @@ because xbuild doesn't support framework reference assemblies.
ZipFlushFilesLimit="$(_ZipFlushFilesLimit)"
ZipFlushSizeLimit="$(_ZipFlushSizeLimit)"
ZipAlignmentPages="$(AndroidZipAlignment)"
UseAssemblyStore="$(AndroidUseAssemblyStore)"
AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)"
IntermediateOutputPath="$(IntermediateOutputPath)">
<Output TaskParameter="OutputFiles" ItemName="BaseZipFile" />
Expand Down

0 comments on commit 9bb00af

Please sign in to comment.