Skip to content

Commit

Permalink
[Xamarin.Android.Build.Tasks] fix incremental builds for `_GenerateAn…
Browse files Browse the repository at this point in the history
…droidRemapNativeCode` (#9548)

I've noticed we are randomly seeing a test failure like:

	Build_AndroidResource_Change
	Exceeded expected time of 2250ms, actual 2992.086ms

Sometimes, it passes and sometimes not.

Reviewing the `.binlog` I noticed under the top 10 expensive tasks:

	GenerateJniRemappingNativeCode = 97 ms, 1 calls.

Which I found by the target:

	_GenerateEmptyAndroidRemapNativeCode
	Building target "_GenerateEmptyAndroidRemapNativeCode" completely.
	Input file "/Users/runner/work/1/a/TestRelease/11-21_21.07.33/temp/BuildAndroidResourceChange/UnnamedProject.csproj" is newer than output file "obj/Debug/android/jni_remap.x86_64.ll".

Which has the `Inputs/Outputs`:

	Inputs="$(MSBuildProjectFullPath)"
	Outputs="@(_AndroidRemapAssemblySource)"

Reviewing the target, it feels like we should fix the `Inputs` and
`Outputs`, such as:

  * `Inputs` should include all MSBuild files
    `@(_AndroidMSBuildAllProjects)`, as settings could be in
    `Directory.Build.props`, etc.

  * `Inputs` should include `build.props` if that file changes to
    force a rerun.

  * We should `<Touch/>` the `Outputs` files to prevent the target
    from running when it doesn't need to.

After these changes, I'm hoping `Build_AndroidResource_Change` passes
more reliably, we will see.
  • Loading branch information
jonathanpeppers authored Nov 26, 2024
1 parent 87a7947 commit 406e43b
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1639,13 +1639,14 @@ because xbuild doesn't support framework reference assemblies.
<Target Name="_GenerateEmptyAndroidRemapNativeCode"
DependsOnTargets="_PrepareAndroidRemapNativeAssemblySources"
Condition=" '@(_AndroidRemapMembers->Count())' == '0' "
Inputs="$(MSBuildProjectFullPath)"
Inputs="$(_AndroidBuildPropertiesCache);@(_AndroidMSBuildAllProjects)"
Outputs="@(_AndroidRemapAssemblySource)">
<GenerateJniRemappingNativeCode
OutputDirectory="$(_NativeAssemblySourceDir)"
GenerateEmptyCode="True"
SupportedAbis="@(_BuildTargetAbis)"
/>
<Touch Files="@(_AndroidRemapAssemblySource)" />
</Target>

<PropertyGroup>
Expand All @@ -1659,13 +1660,14 @@ because xbuild doesn't support framework reference assemblies.
<Target Name="_GenerateAndroidRemapNativeCode"
DependsOnTargets="$(_GenerateAndroidRemapNativeCodeDependsOn)"
Condition=" '@(_AndroidRemapMembers->Count())' != '0' "
Inputs="$(_XARemapMembersFilePath)"
Inputs="$(_AndroidBuildPropertiesCache);@(_AndroidMSBuildAllProjects);$(_XARemapMembersFilePath)"
Outputs="@(_AndroidRemapAssemblySource)">
<GenerateJniRemappingNativeCode
OutputDirectory="$(_NativeAssemblySourceDir)"
RemappingXmlFilePath="$(_XARemapMembersFilePath)"
SupportedAbis="@(_BuildTargetAbis)"
/>
<Touch Files="@(_AndroidRemapAssemblySource)" />
</Target>

<Target Name="_RunAotForAllRIDs"
Expand Down

0 comments on commit 406e43b

Please sign in to comment.