Skip to content

Make sure _GenerateJavaStubs always generates native assembly files #9001

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

Closed
wants to merge 3 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ because xbuild doesn't support framework reference assemblies.
<Target Name="_GenerateJavaStubs"
DependsOnTargets="$(_GenerateJavaStubsDependsOnTargets);$(BeforeGenerateAndroidManifest)"
Inputs="@(_AndroidMSBuildAllProjects);@(_ResolvedUserMonoAndroidAssemblies);$(_AndroidManifestAbs);$(_AndroidBuildPropertiesCache);@(AndroidEnvironment);@(LibraryEnvironments)"
Outputs="$(_AndroidStampDirectory)_GenerateJavaStubs.stamp">
Outputs="$(_AndroidStampDirectory)_GenerateJavaStubs.stamp;@(_TypeMapAssemblySource)">

<PropertyGroup>
<_ManifestOutput Condition=" '$(AndroidManifestMerger)' == 'legacy' ">$(IntermediateOutputPath)android\AndroidManifest.xml</_ManifestOutput>
Expand Down Expand Up @@ -1509,6 +1509,7 @@ because xbuild doesn't support framework reference assemblies.
<FileWrites Include="$(_ManifestOutput)" />
</ItemGroup>

<Touch Files="@(_TypeMapAssemblySource)" />
Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, do we know what deleted @(_TypeMapAssemblySource)? Are they missing from FileWrites?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's the problem, we have no idea why they are gone. The guess is that some earlier build deleted them (DTB perhaps?) which we don't have build logs for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regardless of what made the files disappear, I don't think a stamp file in Outputs is enough, at least in this case. The task inside the target produces files, and we must make sure that those files exist (whether they were removed by us for some reason, or by the developer) and so they must be part of the outputs.

Copy link
Contributor

Choose a reason for hiding this comment

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

So I wonder if it is this.

Because the _TypeMapAssemblySource are generated via a Task. If the task does not run, the _TypeMapAssemblySource will be empty.

On a DTB is _GeneratedJavaStubs is skipped the task filling in the _TypeMapAssemblySource ItemGroup will be empty. As a result the FileWrites entry will not include the files.

In the case where the Task is not run, we need a way to populate the _TypeMapAssemblySource from the files on disk to make sure they are not deleted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have this chain of dependencies:

<Target Name="_PrepareNativeAssemblySources">
  <PrepareAbiItems
      BuildTargetAbis="@(_BuildTargetAbis)"
      NativeSourcesDir="$(_NativeAssemblySourceDir)"
      InstantRunEnabled="$(_InstantRunEnabled)"
      Debug="$(AndroidIncludeDebugSymbols)"
      Mode="typemap">
    <Output TaskParameter="AssemblySources" ItemName="_TypeMapAssemblySource" />
    <Output TaskParameter="AssemblyIncludes" ItemName="_TypeMapAssemblyInclude" />
  </PrepareAbiItems>
</Target>

<PropertyGroup>
  <_GenerateJavaStubsDependsOnTargets>
    _SetLatestTargetFrameworkVersion;
    _PrepareAssemblies;
    _PrepareNativeAssemblySources;
    $(_AfterPrepareAssemblies);
  </_GenerateJavaStubsDependsOnTargets>
</PropertyGroup>

<Target Name="_GenerateJavaStubs"
    DependsOnTargets="$(_GenerateJavaStubsDependsOnTargets);$(BeforeGenerateAndroidManifest)"
    Inputs="@(_AndroidMSBuildAllProjects);@(_ResolvedUserMonoAndroidAssemblies);$(_AndroidManifestAbs);$(_AndroidBuildPropertiesCache);@(AndroidEnvironment);@(LibraryEnvironments)"
    Outputs="$(_AndroidStampDirectory)_GenerateJavaStubs.stamp">

Will _PrepareNativeAssemblySources be ignored when _GenerateJavaStubs Outputs are deemed up to date?

<Touch Files="$(_AndroidStampDirectory)_GenerateJavaStubs.stamp" AlwaysCreate="True" />
</Target>

Expand Down
Loading