Skip to content
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

[Android] Add NdkToolFinder task & Fix up AOT app build #88210

Merged
merged 3 commits into from
Jul 6, 2023

Conversation

steveisok
Copy link
Member

Since we bumped to NDK 23, having the aot compiler itself generate shared libraries stopped working. This is due to NDK 23 moving most of the toolchain into a common bin directory. AS was left over in each of these directories as an alias to bin/<triple>-as.

This change adds a task to collect all of the important NDK toolchain paths. It also fixes up the aot build when AOTWithLibraryFiles is set to true and we want the aot compiler to produce shared libraries.

Since we bumped to NDK 23, having the aot compiler itself generate shared libraries stopped working. This is due to NDK 23 moving most of the toolchain into a common bin directory. AS was left over in each of these directories as an alias to bin/<triple>-as.

This change adds a task to collect all of the important NDK toolchain paths. It also fixes up the aot build when `AOTWithLibraryFiles` is set to true and we want the aot compiler to produce shared libraries.
@steveisok
Copy link
Member Author

/azp run runtime-android

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

src/mono/msbuild/android/build/AndroidBuild.props Outdated Show resolved Hide resolved
: Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Android", "android-sdk", "ndk-bundle"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Android", "android-sdk", "ndk-bundle"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Android", "android-sdk", "ndk-bundle"),
@"C:\android-sdk-windows"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really want to support this path?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what XA checks for as a fallback, so I just lifted it.

:
new string[]
{
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Android", "sdk")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this just applies to OSX, not Linux so we should add an OS check.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a default for linux? There does not appear to be one in XA either.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't, I was thinking about adding an IsOSX check so we don't try this path which will never exist on Linux

src/tasks/MobileBuildTasks/Android/Ndk/Ndk.cs Outdated Show resolved Hide resolved
src/tasks/MobileBuildTasks/Android/Ndk/NdkTools.cs Outdated Show resolved Hide resolved
{
if (Ndk.NdkVersion.Main.Major != 23)
{
throw new Exception($"NDK 23 is required. An unsupported NDK version was found ({Ndk.NdkVersion.Main.Major}).");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it really the exact version? not >= ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, for now. I'll follow up with more broad support.

Copy link
Member

@fanyang-mono fanyang-mono left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/mono/sample/Android/AndroidSampleApp.csproj Outdated Show resolved Hide resolved
Steve Pfister added 2 commits July 5, 2023 13:04
@steveisok steveisok merged commit b3d2503 into dotnet:main Jul 6, 2023
177 checks passed
@steveisok steveisok deleted the add-ndk-mobile-build-tasks branch July 6, 2023 11:22
@ghost ghost locked as resolved and limited conversation to collaborators Aug 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants