Skip to content

Commit 71bc545

Browse files
committed
Embed runtime config for MonoVM
1 parent 275241b commit 71bc545

File tree

4 files changed

+23
-81
lines changed

4 files changed

+23
-81
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
2121
DependsOnTargets="_PrepareCreateEmbeddedAssemblyStoreOutputItems"
2222
Inputs="@(_CreateEmbeddedAssemblyStoreAssembly)"
2323
Outputs="@(_EmbeddedAssemblyStoreSourceFiles)">
24-
<PropertyGroup>
25-
<_EmbedAssemblyStoreInRuntime Condition=" '$(_AndroidUseAssemblyStore)' And '$(_AndroidEmbedAssemblyStoreInRuntime)' ">true</_EmbedAssemblyStoreInRuntime>
26-
<_EmbedAssemblyStoreInRuntime Condition=" '$(_EmbedAssemblyStoreInRuntime)' != 'true' ">false</_EmbedAssemblyStoreInRuntime>
27-
</PropertyGroup>
28-
2924
<CreateEmbeddedAssemblyStore
3025
AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)"
3126
AppSharedLibrariesDir="$(_AndroidApplicationSharedLibraryPath)"

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

Lines changed: 0 additions & 59 deletions
This file was deleted.

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public class GenerateNativeApplicationConfigSources : AndroidTask
5050
[Required]
5151
public bool TargetsCLR { get; set; }
5252

53+
[Required]
54+
public string AndroidBinUtilsDirectory { get; set; } = "";
55+
5356
public bool EnableMarshalMethods { get; set; }
5457
public bool EnableManagedMarshalMethodsLookup { get; set; }
5558
public string? RuntimeConfigBinFilePath { get; set; }
@@ -248,7 +251,6 @@ public override bool RunTask ()
248251
}
249252
}
250253

251-
bool haveRuntimeConfigBlob = !String.IsNullOrEmpty (RuntimeConfigBinFilePath) && File.Exists (RuntimeConfigBinFilePath);
252254
var jniRemappingNativeCodeInfo = BuildEngine4.GetRegisteredTaskObjectAssemblyLocal<GenerateJniRemappingNativeCode.JniRemappingNativeCodeInfo> (ProjectSpecificTaskObjectKey (GenerateJniRemappingNativeCode.JniRemappingNativeCodeInfoKey), RegisteredTaskObjectLifetime.Build);
253255
LLVMIR.LlvmIrComposer appConfigAsmGen;
254256

