Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions build-tools/scripts/Ndk.projitems.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<AndroidNdkApiLevel_X86 Condition=" '$(AndroidNdkApiLevel_X86)' == '' ">@NDK_X86_API_NET@</AndroidNdkApiLevel_X86>
<AndroidNdkApiLevel_X86_64 Condition=" '$(AndroidNdkApiLevel_X86_64)' == '' ">@NDK_X86_64_API@</AndroidNdkApiLevel_X86_64>
<AndroidNdkApiLevel_X64 Condition=" '$(AndroidNdkApiLevel_X64)' == '' ">@NDK_X86_64_API_NET@</AndroidNdkApiLevel_X64>
<AndroidNdkApiLevelNonMono_Arm64 Condition=" '$(AndroidNdkApiLevelNonMono_Arm64)' == '' ">@NDK_ARM64_V8A_API_NON_MONO@</AndroidNdkApiLevelNonMono_Arm64>
<AndroidNdkApiLevelNonMono_X64 Condition=" '$(AndroidNdkApiLevelNonMono_X64)' == '' ">@NDK_X86_64_API_NON_MONO@</AndroidNdkApiLevelNonMono_X64>
</PropertyGroup>

<ItemGroup>
Expand All @@ -30,6 +32,7 @@
Condition=" $(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':arm64-v8a:')) ">
<ApiLevel>$(AndroidNdkApiLevel_ArmV8a)</ApiLevel>
<ApiLevelNET>$(AndroidNdkApiLevel_Arm64)</ApiLevelNET>
<ApiLevelNonMono>$(AndroidNdkApiLevelNonMono_Arm64)</ApiLevelNonMono>
<AndroidRID>android-arm64</AndroidRID>
<SupportMonoVM>True</SupportMonoVM>
<SupportCoreCLR>True</SupportCoreCLR>
Expand All @@ -52,6 +55,7 @@
Condition=" $(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':x86_64:')) ">
<ApiLevel>$(AndroidNdkApiLevel_X86_64)</ApiLevel>
<ApiLevelNET>$(AndroidNdkApiLevel_X64)</ApiLevelNET>
<ApiLevelNonMono>$(AndroidNdkApiLevelNonMono_X64)</ApiLevelNonMono>
<AndroidRID>android-x64</AndroidRID>
<SupportMonoVM>True</SupportMonoVM>
<SupportCoreCLR>True</SupportCoreCLR>
Expand Down
2 changes: 2 additions & 0 deletions build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ GeneratedFile Get_Ndk_projitems (Context context)
{ "@NDK_X86_API_NET@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () },
{ "@NDK_X86_64_API@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () },
{ "@NDK_X86_64_API_NET@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () },
{ "@NDK_ARM64_V8A_API_NON_MONO@", BuildAndroidPlatforms.NdkMinimumNonMonoAPI },
{ "@NDK_X86_64_API_NON_MONO@", BuildAndroidPlatforms.NdkMinimumNonMonoAPI },
};

return new GeneratedPlaceholdersFile (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,46 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android.
<PropertyGroup>
<_NdkAbi Condition=" '$(RuntimeIdentifier)' == 'android-arm64' ">aarch64</_NdkAbi>
<_NdkAbi Condition=" '$(RuntimeIdentifier)' == 'android-x64' ">x86_64</_NdkAbi>
<_NDKApiLevel Condition=" '$(RuntimeIdentifier)' == 'android-arm64' ">$(AndroidNdkApiLevel_Arm64)</_NDKApiLevel>
<_NDKApiLevel Condition=" '$(RuntimeIdentifier)' == 'android-x64' ">$(AndroidNdkAPiLevel_X64)</_NDKApiLevel>
<_NdkSysrootAbi>$(_NdkAbi)-linux-android</_NdkSysrootAbi>
<_NdkPrebuiltAbi Condition=" $([MSBuild]::IsOSPlatform('windows')) ">windows-x86_64</_NdkPrebuiltAbi>
<_NdkPrebuiltAbi Condition=" $([MSBuild]::IsOSPlatform('osx')) ">darwin-x86_64</_NdkPrebuiltAbi>
<_NdkPrebuiltAbi Condition=" $([MSBuild]::IsOSPlatform('linux')) ">linux-x86_64</_NdkPrebuiltAbi>

<!-- We need to explicitly specify the extension on Windows, since some Android NDK versions
for Windows contain bash shell scripts without the extension, in addition to the
Windows-specific .cmd ones. We must use the latter since end users might not have bash
installed on Windows -->
<_NdkWrapperScriptExt Condition=" $([MSBuild]::IsOSPlatform('windows')) ">.cmd</_NdkWrapperScriptExt>
<_NdkSysrootDir>$(_AndroidNdkDirectory)toolchains/llvm/prebuilt/$(_NdkPrebuiltAbi)/sysroot/usr/lib/$(_NdkSysrootAbi)/</_NdkSysrootDir>
<_NdkBinDir>$(_AndroidNdkDirectory)toolchains/llvm/prebuilt/$(_NdkPrebuiltAbi)/bin/</_NdkBinDir>
<CppCompilerAndLinker>clang++</CppCompilerAndLinker>

<!--
Don't call `clang` directly, use the wrapper scripts instead since they properly pass
arguments required to link the application using the right API level libraries.
Using the script also makes it certain that we're not invoking a random `clang` in
from the system but rather the NDK one.

Also, we cannot use $(_NdkBinDir) here because, on Windows, the `Exec` task will get
confused by the forward slash in the path (even though it's a valid path separator
character on Windows) and signal the following error:

SetupOSSpecificProps:
where /Q "C:\Android\android-sdk\ndk\29.0.14206865\toolchains/llvm/prebuilt/windows-x86_64/bin/clang++"
1>EXEC : error : Invalid pattern is specified in "path:pattern".
The command "where /Q "C:\Android\android-sdk\ndk\29.0.14206865\toolchains/llvm/prebuilt/windows-x86_64/bin/clang++"" exited with code 2.

This could be fixed by making sure $(_NdkBinDir) path is fixed-up to use the canonical
form of path separation for the host OS, but it's simpler to just use the NDK-specific
compiler/linker wrapper script name.

Also, do NOT use `clang++` here because it will link the dynamic libc++ library into the
application. If, for some reason, `clang++` has to be used, `<LinkerArgs>` need to be
added to pass `-nostdlib` to it.
-->
<CppCompilerAndLinker>$(_NdkAbi)-linux-android$(_NDKApiLevel)-clang$(_NdkWrapperScriptExt)</CppCompilerAndLinker>
<CppLinker>$(_NdkAbi)-linux-android$(_NDKApiLevel)-clang$(_NdkWrapperScriptExt)</CppLinker>
<ObjCopyName>llvm-objcopy</ObjCopyName>

<!-- We must ensure this is `false`, as it would interfere with statically linking libc++ -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@
<!-- <_XACommonPropsReplacement Include="@NDK_PKG_REVISION@=$(AndroidNdkPkgRevision)" /> -->
<_XACommonPropsReplacement Include="@NDK_PKG_REVISION@=26.3.11579264" />
<_XACommonPropsReplacement Include="@NDK_ARM64_V8A_API@=$(AndroidNdkApiLevel_ArmV8a)" />
<_XACommonPropsReplacement Include="@NDK_ARM64_V8A_API_NON_MONO@=$(AndroidNdkApiLevelNonMono_Arm64)" />
<_XACommonPropsReplacement Include="@NDK_ARMEABI_V7_API@=$(AndroidNdkApiLevel_ArmV7a)" />
<_XACommonPropsReplacement Include="@NDK_X86_64_API@=$(AndroidNdkApiLevel_X86_64)" />
<_XACommonPropsReplacement Include="@NDK_X86_64_API_NON_MONO@=$(AndroidNdkApiLevelNonMono_X64)" />
<_XACommonPropsReplacement Include="@NDK_X86_API@=$(AndroidNdkApiLevel_X86)" />
<_XACommonPropsReplacement Include="@PACKAGE_VERSION_BUILD@=$(XAVersionCommitCount)" />
<_XACommonPropsReplacement Include="@PACKAGE_VERSION@=$(ProductVersion)" />
Expand Down
13 changes: 11 additions & 2 deletions src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,28 @@

<!-- Enable nuget package conflict resolution -->
<ResolveAssemblyConflicts>true</ResolveAssemblyConflicts>

<AndroidNdkApiLevel_Arm64>@NDK_ARM64_V8A_API_NON_MONO@</AndroidNdkApiLevel_Arm64>
<AndroidNdkApiLevel_X64>@NDK_X86_64_API_NON_MONO@</AndroidNdkApiLevel_X64>
</PropertyGroup>
<ItemGroup>
<AndroidMinimumSupportedApiLevel Include="armeabi-v7a">
<ApiLevel>@NDK_ARMEABI_V7_API@</ApiLevel>
</AndroidMinimumSupportedApiLevel>
<AndroidMinimumSupportedApiLevel Include="arm64-v8a">
<AndroidMinimumSupportedApiLevel Include="arm64-v8a" Condition=" '$(_AndroidRuntime)' == 'Mono' ">
<ApiLevel>@NDK_ARM64_V8A_API@</ApiLevel>
</AndroidMinimumSupportedApiLevel>
<AndroidMinimumSupportedApiLevel Include="arm64-v8a" Condition=" '$(_AndroidRuntime)' != 'Mono' ">
<ApiLevel>@NDK_ARM64_V8A_API_NON_MONO@</ApiLevel>
</AndroidMinimumSupportedApiLevel>
<AndroidMinimumSupportedApiLevel Include="x86">
<ApiLevel>@NDK_X86_API@</ApiLevel>
</AndroidMinimumSupportedApiLevel>
<AndroidMinimumSupportedApiLevel Include="x86_64">
<AndroidMinimumSupportedApiLevel Include="x86_64" Condition=" '$(_AndroidRuntime)' == 'Mono' ">
<ApiLevel>@NDK_X86_64_API@</ApiLevel>
</AndroidMinimumSupportedApiLevel>
<AndroidMinimumSupportedApiLevel Include="x86_64" Condition=" '$(_AndroidRuntime)' != 'Mono' ">
<ApiLevel>@NDK_X86_64_API_NON_MONO@</ApiLevel>
</AndroidMinimumSupportedApiLevel>
</ItemGroup>
</Project>