Skip to content

Commit e5799df

Browse files
committed
Always generate embedded store sources in CreateEmbeddedAssemblyStore
1 parent 184636f commit e5799df

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
@@ -62,13 +62,10 @@ public override bool RunTask ()
6262
[Required]
6363
public bool EnablePreloadAssembliesDefault { get; set; }
6464

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

69-
//[Required]
70-
public bool AssemblyStoreEmbeddedInRuntime { get; set; }
71-
7269
public bool EnableMarshalMethods { get; set; }
7370
public string RuntimeConfigBinFilePath { get; set; }
7471
public string BoundExceptionType { get; set; }
@@ -352,7 +349,6 @@ void AddEnvironment ()
352349
JniRemappingReplacementMethodIndexEntryCount = jniRemappingNativeCodeInfo == null ? 0 : jniRemappingNativeCodeInfo.ReplacementMethodIndexEntryCount,
353350
MarshalMethodsEnabled = EnableMarshalMethods,
354351
IgnoreSplitConfigs = ShouldIgnoreSplitConfigs (),
355-
AssemblyStoreEmbeddedInRuntime = UseAssemblyStore && AssemblyStoreEmbeddedInRuntime,
356352
};
357353
LLVMIR.LlvmIrModule appConfigModule = appConfigAsmGen.Construct ();
358354

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ sealed class XamarinAndroidBundledAssembly
198198
public bool MarshalMethodsEnabled { get; set; }
199199
public bool ManagedMarshalMethodsLookupEnabled { get; set; }
200200
public bool IgnoreSplitConfigs { get; set; }
201-
public bool AssemblyStoreEmbeddedInRuntime { get; set; }
202201

203202
public ApplicationConfigNativeAssemblyGenerator (IDictionary<string, string> environmentVariables, IDictionary<string, string> systemProperties, TaskLoggingHelper log)
204203
: base (log)
@@ -308,24 +307,6 @@ protected override void Construct (LlvmIrModule module)
308307
module.Add (bundled_assemblies);
309308

310309
AddAssemblyStores (module);
311-
312-
if (AssemblyStoreEmbeddedInRuntime) {
313-
return;
314-
}
315-
316-
// Need these to keep ABI compatibility with `libxamarin-app.so` used at the runtime's build time
317-
var embedded_assembly_store_size = new LlvmIrGlobalVariable (
318-
(ulong)0,
319-
"embedded_assembly_store_size",
320-
LlvmIrVariableOptions.GlobalConstant
321-
);
322-
module.Add (embedded_assembly_store_size);
323-
324-
var embedded_assembly_store = new LlvmIrGlobalVariable (typeof (byte[]), "embedded_assembly_store", LlvmIrVariableOptions.GlobalWritable) {
325-
ZeroInitializeArray = true,
326-
ArrayItemCount = 0,
327-
};
328-
module.Add (embedded_assembly_store);
329310
}
330311

331312
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
@@ -1906,8 +1906,7 @@ because xbuild doesn't support framework reference assemblies.
19061906
UseAssemblyStore="$(AndroidUseAssemblyStore)"
19071907
EnableMarshalMethods="$(_AndroidUseMarshalMethods)"
19081908
CustomBundleConfigFile="$(AndroidBundleConfigurationFile)"
1909-
AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)"
1910-
AssemblyStoreEmbeddedInRuntime="$(_AndroidEmbedAssemblyStoreInRuntime)" />
1909+
AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)" />
19111910
<Touch Files="$(_AndroidStampDirectory)_GeneratePackageManagerJava.stamp" AlwaysCreate="True" />
19121911
<ItemGroup>
19131912
<FileWrites Include="@(_EnvironmentAssemblySource)" />

0 commit comments

Comments
 (0)