Skip to content

Commit

Permalink
[build] Remove cecil submodule (#597)
Browse files Browse the repository at this point in the history
Cecil is an "interesting" complication: it's a dependency of
Java.Interop, but Xamarin.Android use requires that it be "vendorized"
-- renamed as `Xamarin.Android.Cecil.dll` -- to avoid previously seen
issues because it's an unsigned assembly, and thus There Can Be Only
One `Mono.Cecil.dll` loaded into an AppDomain, and whichever is loaded
first "wins", but that version may not be compatible with what other
assemblies in the AppDomain need, and...

Renaming the assembly was just seen as the easiest solution.

This choice hasn't been without its own shortcomings; see e.g. commits
168c94d ("priorities"), cfa74d3 (downstream build system changes),
5eeb287 ("rebuilds are hard"), 6717275 ("because of 168c94d,
xamarin-android 'owns' the checkout, but that may not be API
compatible, oops"), etc., etc.

Plus, it kinda became moot with [dotnet/android@0c9f83b7][0]
which removed the `mono` git submodule from xamarin-android.  Instead
of building mono from source -- and, implicitly, building *cecil* from
source -- mono was instead obtained from a "mono archive" which
contained a prebuilt `Mono.Cecil.dll` which was "renamed" to
`Xamarin.Android.Cecil.dll`.

Which meant that in a xamarin-android build, cecil should *never* be
built from source anymore, which in turn meant that -- give or take
the occasional build system bug --
`Java.Interop/src/Xamarin.Android.Cecil` and company were "dead code",
as far as the commercial product is concerned.

Meanwhile, the existance of `src/Xamarin.Android.Cecil` proved to be
an ongoing source of maintenance pain, as -- depending on the IDE --
it couldn't build reliably, or would rebuild when it shouldn't have.

Rethink the whole Cecil relationship.  If xamarin-android doesn't
require a cecil source checkout, why not ditch it entirely?

Remove the `external/cecil` git submodule, and the
`src/Xamarin.Android.Cecil*` projects, and replace them with NuGet
package references to the [`Mono.Cecil` NuGet package][1].

What this means is that a "pure Java.Interop" build will now have
*different* assembly references than the "same" utilities built from
xamarin-android.  For example, `generator.exe`, when built from
Java.Interop, will reference `Mono.Cecil.dll`, while it will instead
reference `Xamarin.Android.Cecil.dll` when built from xamarin-android.

The `$(CecilSourceDirectory)` MSBuild property is used to determine
whether the Mono.Cecil NuGet package or the `Xamarin.Android.Cecil.dll`
assembly reference should be used at build time.

[0]: dotnet/android@0c9f83b
[1]: https://www.nuget.org/packages/Mono.Cecil/0.11.2
  • Loading branch information
jonpryor authored Mar 27, 2020
1 parent 3091274 commit 56c92c7
Show file tree
Hide file tree
Showing 23 changed files with 30 additions and 159 deletions.
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[submodule "external/cecil"]
path = external/cecil
url = https://github.com/mono/cecil.git
branch = master
[submodule "external/xamarin-android-tools"]
path = external/xamarin-android-tools
url = https://github.com/xamarin/xamarin-android-tools.git
Expand Down
4 changes: 1 addition & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
<UtilityOutputFullPath Condition=" '$(UtilityOutputFullPath)' == '' ">$(ToolOutputFullPath)</UtilityOutputFullPath>
</PropertyGroup>
<PropertyGroup>
<CecilRestoreConfiguration Condition=" '$(CecilRestoreConfiguration)' == '' ">$(Configuration)</CecilRestoreConfiguration>
<CecilSourceDirectory Condition=" '$(CecilSourceDirectory)' == '' ">$(MSBuildThisFileDirectory)external\cecil</CecilSourceDirectory>
<XamarinAndroidToolsDirectory Condition=" '$(XamarinAndroidToolsDirectory)' == '' ">$(MSBuildThisFileDirectory)external\xamarin-android-tools</XamarinAndroidToolsDirectory>
</PropertyGroup>
<PropertyGroup>
Expand All @@ -42,7 +40,7 @@
<_JavacSourceOptions>-source $(JavacSourceVersion) -target $(JavacTargetVersion) -bootclasspath "$(JreRtJarPath)"</_JavacSourceOptions>
</PropertyGroup>
<PropertyGroup>
<CecilFullPath>$([System.IO.Path]::GetFullPath ('$(CecilSourceDirectory)'))</CecilFullPath>
<_XamarinAndroidCecilPath Condition=" '$(CecilSourceDirectory)' != '' And Exists('$(UtilityOutputFullPath)Xamarin.Android.Cecil.dll') ">$(UtilityOutputFullPath)Xamarin.Android.Cecil.dll</_XamarinAndroidCecilPath>
<XamarinAndroidToolsFullPath>$([System.IO.Path]::GetFullPath ('$(XamarinAndroidToolsDirectory)'))</XamarinAndroidToolsFullPath>
</PropertyGroup>
</Project>
14 changes: 0 additions & 14 deletions Java.Interop.sln
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "jcw-gen", "tools\jcw-gen\jc
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.Tools.JavaCallableWrappers-Tests", "tests\Java.Interop.Tools.JavaCallableWrappers-Tests\Java.Interop.Tools.JavaCallableWrappers-Tests.csproj", "{58B564A1-570D-4DA2-B02D-25BDDB1A9F4F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.Cecil", "src\Xamarin.Android.Cecil\Xamarin.Android.Cecil.csproj", "{15945D4B-FF56-4BCC-B598-2718D199DD08}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.Cecil.Mdb", "src\Xamarin.Android.Cecil\Xamarin.Android.Cecil.Mdb.csproj", "{C0487169-8F81-497F-919E-EB42B1D0243F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.GenericMarshaler", "src\Java.Interop.GenericMarshaler\Java.Interop.GenericMarshaler.csproj", "{D1243BAB-23CA-4566-A2A3-3ADA2C2DC3AF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Java.Interop.BootstrapTasks", "build-tools\Java.Interop.BootstrapTasks\Java.Interop.BootstrapTasks.csproj", "{3E8E5C8C-59A6-4A9A-B55D-46AB14431B2A}"
Expand Down Expand Up @@ -222,14 +218,6 @@ Global
{58B564A1-570D-4DA2-B02D-25BDDB1A9F4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{58B564A1-570D-4DA2-B02D-25BDDB1A9F4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{58B564A1-570D-4DA2-B02D-25BDDB1A9F4F}.Release|Any CPU.Build.0 = Release|Any CPU
{15945D4B-FF56-4BCC-B598-2718D199DD08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{15945D4B-FF56-4BCC-B598-2718D199DD08}.Debug|Any CPU.Build.0 = Debug|Any CPU
{15945D4B-FF56-4BCC-B598-2718D199DD08}.Release|Any CPU.ActiveCfg = Release|Any CPU
{15945D4B-FF56-4BCC-B598-2718D199DD08}.Release|Any CPU.Build.0 = Release|Any CPU
{C0487169-8F81-497F-919E-EB42B1D0243F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0487169-8F81-497F-919E-EB42B1D0243F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0487169-8F81-497F-919E-EB42B1D0243F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0487169-8F81-497F-919E-EB42B1D0243F}.Release|Any CPU.Build.0 = Release|Any CPU
{D1243BAB-23CA-4566-A2A3-3ADA2C2DC3AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D1243BAB-23CA-4566-A2A3-3ADA2C2DC3AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1243BAB-23CA-4566-A2A3-3ADA2C2DC3AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -286,8 +274,6 @@ Global
{64CC4E44-CE3A-4319-BF3F-6CF8BD513870} = {0998E45F-8BCE-4791-A944-962CD54E2D80}
{52C7D9B6-E8C8-47D0-9471-652D278D7D77} = {C8F58966-94BF-407F-914A-8654F8B8AE3B}
{58B564A1-570D-4DA2-B02D-25BDDB1A9F4F} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
{15945D4B-FF56-4BCC-B598-2718D199DD08} = {C8F58966-94BF-407F-914A-8654F8B8AE3B}
{C0487169-8F81-497F-919E-EB42B1D0243F} = {C8F58966-94BF-407F-914A-8654F8B8AE3B}
{D1243BAB-23CA-4566-A2A3-3ADA2C2DC3AF} = {4C173212-371D-45D8-BA83-9226194F48DC}
{3E8E5C8C-59A6-4A9A-B55D-46AB14431B2A} = {172B608B-E6F3-41CC-9949-203A76BA247C}
{E34BCFA0-CAA4-412C-AA1C-75DB8D67D157} = {172B608B-E6F3-41CC-9949-203A76BA247C}
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ include build-tools/scripts/msbuild.mk
prepare:: $(BUILD_PROPS) src/Java.Runtime.Environment/Java.Runtime.Environment.dll.config

prepare:: prepare-bootstrap
$(MSBUILD) $(MSBUILD_FLAGS) /t:Restore external/cecil/Mono.Cecil.sln
$(MSBUILD) $(MSBUILD_FLAGS) /t:Restore Java.Interop.sln

prepare-bootstrap: prepare-external bin/Build$(CONFIGURATION)/Java.Interop.BootstrapTasks.dll
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ The `Configuration.Override.props` file is `<Import/>`ed by

Overridable MSBuild properties include:

* `$(CecilSourceDirectory)`: Directory for the `cecil` sources.
Defaults to `external/cecil`.
* `$(CecilSourceDirectory)`: If the empty string, Cecil will be obtained from
NuGet packages. Otherwise, `$(UtilityOutputFullPath)Xamarin.Android.Cecil.dll`
will be used to reference Cecil.
* `$(JdkJvmPath)`: Full path name to the JVM native library to link
[`java-interop`](src/java-interop) against. By default this is
probed for from numerous locations within
Expand Down
1 change: 0 additions & 1 deletion build-tools/scripts/PrepareWindows.targets
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
SourceUris="$(_NuGetUri)"
DestinationFiles="$(_NuGet)"
/>
<Exec Command="$(_NuGet) restore Mono.Cecil.sln" WorkingDirectory="$(_TopDir)\external\cecil" />
<Exec Command="$(_NuGet) restore Java.Interop.sln" WorkingDirectory="$(_TopDir)" />
<JdkInfo
JdksRoot="$(ProgramFiles)\Java"
Expand Down
9 changes: 9 additions & 0 deletions build-tools/scripts/cecil.projitems
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition=" '$(_XamarinAndroidCecilPath)' == '' ">
<PackageReference Include="Mono.Cecil" Version="0.11.2" />
</ItemGroup>
<ItemGroup Condition=" '$(_XamarinAndroidCecilPath)' != '' ">
<Reference Include="$(_XamarinAndroidCecilPath)" />
</ItemGroup>
</Project>
4 changes: 0 additions & 4 deletions external/Mono.Cecil.AssemblyInfo.cs

This file was deleted.

9 changes: 0 additions & 9 deletions external/Mono.Cecil.overrides

This file was deleted.

1 change: 0 additions & 1 deletion external/cecil
Submodule cecil deleted from a6a7f5
4 changes: 2 additions & 2 deletions src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>

<Import Project="..\..\build-tools\scripts\cecil.projitems" />

<PropertyGroup>
<OutputPath>$(ToolOutputFullPath)</OutputPath>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Java.Interop.Tools.Diagnostics\Java.Interop.Tools.Diagnostics.csproj" />
<ProjectReference Include="..\Xamarin.Android.Cecil\Xamarin.Android.Cecil.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<Import Project="..\..\build-tools\scripts\cecil.projitems" />

<PropertyGroup>
<OutputPath>$(ToolOutputFullPath)</OutputPath>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Xamarin.Android.Cecil\Xamarin.Android.Cecil.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<DefineConstants>JCW_ONLY_TYPE_NAMES;HAVE_CECIL</DefineConstants>
</PropertyGroup>

<Import Project="..\..\build-tools\scripts\cecil.projitems" />

<ItemGroup>
<Compile Include="..\Java.Interop.Tools.TypeNameMappings\Java.Interop.Tools.TypeNameMappings\JavaNativeTypeManager.cs">
<Link>JavaNativeTypeManager.cs</Link>
Expand All @@ -26,7 +28,6 @@
<ItemGroup>
<ProjectReference Include="..\Java.Interop.Tools.Cecil\Java.Interop.Tools.Cecil.csproj" />
<ProjectReference Include="..\Java.Interop.Tools.Diagnostics\Java.Interop.Tools.Diagnostics.csproj" />
<ProjectReference Include="..\Xamarin.Android.Cecil\Xamarin.Android.Cecil.csproj" />
</ItemGroup>

<Import Project="..\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems" Label="Shared" Condition="Exists('..\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems')" />
Expand Down
32 changes: 0 additions & 32 deletions src/Xamarin.Android.Cecil/Xamarin.Android.Cecil.Mdb.csproj

This file was deleted.

32 changes: 0 additions & 32 deletions src/Xamarin.Android.Cecil/Xamarin.Android.Cecil.csproj

This file was deleted.

42 changes: 0 additions & 42 deletions src/Xamarin.Android.Cecil/Xamarin.Android.Cecil.targets

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
<OutputPath>$(TestOutputFullPath)</OutputPath>
</PropertyGroup>

<Import Project="..\..\build-tools\scripts\cecil.projitems" />

<ItemGroup>
<ProjectReference Include="..\Xamarin.Android.Cecil\Xamarin.Android.Cecil.csproj" />
<ProjectReference Include="..\Xamarin.Android.Tools.AnnotationSupport\Xamarin.Android.Tools.AnnotationSupport.csproj" />
<ProjectReference Include="..\Xamarin.Android.Tools.ApiXmlAdjuster\Xamarin.Android.Tools.ApiXmlAdjuster.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<OutputPath>$(TestOutputFullPath)</OutputPath>
</PropertyGroup>

<Import Project="..\..\build-tools\scripts\cecil.projitems" />

<ItemGroup>
<PackageReference Include="nunit" Version="3.11.0" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.9.0" />
Expand All @@ -22,7 +24,6 @@
<ProjectReference Include="..\..\src\Java.Interop.Tools.JavaCallableWrappers\Java.Interop.Tools.JavaCallableWrappers.csproj" />
<ProjectReference Include="..\..\src\Java.Interop.Tools.Cecil\Java.Interop.Tools.Cecil.csproj" />
<ProjectReference Include="..\..\src\Java.Interop.Tools.Diagnostics\Java.Interop.Tools.Diagnostics.csproj" />
<ProjectReference Include="..\..\src\Xamarin.Android.Cecil\Xamarin.Android.Cecil.csproj" />
</ItemGroup>

<Import Project="..\..\src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems" Label="Shared" Condition="Exists('..\..\src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems')" />
Expand Down
3 changes: 2 additions & 1 deletion tests/generator-Tests/generator-Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<OutputPath>$(TestOutputFullPath)</OutputPath>
</PropertyGroup>

<Import Project="..\..\build-tools\scripts\cecil.projitems" />

<ItemGroup>
<PackageReference Include="nunit" Version="3.11.0" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.9.0" />
Expand All @@ -23,7 +25,6 @@
<ProjectReference Include="..\..\tools\generator\generator.csproj" />
<ProjectReference Include="..\..\src\Java.Interop.Tools.JavaCallableWrappers\Java.Interop.Tools.JavaCallableWrappers.csproj" />
<ProjectReference Include="..\..\src\Xamarin.Android.Tools.ApiXmlAdjuster\Xamarin.Android.Tools.ApiXmlAdjuster.csproj" />
<ProjectReference Include="..\..\src\Xamarin.Android.Cecil\Xamarin.Android.Cecil.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion tools/generator/generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
</Compile>
</ItemGroup>

<Import Project="..\..\build-tools\scripts\cecil.projitems" />

<ItemGroup>
<PackageReference Include="Mono.Options" Version="5.3.0.1" />
<!-- Since we are sharing an OutputDirectory, and HtmlAgilityPack is also referenced by a different netstandard2.0 libary,
Expand All @@ -38,7 +40,6 @@
<ProjectReference Include="..\..\src\Xamarin.Android.Tools.ApiXmlAdjuster\Xamarin.Android.Tools.ApiXmlAdjuster.csproj" />
<ProjectReference Include="..\..\src\Java.Interop.Tools.Diagnostics\Java.Interop.Tools.Diagnostics.csproj" />
<ProjectReference Include="..\..\src\Java.Interop.Tools.Cecil\Java.Interop.Tools.Cecil.csproj" />
<ProjectReference Include="..\..\src\Xamarin.Android.Cecil\Xamarin.Android.Cecil.csproj" />
<ProjectReference Include="..\..\src\Java.Interop.Tools.JavaCallableWrappers\Java.Interop.Tools.JavaCallableWrappers.csproj" />
</ItemGroup>

Expand Down
3 changes: 2 additions & 1 deletion tools/jcw-gen/jcw-gen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
<PackageReference Include="Mono.Options" Version="5.3.0.1" />
</ItemGroup>

<Import Project="..\..\build-tools\scripts\cecil.projitems" />

<ItemGroup>
<ProjectReference Include="..\..\src\Java.Interop.Tools.JavaCallableWrappers\Java.Interop.Tools.JavaCallableWrappers.csproj" />
<ProjectReference Include="..\..\src\Java.Interop.Tools.Cecil\Java.Interop.Tools.Cecil.csproj" />
<ProjectReference Include="..\..\src\Java.Interop.Tools.Diagnostics\Java.Interop.Tools.Diagnostics.csproj" />
<ProjectReference Include="..\..\src\Xamarin.Android.Cecil\Xamarin.Android.Cecil.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>

<Import Project="..\..\build-tools\scripts\cecil.projitems" />
<Import Project="..\..\src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems" Label="Shared" Condition="Exists('..\..\src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems')" />

<PropertyGroup>
Expand All @@ -21,7 +22,6 @@
<ProjectReference Include="..\..\src\Java.Interop.Export\Java.Interop.Export.csproj" />
<ProjectReference Include="..\..\src\Java.Interop\Java.Interop.csproj" />
<ProjectReference Include="..\..\src\Java.Runtime.Environment\Java.Runtime.Environment.csproj" />
<ProjectReference Include="..\..\src\Xamarin.Android.Cecil\Xamarin.Android.Cecil.csproj" />
<ProjectReference Include="..\..\src\Java.Interop.Tools.Cecil\Java.Interop.Tools.Cecil.csproj" />
</ItemGroup>

Expand Down
1 change: 0 additions & 1 deletion tools/logcat-parse/logcat-parse.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<ProjectReference Include="..\..\src\Java.Interop.Tools.JavaCallableWrappers\Java.Interop.Tools.JavaCallableWrappers.csproj" />
<ProjectReference Include="..\..\src\Java.Interop.Tools.Cecil\Java.Interop.Tools.Cecil.csproj" />
<ProjectReference Include="..\..\src\Java.Interop.Tools.Diagnostics\Java.Interop.Tools.Diagnostics.csproj" />
<ProjectReference Include="..\..\src\Xamarin.Android.Cecil\Xamarin.Android.Cecil.csproj" />
</ItemGroup>

</Project>

0 comments on commit 56c92c7

Please sign in to comment.