Skip to content

Commit

Permalink
[Xamarin.Android.Build.Tasks] simplify inputs to _CompileToDalvik (#2131
Browse files Browse the repository at this point in the history
)

Recently I've been discovering more and more places where usage of
`**\*.*` can hurt the performance of our build.

In this case, the `_FindCompiledJavaFiles` target:

    <Target Name="_FindCompiledJavaFiles" DependsOnTargets="_CompileJava">
        <CreateItem Include="$(IntermediateOutputPath)android\bin\classes\\**\*.class">
            <Output TaskParameter="Include" ItemName="_CompiledJavaFiles" />
        </CreateItem>
    </Target>

This target is running even in builds with no changes, so we are
*always* recursing directories and finding `*.class` files.

But since we are using a `classes.zip` file now, we don't need to
recurse and find the `*.class` files at all anymore!

I was able to remove this target completely, and change
`$(_CompileToDalvikInputs)` to use
`$(IntermediateOutputPath)android\bin\classes.zip`. Less inputs also
help build times, because MSBuild won't have to evaluate timestamps on
all the `*.class` files. It can just look at the single `classes.zip`
file.

To see the difference, a build with no changes was taking:

    46 ms  _FindCompiledJavaFiles                     1 calls
    15 ms  _CompileToDalvikWithDx                     1 calls

After these changes:

    4 ms  _CompileToDalvikWithDx                     1 calls

`_FindCompiledJavaFiles` is gone completely.

I also made sure to include `_CompileJava` in
`$(_CompileToDalvikDependsOnTargets)` in place of
`_FindCompiledJavaFiles`.
  • Loading branch information
jonathanpeppers authored and jonpryor committed Sep 5, 2018
1 parent 50a30aa commit d8e9a30
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2470,16 +2470,9 @@ because xbuild doesn't support framework reference assemblies.
</CreateItem>
</Target>

<Target Name="_FindCompiledJavaFiles" DependsOnTargets="_CompileJava">
<CreateItem
Include="$(IntermediateOutputPath)android\bin\classes\\**\*.class">
<Output TaskParameter="Include" ItemName="_CompiledJavaFiles" />
</CreateItem>
</Target>

<PropertyGroup>
<_CompileToDalvikDependsOnTargets>
_FindCompiledJavaFiles;
_CompileJava;
_GetMonoPlatformJarPath;
_GetAdditionalResourcesFromAssemblies;
_CreateAdditionalResourceCache;
Expand All @@ -2489,7 +2482,7 @@ because xbuild doesn't support framework reference assemblies.
$(MSBuildAllProjects)
;@(_JavaLibrariesToCompileForAppDx)
;@(AndroidExternalJavaLibrary)
;@(_CompiledJavaFiles)
;$(IntermediateOutputPath)android\bin\classes.zip
;@(ProguardConfiguration)
;@(MultiDexMainDexList)
;$(_AndroidBuildPropertiesCache)
Expand Down

0 comments on commit d8e9a30

Please sign in to comment.