Skip to content

Commit

Permalink
Remove cecil submodule
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 committed Mar 10, 2020
1 parent 0a3354b commit fde797d
Show file tree
Hide file tree
Showing 19 changed files with 27 additions and 154 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
2 changes: 0 additions & 2 deletions Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
/>
<PropertyGroup>
<CecilRestoreConfiguration Condition=" '$(CecilRestoreConfiguration)' == '' ">$(Configuration)</CecilRestoreConfiguration>
<CecilSourceDirectory Condition=" '$(CecilSourceDirectory)' == '' ">$(MSBuildThisFileDirectory)external\cecil</CecilSourceDirectory>
<UtilityOutputFullPath Condition=" '$(UtilityOutputFullPath)' == '' ">$(MSBuildThisFileDirectory)bin\$(_Configuration)\</UtilityOutputFullPath>
<XamarinAndroidToolsDirectory Condition=" '$(XamarinAndroidToolsDirectory)' == '' ">$(MSBuildThisFileDirectory)external\xamarin-android-tools</XamarinAndroidToolsDirectory>
</PropertyGroup>
Expand All @@ -31,7 +30,6 @@
<_JavacSourceOptions>-source $(JavacSourceVersion) -target $(JavacTargetVersion) -bootclasspath "$(JreRtJarPath)"</_JavacSourceOptions>
</PropertyGroup>
<PropertyGroup>
<CecilFullPath>$([System.IO.Path]::GetFullPath ('$(CecilSourceDirectory)'))</CecilFullPath>
<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 @@ -58,7 +58,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 @@ it within other project files.

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, `$(CecilSourceDirectory)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
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=" '$(CecilSourceDirectory)' == '' ">
<PackageReference Include="Mono.Cecil" Version="0.11.2" />
</ItemGroup>
<ItemGroup Condition=" '$(CecilSourceDirectory)' != '' ">
<Reference Include="$(UtilityOutputFullPath)Xamarin.Android.Cecil.dll" />
</ItemGroup>
</Project>
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 @@ -4,6 +4,8 @@
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

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

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>..\..\bin\Debug</OutputPath>
</PropertyGroup>
Expand All @@ -14,7 +16,5 @@

<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,6 +4,8 @@
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

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

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>..\..\bin\Debug</OutputPath>
</PropertyGroup>
Expand All @@ -12,8 +14,4 @@
<OutputPath>..\..\bin\Release</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 @@ -14,6 +14,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 @@ -23,7 +25,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
33 changes: 0 additions & 33 deletions src/Xamarin.Android.Cecil/Xamarin.Android.Cecil.Mdb.csproj

This file was deleted.

33 changes: 0 additions & 33 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 @@ -12,8 +12,9 @@
<OutputPath>..\..\bin\Release</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 @@ -15,6 +15,8 @@
<OutputPath>..\..\bin\TestRelease</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 @@ -26,7 +28,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 @@ -15,6 +15,8 @@
<OutputPath>..\..\bin\TestRelease</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 @@ -27,7 +29,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
5 changes: 1 addition & 4 deletions tools/generator/generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<Import Project="..\..\Configuration.props" />
<Import Project="..\..\build-tools\scripts\cecil.projitems" />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
Expand Down Expand Up @@ -147,10 +148,6 @@
<Project>{D48EE8D0-0A0A-4493-AEF5-DAF5F8CF86AD}</Project>
<Name>Java.Interop.Tools.Cecil</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Xamarin.Android.Cecil\Xamarin.Android.Cecil.csproj">
<Project>{15945D4B-FF56-4BCC-B598-2718D199DD08}</Project>
<Name>Xamarin.Android.Cecil</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Java.Interop.Tools.JavaCallableWrappers\Java.Interop.Tools.JavaCallableWrappers.csproj">
<Project>{D18FCF91-8876-48A0-A693-2DC1E7D3D80A}</Project>
<Name>Java.Interop.Tools.JavaCallableWrappers</Name>
Expand Down
5 changes: 1 addition & 4 deletions tools/jcw-gen/jcw-gen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<Import Project="..\..\Configuration.props" />
<Import Project="..\..\build-tools\scripts\cecil.projitems" />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
Expand Down Expand Up @@ -53,10 +54,6 @@
<Project>{64CC4E44-CE3A-4319-BF3F-6CF8BD513870}</Project>
<Name>Java.Interop.Tools.Diagnostics</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Xamarin.Android.Cecil\Xamarin.Android.Cecil.csproj">
<Project>{15945D4B-FF56-4BCC-B598-2718D199DD08}</Project>
<Name>Xamarin.Android.Cecil</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<Import Project="..\..\Configuration.props" />
<Import Project="..\..\build-tools\scripts\cecil.projitems" />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
Expand Down Expand Up @@ -56,10 +57,6 @@
<Project>{5887B410-D448-4257-A46B-EAC03C80BE93}</Project>
<Name>Java.Runtime.Environment</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Xamarin.Android.Cecil\Xamarin.Android.Cecil.csproj">
<Project>{15945D4B-FF56-4BCC-B598-2718D199DD08}</Project>
<Name>Xamarin.Android.Cecil</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Java.Interop.Tools.Cecil\Java.Interop.Tools.Cecil.csproj">
<Project>{D48EE8D0-0A0A-4493-AEF5-DAF5F8CF86AD}</Project>
<Name>Java.Interop.Tools.Cecil</Name>
Expand Down

0 comments on commit fde797d

Please sign in to comment.