@@ -272,6 +274,17 @@ public override bool RunTask ()
272274
IgnoreSplitConfigs = ShouldIgnoreSplitConfigs (),
273275
};
274276
} else {
277+
bool haveRuntimeConfigBlob = !String.IsNullOrEmpty (RuntimeConfigBinFilePath) && File.Exists (RuntimeConfigBinFilePath);
278+
ELFEmbeddingHelper.EmbedBinary (
279+
Log,
280+
SupportedAbis,
281+
AndroidBinUtilsDirectory,
282+
RuntimeConfigBinFilePath,
283+
ELFEmbeddingHelper.KnownEmbedItems.RuntimeConfig,
284+
EnvironmentOutputDirectory,
285+
missingContentOK: !haveRuntimeConfigBlob
286+
);
287+
275288
appConfigAsmGen = new ApplicationConfigNativeAssemblyGenerator (environmentVariables, systemProperties, Log) {
276289
UsesMonoAOT = usesMonoAOT,
277290
UsesMonoLLVM = EnableLLVM,

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

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
344344
<AndroidUseAssemblyStore Condition=" '$(AndroidUseAssemblyStore)' == '' and ('$(EmbedAssembliesIntoApk)' != 'true' or '$(AndroidIncludeDebugSymbols)' == 'true') ">false</AndroidUseAssemblyStore>
345345
<AndroidUseAssemblyStore Condition=" '$(AndroidUseAssemblyStore)' == '' ">true</AndroidUseAssemblyStore>
346346
<_AndroidUseAssemblyStore>$(AndroidUseAssemblyStore)</_AndroidUseAssemblyStore>
347+
348+
<_EmbedAssemblyStoreInRuntime Condition=" '$(_AndroidUseAssemblyStore)' == 'True' And '$(_AndroidEmbedAssemblyStoreInRuntime)' == 'True' ">true</_EmbedAssemblyStoreInRuntime>
349+
<_EmbedAssemblyStoreInRuntime Condition=" '$(_EmbedAssemblyStoreInRuntime)' != 'true' ">false</_EmbedAssemblyStoreInRuntime>
347350
</PropertyGroup>
348351

349352
<!-- For CoreCLR assembly stores are always on, individual assembly entries in the APK aren't supported.
@@ -1881,7 +1884,7 @@ because xbuild doesn't support framework reference assemblies.
18811884
DependsOnTargets="$(_GeneratePackageManagerJavaDependsOn)"
18821885
Inputs="@(_GeneratePackageManagerJavaInputs)"
18831886
Outputs="$(_AndroidStampDirectory)_GeneratePackageManagerJava.stamp">
1884-
1887+
18851888
<!-- Create java needed for Mono runtime -->
18861889
<GeneratePackageManagerJava
18871890
MainAssembly="$(TargetPath)"
@@ -1915,7 +1918,8 @@ because xbuild doesn't support framework reference assemblies.
19151918
EnableManagedMarshalMethodsLookup="$(_AndroidUseManagedMarshalMethodsLookup)"
19161919
CustomBundleConfigFile="$(AndroidBundleConfigurationFile)"
19171920
TargetsCLR="$(_AndroidUseCLR)"
1918-
ProjectRuntimeConfigFilePath="$(ProjectRuntimeConfigFilePath)">
1921+
ProjectRuntimeConfigFilePath="$(ProjectRuntimeConfigFilePath)"
1922+
AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)">
19191923
</GenerateNativeApplicationConfigSources>
19201924

19211925
<GenerateNativeMarshalMethodSources
@@ -1927,7 +1931,7 @@ because xbuild doesn't support framework reference assemblies.
19271931
SatelliteAssemblies="@(_AndroidResolvedSatellitePaths)"
19281932
SupportedAbis="@(_BuildTargetAbis)">
19291933
</GenerateNativeMarshalMethodSources>
1930-
1934+
19311935
<Touch Files="$(_AndroidStampDirectory)_GeneratePackageManagerJava.stamp" AlwaysCreate="True" />
19321936
<ItemGroup>
19331937
<FileWrites Include="@(_EnvironmentAssemblySource)" />
@@ -2336,7 +2340,7 @@ because xbuild doesn't support framework reference assemblies.
23362340
in monodroid.
23372341
-->
23382342
<CreateAssemblyStore
2339-
Condition=" '$(_AndroidRuntime)' != 'NativeAOT' "
2343+
Condition=" '$(_AndroidRuntime)' != 'NativeAOT' And '$(_EmbedAssemblyStoreInRuntime)' != 'True' "
23402344
AppSharedLibrariesDir="$(_AndroidApplicationSharedLibraryPath)"
23412345
IncludeDebugSymbols="$(AndroidIncludeDebugSymbols)"
23422346
ResolvedFrameworkAssemblies="@(_BuildApkResolvedFrameworkAssemblies)"
@@ -2347,7 +2351,7 @@ because xbuild doesn't support framework reference assemblies.
23472351
</CreateAssemblyStore>
23482352

23492353
<WrapAssembliesAsSharedLibraries
2350-
Condition=" '$(_AndroidRuntime)' != 'NativeAOT' "
2354+
Condition=" '$(_AndroidRuntime)' != 'NativeAOT' And '$(_EmbedAssemblyStoreInRuntime)' != 'True' "
23512355
AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)"
23522356
IncludeDebugSymbols="$(AndroidIncludeDebugSymbols)"
23532357
IntermediateOutputPath="$(IntermediateOutputPath)"
@@ -2374,17 +2378,6 @@ because xbuild doesn't support framework reference assemblies.
23742378
<Output TaskParameter="FilesToAddToArchive" ItemName="FilesToAddToArchive" />
23752379
</CollectJarContentFilesForArchive>
23762380

2377-
<!-- CoreCLR builds embed runtime config in libxamarin-app.so -->
2378-
<CollectRuntimeConfigFilesForArchive
2379-
Condition=" '$(_AndroidRuntime)' == 'MonoVM' "
2380-
AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)"
2381-
IntermediateOutputPath="$(IntermediateOutputPath)"
2382-
RuntimeConfigBinFilePath="$(_BinaryRuntimeConfigPath)"
2383-
SupportedAbis="@(_BuildTargetAbis)"
2384-
RuntimePackLibraryDirectories="@(_RuntimePackLibraryDirectory)">
2385-
<Output TaskParameter="FilesToAddToArchive" ItemName="FilesToAddToArchive" />
2386-
</CollectRuntimeConfigFilesForArchive>
2387-
23882381
<CollectNativeFilesForArchive
23892382
AndroidNdkDirectory="$(_AndroidNdkDirectory)"
23902383
ApkOutputPath="$(_ApkOutputPath)"

0 commit comments

Comments
 (0)