Skip to content

Commit bc1a818

Browse files
[build] option for Java.Interop to be built as non-PCL
Fixes: http://work.devdiv.io/667174 When building a "Hello World" Xamarin.Android app, I noticed the following in the build log: Adding assembly reference for Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065, recursively... Adding assembly reference for System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.ComponentModel.Composition, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, recursively... Adding assembly reference for System.Diagnostics.Debug, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Threading, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Collections, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Collections.Concurrent, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Reflection, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Reflection.Primitives, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Dynamic.Runtime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.ObjectModel, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Linq, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Runtime.InteropServices, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Runtime.Extensions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for System.Reflection.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively... Adding assembly reference for Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065, recursively... It appears that Java.Interop is a PCL, and we end up having to work with lots of facade assemblies during our build! My thought is that we should build `Java.Interop.dll` the same as `Mono.Android.dll`: <PropertyGroup> <NoStdLib>true</NoStdLib> </PropertyGroup> <ItemGroup> <Reference Include="mscorlib"> <HintPath>$(XAInstallPrefix)xbuild-frameworks\MonoAndroid\v1.0\mscorlib.dll</HintPath> <Private>False</Private> </Reference> <Reference Include="System"> <HintPath>$(XAInstallPrefix)xbuild-frameworks\MonoAndroid\v1.0\System.dll</HintPath> <Private>False</Private> </Reference> <Reference Include="System.Core"> <HintPath>$(XAInstallPrefix)xbuild-frameworks\MonoAndroid\v1.0\System.Core.dll</HintPath> <Private>False</Private> </Reference> </ItemGroup> I added a new property, `$(JavaInteropProfile)` we can set downstream in Xamarin.Android. We can set this with a `Configuration.Override.props` file that is already used in Xamarin.Android's build process. After doing this, the log now reads: Adding assembly reference for Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065, recursively... Adding assembly reference for Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065, recursively... And the savings in build times for "Hello World", this is the `Rebuild` target: - `Debug` + PCL - 8.424s - `Release` + PCL - 13.651s - `Debug` + *not* PCL - 4.258s - `Release` + *not PCL - 9.487s That does bring up a big question, however... Why are facade assemblies adding so much build time??? This change is good: making `Java.Interop` have fewer dependencies. But I suspect there is more work to be done downstream in Xamarin.Android. I have a feeling referencing `netstandard` libraries cause the same problem to occur.
1 parent 80b4f4e commit bc1a818

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project>
2+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
3+
<PropertyGroup>
4+
<NoStdLib>true</NoStdLib>
5+
</PropertyGroup>
6+
<ItemGroup Condition=" '$(XAInstallPrefix)' != '' ">
7+
<Reference Include="mscorlib">
8+
<HintPath>$(XAInstallPrefix)xbuild-frameworks\MonoAndroid\v1.0\mscorlib.dll</HintPath>
9+
<Private>False</Private>
10+
</Reference>
11+
<Reference Include="System">
12+
<HintPath>$(XAInstallPrefix)xbuild-frameworks\MonoAndroid\v1.0\System.dll</HintPath>
13+
<Private>False</Private>
14+
</Reference>
15+
<Reference Include="System.Core">
16+
<HintPath>$(XAInstallPrefix)xbuild-frameworks\MonoAndroid\v1.0\System.Core.dll</HintPath>
17+
<Private>False</Private>
18+
</Reference>
19+
</ItemGroup>
20+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Project>
2+
<PropertyGroup>
3+
<TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
4+
</PropertyGroup>
5+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
6+
</Project>

src/Java.Interop/Java.Interop.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<OutputType>Library</OutputType>
1111
<RootNamespace>Java.Interop</RootNamespace>
1212
<AssemblyName>Java.Interop</AssemblyName>
13-
<TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
1413
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1514
<NoWarn>1591</NoWarn>
1615
<SignAssembly>true</SignAssembly>
@@ -129,7 +128,10 @@
129128
<CompileJavaInteropJar Include="java\com\xamarin\java_interop\GCUserPeerable.java" />
130129
<CompileJavaInteropJar Include="java\com\xamarin\java_interop\ManagedPeer.java" />
131130
</ItemGroup>
132-
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
131+
<Import Project="..\..\Configuration.props" />
132+
<Import Project="$(JNIEnvGenPath)\JdkInfo.props" />
133+
<Import Project="Java.Interop.PCL.props" Condition=" '$(JavaInteropProfile)' != 'net45' " />
134+
<Import Project="Java.Interop.Net45.props" Condition=" '$(JavaInteropProfile)' == 'net45' " />
133135
<Import Project="Java.Interop.targets" />
134136
<PropertyGroup>
135137
<BuildDependsOn>

src/Java.Interop/Java.Interop.targets

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<PropertyGroup>
44
<Runtime Condition="'$(OS)' != 'Windows_NT'">mono</Runtime>
55
</PropertyGroup>
6-
<Import Project="$(JNIEnvGenPath)\JdkInfo.props" />
76
<Target Name="BuildJnienvGen"
87
Inputs="..\..\build-tools\jnienv-gen\jnienv-gen.csproj"
98
Outputs="$(JNIEnvGenPath)\jnienv-gen.exe">

0 commit comments

Comments
 (0)