Skip to content

Commit 1ea9451

Browse files
committed
Always generate embedded store sources in CreateEmbeddedAssemblyStore
1 parent 1c028ee commit 1ea9451

File tree

5 files changed

+28
-27
lines changed

5 files changed

+28
-27
lines changed

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AssemblyStores.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
</Target>
1414

1515
<Target Name="_CreateEmbeddedAssemblyStore"
16-
Condition=" '$(_AndroidEmbedAssemblyStoreInRuntime)' == 'True' "
1716
DependsOnTargets="_PrepareCreateEmbeddedAssemblyStoreOutputItems"
1817
Inputs="@(_ShrunkUserAssemblies);@(_AndroidResolvedSatellitePaths);@(_ShrunkFrameworkAssemblies)"
1918
Outputs="@(_EmbeddedAssemblyStoreSourceFiles)">
2019
<CreateEmbeddedAssemblyStore
2120
AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)"
2221
AppSharedLibrariesDir="$(_AndroidApplicationSharedLibraryPath)"
2322
AssemblySourcesDir="$(IntermediateOutputPath)android"
23+
AssemblyStoreEmbeddedInRuntime="$(_AndroidEmbedAssemblyStoreInRuntime)"
2424
CompressedAssembliesDir="$(_AndroidCompressedAssembliesDir)\test\"
2525
Debug="$(AndroidIncludeDebugSymbols)"
2626
EnableCompression="$(AndroidEnableAssemblyCompression)"

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public class CreateEmbeddedAssemblyStore : AndroidTask
2525
[Required]
2626
public string CompressedAssembliesDir { get; set; }
2727

28+
[Required]
29+
public bool AssemblyStoreEmbeddedInRuntime { get; set; }
30+
2831
[Required]
2932
public bool Debug { get; set; }
3033

@@ -44,6 +47,28 @@ public class CreateEmbeddedAssemblyStore : AndroidTask
4447
public string [] SupportedAbis { get; set; }
4548

4649
public override bool RunTask ()
50+
{
51+
if (AssemblyStoreEmbeddedInRuntime) {
52+
return EmbedAssemblyStore ();
53+
}
54+
55+
// Generate sources to satisfy libmonodroid's ABI requirements
56+
foreach (string abi in SupportedAbis) {
57+
ELFEmbeddingHelper.EmbedBinary (
58+
Log,
59+
abi,
60+
AndroidBinUtilsDirectory,
61+
inputFile: null,
62+
ELFEmbeddingHelper.KnownEmbedItems.AssemblyStore,
63+
AssemblySourcesDir,
64+
missingContentOK: true
65+
);
66+
}
67+
68+
return !Log.HasLoggedErrors;
69+
}
70+
71+
bool EmbedAssemblyStore ()
4772
{
4873
bool compress = !Debug && EnableCompression;
4974
IDictionary<AndroidTargetArch, Dictionary<string, CompressedAssemblyInfo>>? compressedAssembliesInfo = null;

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,10 @@ public class GeneratePackageManagerJava : AndroidTask
6161
[Required]
6262
public bool EnablePreloadAssembliesDefault { get; set; }
6363

64-
// These two properties should be required but they will require modifying `monodroid` first
64+
// This property should be required but it will require modifying `monodroid` first
6565
//[Required]
6666
public string AndroidBinUtilsDirectory { get; set; }
6767

68-
//[Required]
69-
public bool AssemblyStoreEmbeddedInRuntime { get; set; }
70-
7168
public bool EnableMarshalMethods { get; set; }
7269
public string RuntimeConfigBinFilePath { get; set; }
7370
public string BoundExceptionType { get; set; }
@@ -377,7 +374,6 @@ void AddEnvironment ()
377374
JniRemappingReplacementMethodIndexEntryCount = jniRemappingNativeCodeInfo == null ? 0 : jniRemappingNativeCodeInfo.ReplacementMethodIndexEntryCount,
378375
MarshalMethodsEnabled = EnableMarshalMethods,
379376
IgnoreSplitConfigs = ShouldIgnoreSplitConfigs (),
380-
AssemblyStoreEmbeddedInRuntime = UseAssemblyStore && AssemblyStoreEmbeddedInRuntime,
381377
};
382378
LLVMIR.LlvmIrModule appConfigModule = appConfigAsmGen.Construct ();
383379

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ sealed class XamarinAndroidBundledAssembly
189189
public uint PackagedNativeLibrariesCount { get; set; }
190190
public bool MarshalMethodsEnabled { get; set; }
191191
public bool IgnoreSplitConfigs { get; set; }
192-
public bool AssemblyStoreEmbeddedInRuntime { get; set; }
193192

194193
public ApplicationConfigNativeAssemblyGenerator (IDictionary<string, string> environmentVariables, IDictionary<string, string> systemProperties, TaskLoggingHelper log)
195194
: base (log)
@@ -296,24 +295,6 @@ protected override void Construct (LlvmIrModule module)
296295
module.Add (bundled_assemblies);
297296

298297
AddAssemblyStores (module);
299-
300-
if (AssemblyStoreEmbeddedInRuntime) {
301-
return;
302-
}
303-
304-
// Need these to keep ABI compatibility with `libxamarin-app.so` used at the runtime's build time
305-
var embedded_assembly_store_size = new LlvmIrGlobalVariable (
306-
(ulong)0,
307-
"embedded_assembly_store_size",
308-
LlvmIrVariableOptions.GlobalConstant
309-
);
310-
module.Add (embedded_assembly_store_size);
311-
312-
var embedded_assembly_store = new LlvmIrGlobalVariable (typeof (byte[]), "embedded_assembly_store", LlvmIrVariableOptions.GlobalWritable) {
313-
ZeroInitializeArray = true,
314-
ArrayItemCount = 0,
315-
};
316-
module.Add (embedded_assembly_store);
317298
}
318299

319300
void AddAssemblyStores (LlvmIrModule module)

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,8 +1749,7 @@ because xbuild doesn't support framework reference assemblies.
17491749
UseAssemblyStore="$(AndroidUseAssemblyStore)"
17501750
EnableMarshalMethods="$(_AndroidUseMarshalMethods)"
17511751
CustomBundleConfigFile="$(AndroidBundleConfigurationFile)"
1752-
AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)"
1753-
AssemblyStoreEmbeddedInRuntime="$(_AndroidEmbedAssemblyStoreInRuntime)" />
1752+
AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)" />
17541753
<Touch Files="$(_AndroidStampDirectory)_GeneratePackageManagerJava.stamp" AlwaysCreate="True" />
17551754
<ItemGroup>
17561755
<FileWrites Include="@(_EnvironmentAssemblySource)" />

0 commit comments

Comments
 (0)