Skip to content

[native] Runtime linking at app build time #9006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 53 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
4d1e0ea
First steps towards native runtime linking at app build time
grendello Jun 5, 2024
87e4274
The basics
grendello Jun 6, 2024
4c0e011
More linker command line work
grendello Jun 7, 2024
34a1a8e
Actually linking now
grendello Jun 10, 2024
846be3f
Bump binutils to 18.1.7-8.0.0
grendello Jun 12, 2024
ff41900
Package more library stubs
grendello Jun 21, 2024
de23b8a
Extract debug symbols at link time
grendello Jun 24, 2024
9b02b87
First steps towards p/invoke usage scanner
grendello Jun 25, 2024
bec9189
Fixlet + register scan results
grendello Jun 25, 2024
0828d50
[wip] p/invoke preservation source code generator
grendello Jul 1, 2024
f88da48
AndroidAsyncTask -> AsyncTask
grendello Jul 9, 2024
e9ed1fc
Prepare for new p/invoke code, step #3
grendello Jul 10, 2024
83fb4d9
Let's see what breaks
grendello Jul 16, 2024
6177204
Update the list of p/invokes, slight generated code changes
grendello Jul 16, 2024
4f5a86b
Formatting
grendello Jul 16, 2024
71f70a9
Fix post-rebase issues and conflicts
grendello Jul 23, 2024
7b561dc
Update TODO
grendello Jul 23, 2024
4f53281
Post-rebase fixes
grendello Jul 24, 2024
ab1bb21
Some post-rebase fixups
grendello Aug 27, 2024
03abff9
Try to make it work at run time
grendello Aug 29, 2024
c221d82
Moar linking ahead
grendello Aug 30, 2024
342e927
Unified runtime is properly linked now
grendello Sep 2, 2024
571f1ce
Stuff
grendello Sep 2, 2024
b6e2298
XA hello world works
grendello Sep 3, 2024
d7f3272
Benchmarking before implementation
grendello Sep 4, 2024
105d44a
Beginnings of real code generation
grendello Sep 5, 2024
56e1096
Code generation progress
grendello Sep 6, 2024
23252f8
Generated find_pinvoke code appears to be correct
grendello Sep 9, 2024
18f1d14
Linking works as expected
grendello Sep 9, 2024
81d2c3a
Hide almost all the exported symbols
grendello Sep 9, 2024
bff1425
Hide `find_pinvoke`
grendello Sep 9, 2024
2db6296
Don't enable runtime linking in debug builds
grendello Sep 10, 2024
18e8f4c
Temporarily include `libunwind.a` from the NDK toolchain
grendello Sep 10, 2024
a9b5e3b
Use the right version of the LLVM toolchain
grendello Sep 10, 2024
3daf433
Tweak some tests to run with the unified runtime
grendello Sep 11, 2024
2f38764
Instant run is no more
grendello Sep 11, 2024
6c1c742
Try to fix some tests
grendello Sep 12, 2024
a0c671f
_LinkNativeRuntime must be called earlier
grendello Sep 13, 2024
6f06c21
Post-rebase fixups
grendello Sep 13, 2024
71749a9
Don't ignore method-less types when scanning
grendello Sep 13, 2024
6776200
Let's see if this works
grendello Sep 16, 2024
dd9fbba
Mono.Android-Tests might work now
grendello Sep 17, 2024
0025d34
This might fix the GenerateJavaStubsAndAssembly test
grendello Sep 17, 2024
4dee599
AOT profiling won't work with dynamic runtime linking
grendello Sep 18, 2024
d216289
Fix some post-rebase errors
grendello Oct 1, 2024
cb678cf
Don't package BCL libraries when linking dynamically
grendello Oct 2, 2024
f25989f
Add some debug messages
grendello Oct 2, 2024
fd0406e
Accept all the libs when not linking
grendello Oct 3, 2024
130514d
Make runtime linking an option in the DotNetBuild test
grendello Oct 3, 2024
dcf6fb5
Don't test dynamic linking in here
grendello Oct 3, 2024
3bd5c59
Not needed anymore
grendello Oct 16, 2024
327687c
Post-rebase fixes
grendello Oct 16, 2024
81a7369
Still needed, after all
grendello Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions NativeLinkingTODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Problems to solve

