-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[XABT] Refactor manifest merging and ACW map generation out of `Gener…
…ateJavaStubs`. (#9827) Begin breaking down the `<GenerateJavaStubs>` task into smaller, more manageable pieces by moving the manifest merging and ACW map generation into separate tasks. Once this is complete, we should be able to start moving these steps that require Cecil assembly scanning into linker steps (or equivalent), eventually saving a Cecil assembly scan per build. Additionally, create a new `GetProjectBuildSpecificTaskObjectKey` to be used with `GetRegisteredTaskObject`. This version additional uses `$(IntermediateOutpuPath)` in the key to help ensure data from multi-targeted builds (`net8.0-android,net9.0-android`) is not overwritten.
- Loading branch information
Showing
6 changed files
with
308 additions
and
192 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#nullable enable | ||
using System.Collections.Concurrent; | ||
using System.Linq; | ||
using Microsoft.Android.Build.Tasks; | ||
using Microsoft.Build.Framework; | ||
using Xamarin.Android.Tools; | ||
|
||
namespace Xamarin.Android.Tasks; | ||
|
||
public class GenerateACWMap : AndroidTask | ||
{ | ||
public override string TaskPrefix => "ACW"; | ||
|
||
[Required] | ||
public string AcwMapFile { get; set; } = ""; | ||
|
||
[Required] | ||
public string IntermediateOutputDirectory { get; set; } = ""; | ||
|
||
public override bool RunTask () | ||
{ | ||
// Retrieve the stored NativeCodeGenState | ||
var nativeCodeGenStates = BuildEngine4.GetRegisteredTaskObjectAssemblyLocal<ConcurrentDictionary<AndroidTargetArch, NativeCodeGenState>> ( | ||
MonoAndroidHelper.GetProjectBuildSpecificTaskObjectKey (GenerateJavaStubs.NativeCodeGenStateRegisterTaskKey, WorkingDirectory, IntermediateOutputDirectory), | ||
RegisteredTaskObjectLifetime.Build | ||
); | ||
|
||
// We only need the first architecture, since this task is architecture-agnostic | ||
var templateCodeGenState = nativeCodeGenStates.First ().Value; | ||
|
||
var acwMapGen = new ACWMapGenerator (Log); | ||
|
||
if (!acwMapGen.Generate (templateCodeGenState, AcwMapFile)) { | ||
Log.LogDebugMessage ("ACW map generation failed"); | ||
} | ||
|
||
if (Log.HasLoggedErrors) { | ||
// Ensure that on a rebuild, we don't *skip* the `_GenerateJavaStubs` target, | ||
// by ensuring that the target outputs have been deleted. | ||
Files.DeleteFile (AcwMapFile, Log); | ||
} | ||
|
||
return !Log.HasLoggedErrors; | ||
} | ||
} |
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
Oops, something went wrong.