Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Xamarin.Android.Build.Tasks] $(AndroidNdkDirectory) is optional (#6539)
Context: #3299 Context: f0b1e8a Commit f0b1e8a updated the Xamarin.Android installation so that NDK tools required for Profiled AOT were redistributed as part of Xamarin.Android itself, removing the need to have an NDK installation in order to use Profiled AOT; this was principally the `*-ld` and `*-strip` utilities. (`*-as` were already bundled into Xamarin.Android via decfbcc.) However, in a classic "the left hand isn't necessarily communicating with the right hand" scenario, commit f0b1e8a didn't add any unit tests enforcing this, so if you *actually* tried to build an app with Profiled AOT when the NDK wasn't available, the build would fail: error XA5104: Could not locate the Android NDK. Please make sure the Android NDK is installed in the Android SDK Manager, or if using a custom NDK path, please ensure the $(AndroidNdkDirectory) MSBuild property is set to the custom path. Make it possible to build with AOT or Profiled AOT without the NDK: 1. Make a `NullNdkTools` class to use when an NDK is not found. 2. Make the NDK only actually required when `$(EnableLLVM)` is `true`. 3. Update our MSBuild tests so they leave the `$(AndroidNdkDirectory)` property blank. After these changes, I'm able to build apps with both normal AOT and Profiled AOT enabled, without having an Android NDK used. After this is merged, we might be able to make `Release` builds in .NET 6 default to using profiled AOT.
- Loading branch information
1 parent
5dcf294
commit c96d9f4
Showing
14 changed files
with
77 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/Xamarin.Android.Build.Tasks/Utilities/NdkTools/NullNdkTools.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#nullable enable | ||
using System; | ||
using Microsoft.Android.Build.Tasks; | ||
using Microsoft.Build.Utilities; | ||
using Xamarin.Android.Tools; | ||
|
||
namespace Xamarin.Android.Tasks | ||
{ | ||
class NullNdkTools : NdkTools | ||
{ | ||
public NullNdkTools (TaskLoggingHelper? log = null) : base (new NdkVersion (), log) | ||
{ | ||
log?.LogDebugMessage ("No Android NDK found"); | ||
} | ||
|
||
public override int GetMinimumApiLevelFor (AndroidTargetArch arch) => throw new NotImplementedException (); | ||
|
||
public override string GetToolPath (NdkToolKind kind, AndroidTargetArch arch, int apiLevel) => throw new NotImplementedException (); | ||
|
||
public override string GetToolPath (string name, AndroidTargetArch arch, int apiLevel) => throw new NotImplementedException (); | ||
|
||
public override bool ValidateNdkPlatform (Action<string> logMessage, Action<string, string> logError, AndroidTargetArch arch, bool enableLLVM) => throw new NotImplementedException (); | ||
|
||
protected override string GetPlatformIncludeDirPath (AndroidTargetArch arch, int apiLevel) => throw new NotImplementedException (); | ||
} | ||
} |