* `libSystem.Security.Cryptography.Native.Android.a` contains the `JNI_OnLoad` function
which initializes the whole crypto support library, but we can't use it as it would
conflict with our own. Potential solution is to modify the above library's source code
to add an init function that we will call from our own `JNI_OnLoad` and make the library's
init function do the same. The `JNI_OnLoad` object file would have to be omitted from the
library's `.a`
* `p/invoke usage`.
Currently, all the BCL archives (with exception of the above crypto one) are
linked into the unified runtime using `--whole-archive` - that is, they become part of the
runtime in their entirety. This is wasteful, but necessary, so that `p/invokes` into those
libraries work correctly. Instead, we should scan the application DLLs for p/invokes from
those libraries and generate code to reference the required functions, so that the linker
can do its job and remove code not used by the application. Likely needed is a linker step.
* `p/invoke` handling mechanism. Right now, we `dlopen` the relevant `.so` library and look
up the required symbol in there. With the unified runtime the `.so` disappears, so we either
need to look it up in our own library or, better, call the function directly. The latter is
a bit more complicated to implement but would give us much faster code, thus it's the preferred
solution.

# Helpers

* linker can output a list of pinvokes, see https://github.com/dotnet/android/issues/7114

# Ideas

* Use [mold](https://github.com/rui314/mold) which has recently been re-licensed under `MIT/X11`
(and contains components licensed under a mixture of `BSD*` and `Apache 2.0` licenses), so we
can easily redistribute it instead of the LLVM's `lld`. The advantage is `mold`'s [speed](https://github.com/rui314/mold?tab=readme-ov-file#mold-a-modern-linker)
15 changes: 14 additions & 1 deletion build-tools/create-packs/Microsoft.Android.Runtime.proj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,20 @@ projects that use the Microsoft.Android framework in .NET 6+.
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libmono-android.release.so" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libxamarin-debug-app-helper.so" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libxamarin-native-tracing.so" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libunwind_xamarin.a" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libunwind_xamarin-release.a" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libruntime-base-release.a" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libxa-java-interop-release.a" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libxa-lz4-release.a" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libxa-shared-bits-release.a" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libmono-android.release-static-release.a" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libpinvoke-override-dynamic-release.a" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\crtbegin_so.o" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\crtend_so.o" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libclang_rt.builtins-*-android.a" />

<!-- Remove once https://github.com/dotnet/runtime/pull/107615 is merged and released -->
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libunwind.a" />

<FrameworkListFileClass Include="@(_AndroidRuntimePackAssemblies->'%(Filename)%(Extension)')" Profile="Android" />
<FrameworkListFileClass Include="@(_AndroidRuntimePackAssets->'%(Filename)%(Extension)')" Profile="Android" />
</ItemGroup>
Expand Down
12 changes: 12 additions & 0 deletions build-tools/installers/create-installers.targets
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,29 @@
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)ELFSharp.dll" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)ManifestOverlays\Timing.xml" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm64\libc.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm64\libdl.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm64\liblog.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm64\libm.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm64\libz.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm\libc.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm\libdl.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm\liblog.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm\libm.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-arm\libz.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x64\libc.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x64\libdl.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x64\liblog.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x64\libm.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x64\libz.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x86\libc.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x86\libdl.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x86\liblog.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x86\libm.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)dsostubs\android-arm64\libarchive-dso-stub.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)dsostubs\android-arm\libarchive-dso-stub.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)dsostubs\android-x64\libarchive-dso-stub.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)dsostubs\android-x86\libarchive-dso-stub.so" />
<_MSBuildFiles Include="$(MicrosoftAndroidSdkOutDir)libstubs\android-x86\libz.so" />
</ItemGroup>
<ItemGroup>
<_MSBuildTargetsSrcFiles Include="$(MSBuildTargetsSrcDir)\Xamarin.Android.AvailableItems.targets" />
Expand Down
33 changes: 33 additions & 0 deletions build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,37 @@ public static partial class Defaults
{ "x86_64", "x86_64-linux-android" },
};

public static readonly Dictionary<string, string> AbiToRID = new (StringComparer.Ordinal) {
{ "armeabi-v7a", "android-arm" },
{ "arm64-v8a", "android-arm64" },
{ "x86", "android-x86" },
{ "x86_64", "android-x64" },
};

public static readonly Dictionary<string, string> AbiToClangArch = new (StringComparer.Ordinal) {
{ "armeabi-v7a", "arm" },
{ "arm64-v8a", "aarch64" },
{ "x86", "i686" },
{ "x86_64", "x86_64" },
};

/// <summary>
/// Used in rules.mk generator. Files to include in the XA bundle archives.
/// </summary>
public static readonly List <string> BundleZipsInclude = new List <string> {
"$(ZIP_OUTPUT_BASENAME)/THIRD-PARTY-NOTICES.TXT",
"$(ZIP_OUTPUT_BASENAME)/bin/Debug",
"$(ZIP_OUTPUT_BASENAME)/bin/Release",
};

/// <summary>
/// Used in rules.mk generator. Files to exclude from the XA bundle archives. Must be syntactically
/// correct for GNU Make.
/// </summary>
public static readonly List <string> BundleZipsExclude = new List <string> {
"$(ZIP_OUTPUT_BASENAME)/bin/*/bundle-*.zip"
};

public static readonly List <NDKTool> NDKTools = new List<NDKTool> {
// Tools prefixed with architecture triple
new NDKTool (name: "as", prefixed: true),
Expand Down Expand Up @@ -220,6 +251,7 @@ public static partial class Paths
// Other
public static string AndroidNdkDirectory => ctx.Properties.GetRequiredValue (KnownProperties.AndroidNdkDirectory);
public static string AndroidToolchainRootDirectory => GetCachedPath (ref androidToolchainRootDirectory, () => Path.Combine (AndroidNdkDirectory, "toolchains", "llvm", "prebuilt", NdkToolchainOSTag));
public static string AndroidClangRootDirectory => GetCachedPath (ref androidClangRootDirectory, () => Path.Combine (AndroidToolchainRootDirectory, "lib", "clang"));
public static string AndroidToolchainBinDirectory => GetCachedPath (ref androidToolchainBinDirectory, () => Path.Combine (AndroidToolchainRootDirectory, "bin"));
public static string AndroidToolchainSysrootLibDirectory => GetCachedPath (ref androidToolchainSysrootLibDirectory, () => Path.Combine (AndroidToolchainRootDirectory, "sysroot", "usr", "lib"));
public static string WindowsBinutilsInstallDir => GetCachedPath (ref windowsBinutilsInstallDir, () => Path.Combine (InstallMSBuildDir, "binutils"));
Expand Down Expand Up @@ -264,6 +296,7 @@ static string GetCachedPath (ref string? variable, Func<string> creator)
static string? buildBinDir;
static string? binDir;
static string? androidToolchainRootDirectory;
static string? androidClangRootDirectory;
static string? androidToolchainBinDirectory;
static string? androidToolchainSysrootLibDirectory;
static string? installMSBuildDir;
Expand Down
70 changes: 70 additions & 0 deletions build-tools/xaprepare/xaprepare/Steps/Step_Android_SDK_NDK.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -151,13 +152,82 @@ bool AcceptLicenses (Context context, string sdkRoot)

bool GatherNDKInfo (Context context)
{
if (!CopyRedistributableFiles (context)) {
return false;
}

// Ignore NDK property setting if not installing the NDK
if (!DependencyTypeToInstall.HasFlag (AndroidToolchainComponentType.BuildDependency))
return true;
else
return context.BuildInfo.GatherNDKInfo (context);
}

bool CopyRedistributableFiles (Context context)
{
string androidVersionPath = Path.Combine (Configurables.Paths.AndroidToolchainRootDirectory, "AndroidVersion.txt");
if (!File.Exists (androidVersionPath)) {
throw new InvalidOperationException ($"Android version file '{androidVersionPath}' not found");
}

string[]? lines = File.ReadAllLines (androidVersionPath);
if (lines == null || lines.Length < 1) {
throw new InvalidOperationException ($"Unknown format of Android version file '{androidVersionPath}'");
}

// First line is (should be) the LLVM version, we need just the main release number
string[] llvmVersion = lines[0].Split ('.');
if (llvmVersion.Length < 3) {
throw new InvalidOperationException ($"Unknown LLVM version format for '{lines[0]}'");
}

string clangLibPath = Path.Combine (
Configurables.Paths.AndroidClangRootDirectory,
llvmVersion[0],
"lib",
"linux"
);

foreach (var kvp in Configurables.Defaults.AndroidToolchainPrefixes) {
string abi = kvp.Key;

string crtFilesPath = Path.Combine (
Configurables.Paths.AndroidToolchainSysrootLibDirectory,
kvp.Value,
BuildAndroidPlatforms.NdkMinimumAPI.ToString (CultureInfo.InvariantCulture)
);

string clangArch = Configurables.Defaults.AbiToClangArch[abi];
CopyFile (abi, crtFilesPath, "crtbegin_so.o");
CopyFile (abi, crtFilesPath, "crtend_so.o");
CopyFile (abi, clangLibPath, $"libclang_rt.builtins-{clangArch}-android.a");

// Yay, consistency
if (String.Compare (clangArch, "i686", StringComparison.Ordinal) == 0) {
clangArch = "i386";
}

// Remove once https://github.com/dotnet/runtime/pull/107615 is merged and released
CopyFile (abi, Path.Combine (clangLibPath, clangArch), "libunwind.a");
}

return true;

void CopyFile (string abi, string sourceDir, string fileName)
{
Log.StatusLine ($" {context.Characters.Bullet} Copying NDK redistributable: ", $"{fileName} ({abi})", tailColor: ConsoleColor.White);
string rid = Configurables.Defaults.AbiToRID [abi];
string outputDir = Path.Combine (
context.Properties.GetRequiredValue (KnownProperties.MicrosoftAndroidSdkOutDir),
"lib",
rid
);

string sourceFile = Path.Combine (sourceDir, fileName);
Utilities.CopyFileToDir (sourceFile, outputDir);
}
}

void CheckPackageStatus (Context context, string packageCacheDir, AndroidPackage pkg, List <AndroidPackage> toDownload)
{
Log.StatusLine ($" {context.Characters.Bullet} Installing ", pkg.Component.Name, tailColor: ConsoleColor.White);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ This file is imported *after* the Microsoft.NET.Sdk/Sdk.targets.
<Import Project="Microsoft.Android.Sdk.Aot.targets" Condition=" '$(AndroidApplication)' == 'true' " />
<Import Project="Microsoft.Android.Sdk.Application.targets" Condition=" '$(AndroidApplication)' == 'true' " />
<Import Project="Microsoft.Android.Sdk.AssemblyResolution.targets" />

<!-- This one must be imported after `Microsoft.Android.Sdk.AssemblyResolution.targets` -->
<Import Project="Microsoft.Android.Sdk.NativeRuntime.targets" Condition=" '$(AndroidApplication)' == 'true' " />
<Import Project="Microsoft.Android.Sdk.ILLink.targets" />
<Import Project="Microsoft.Android.Sdk.ProjectCapabilities.targets" />
<Import Project="Microsoft.Android.Sdk.Publish.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,17 @@ _ResolveAssemblies MSBuild target.
</ItemGroup>
</Target>

<Target Name="_IncludeNativeSystemLibraries">
<Target Name="_PrepareMonoComponentItems">
<ItemGroup>
<_MonoComponent Condition=" '$(AndroidEnableProfiler)' == 'true' " Include="diagnostics_tracing" />
<_MonoComponent Condition=" '$(AndroidUseInterpreter)' == 'true' " Include="hot_reload" />
<_MonoComponent Condition=" '$(AndroidIncludeDebugSymbols)' == 'true' " Include="debugger" />
<_MonoComponent Condition=" '$(_AndroidExcludeMarshalIlgenComponent)' != 'true' " Include="marshal-ilgen" />
</ItemGroup>
</Target>

<Target Name="_IncludeNativeSystemLibraries"
DependsOnTargets="_PrepareMonoComponentItems">
<PropertyGroup>
<_AndroidIncludeSystemGlobalizationNative Condition=" '$(_AndroidIncludeSystemGlobalizationNative)' == '' ">true</_AndroidIncludeSystemGlobalizationNative>
<_AndroidEnableNativeStackTracing Condition=" '$(_AndroidEnableNativeStackTracing)' == ''">false</_AndroidEnableNativeStackTracing>
Expand All @@ -225,15 +235,12 @@ _ResolveAssemblies MSBuild target.
<_ResolvedNativeLibraries Include="@(ResolvedFileToPublish)" Condition=" '%(ResolvedFileToPublish.Extension)' == '.so' " />
</ItemGroup>
<ItemGroup>
<_MonoComponent Condition=" '$(AndroidEnableProfiler)' == 'true' " Include="diagnostics_tracing" />
<_MonoComponent Condition=" '$(AndroidUseInterpreter)' == 'true' " Include="hot_reload" />
<_MonoComponent Condition=" '$(AndroidIncludeDebugSymbols)' == 'true' " Include="debugger" />
<_MonoComponent Condition=" '$(_AndroidExcludeMarshalIlgenComponent)' != 'true' " Include="marshal-ilgen" />
<!-- Filename without extension -->
<_ExcludedNativeLibraries Condition=" '$(_AndroidIncludeSystemGlobalizationNative)' != 'true' " Include="libSystem.Globalization.Native" />
<_ExcludedNativeLibraries Condition=" '$(_AndroidEnableNativeStackTracing)' != 'true' " Include="libxamarin-native-tracing" />
</ItemGroup>
<ProcessNativeLibraries
NativeRuntimeLinking="$(_AndroidEnableNativeRuntimeLinking)"
InputLibraries="@(_ResolvedNativeLibraries)"
ExcludedLibraries="@(_ExcludedNativeLibraries)"
Components="@(_MonoComponent->Distinct())"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ properties that determine build ordering.
_ReadAndroidManifest;
_CompileJava;
_CreateApplicationSharedLibraries;
_LinkNativeRuntime;
_CompileDex;
$(_AfterCompileDex);
_CreateBaseApk;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!--
***********************************************************************************************
Microsoft.Android.Sdk.NativeRuntime.targets

Contains code to build and link the native runtime at application build time.

***********************************************************************************************
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="Xamarin.Android.Tasks.GetNativeRuntimeComponents" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />
<UsingTask TaskName="Xamarin.Android.Tasks.LinkNativeRuntime" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />

<Target Name="_PrepareUnifiedNativeRuntimeItems"
Condition=" '$(_AndroidEnableNativeRuntimeLinking)' == 'true' ">
<ItemGroup>
<_UnifiedNativeRuntime Include="$(_AndroidApplicationSharedLibraryPath)%(_BuildTargetAbis.Identity)\libmonodroid-unified.so">
<abi>%(_BuildTargetAbis.Identity)</abi>
<ArchiveFileName>libmonodroid.so</ArchiveFileName>
</_UnifiedNativeRuntime>
</ItemGroup>

<ItemGroup>
<_ResolvedNativeArchive Include="@(ResolvedFileToPublish)" Condition=" '%(ResolvedFileToPublish.Extension)' == '.a' " />
<_ResolvedNativeObjectFile Include="@(ResolvedFileToPublish)" Condition=" '%(ResolvedFileToPublish.Extension)' == '.o' " />
<_ApplicationSharedLibrary Include="@(_UnifiedNativeRuntime)" />
</ItemGroup>

<GetNativeRuntimeComponents
MonoComponents="@(_MonoComponent)"
ResolvedNativeObjectFiles="@(_ResolvedNativeObjectFile)"
ResolvedNativeArchives="@(_ResolvedNativeArchive)">
<Output TaskParameter="NativeArchives" ItemName="_SelectedNativeArchive" />
<Output TaskParameter="RequiredLibraries" ItemName="_RequiredLinkLibraries" />
<Output TaskParameter="LinkStartFiles" ItemName="_NativeLinkStartFiles" />
<Output TaskParameter="LinkEndFiles" ItemName="_NativeLinkEndFiles" />
<Output TaskParameter="NativeSymbolsToExport" ItemName="_NativeSymbolsToExport" />
</GetNativeRuntimeComponents>
</Target>

<Target Name="_LinkNativeRuntime"
DependsOnTargets="_PrepareMonoComponentItems;_CompileNativeAssemblySources;_PrepareUnifiedNativeRuntimeItems"
Inputs="@(_NativeAssemblyTarget);@(_SelectedNativeArchive)"
Outputs="@(_UnifiedNativeRuntime)"
Condition=" '$(_AndroidEnableNativeRuntimeLinking)' == 'true' ">
<LinkNativeRuntime
MonoComponents="@(_MonoComponent)"
AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)"
IntermediateOutputPath="$(IntermediateOutputPath)"
NativeArchives="@(_SelectedNativeArchive)"
NativeObjectFiles="@(_NativeAssemblyTarget)"
NativeLinkStartFiles="@(_NativeLinkStartFiles)"
NativeLinkEndFiles="@(_NativeLinkEndFiles)"
NativeSymbolsToExport="@(_NativeSymbolsToExport)"
LinkLibraries="@(_RequiredLinkLibraries)"
OutputRuntimes="@(_UnifiedNativeRuntime)"
SupportedAbis="@(_BuildTargetAbis)"
SaveDebugSymbols="true" />

<ItemGroup>
<FileWrites Include="@(_UnifiedNativeRuntime)" />
</ItemGroup>
</Target>
</Project>
Loading
Loading