Skip to content

Commit ae85418

Browse files
committed
Remove cecil submodule
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
1 parent e7c5f54 commit ae85418

File tree

23 files changed

+30
-159
lines changed

23 files changed

+30
-159
lines changed

.gitmodules

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
[submodule "external/cecil"]
2-
path = external/cecil
3-
url = https://github.com/mono/cecil.git
4-
branch = master
51
[submodule "external/xamarin-android-tools"]
62
path = external/xamarin-android-tools
73
url = https://github.com/xamarin/xamarin-android-tools.git

Directory.Build.props

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
<UtilityOutputFullPath Condition=" '$(UtilityOutputFullPath)' == '' ">$(ToolOutputFullPath)</UtilityOutputFullPath>
3333
</PropertyGroup>
3434
<PropertyGroup>
35-
<CecilRestoreConfiguration Condition=" '$(CecilRestoreConfiguration)' == '' ">$(Configuration)</CecilRestoreConfiguration>
36-
<CecilSourceDirectory Condition=" '$(CecilSourceDirectory)' == '' ">$(MSBuildThisFileDirectory)external\cecil</CecilSourceDirectory>
3735
<XamarinAndroidToolsDirectory Condition=" '$(XamarinAndroidToolsDirectory)' == '' ">$(MSBuildThisFileDirectory)external\xamarin-android-tools</XamarinAndroidToolsDirectory>
3836
</PropertyGroup>
3937
<PropertyGroup>
@@ -43,7 +41,7 @@
4341
<_JavacSourceOptions>-source $(JavacSourceVersion) -target $(JavacTargetVersion) -bootclasspath "$(JreRtJarPath)"</_JavacSourceOptions>
4442
</PropertyGroup>
4543
<PropertyGroup>
46-
<CecilFullPath>$([System.IO.Path]::GetFullPath ('$(CecilSourceDirectory)'))</CecilFullPath>
44+
<_XamarinAndroidCecilPath Condition=" '$(CecilSourceDirectory)' != '' And Exists('$(UtilityOutputFullPath)Xamarin.Android.Cecil.dll') ">$(UtilityOutputFullPath)Xamarin.Android.Cecil.dll</_XamarinAndroidCecilPath>
4745
<XamarinAndroidToolsFullPath>$([System.IO.Path]::GetFullPath ('$(XamarinAndroidToolsDirectory)'))</XamarinAndroidToolsFullPath>
4846
</PropertyGroup>
4947
</Project>

Java.Interop.sln

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "jcw-gen", "tools\jcw-gen\jc
7777
EndProject
7878
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}"
7979
EndProject
80-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.Cecil", "src\Xamarin.Android.Cecil\Xamarin.Android.Cecil.csproj", "{15945D4B-FF56-4BCC-B598-2718D199DD08}"
81-
EndProject
82-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.Cecil.Mdb", "src\Xamarin.Android.Cecil\Xamarin.Android.Cecil.Mdb.csproj", "{C0487169-8F81-497F-919E-EB42B1D0243F}"
83-
EndProject
8480
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.GenericMarshaler", "src\Java.Interop.GenericMarshaler\Java.Interop.GenericMarshaler.csproj", "{D1243BAB-23CA-4566-A2A3-3ADA2C2DC3AF}"
8581
EndProject
8682
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Java.Interop.BootstrapTasks", "build-tools\Java.Interop.BootstrapTasks\Java.Interop.BootstrapTasks.csproj", "{3E8E5C8C-59A6-4A9A-B55D-46AB14431B2A}"
@@ -222,14 +218,6 @@ Global
222218
{58B564A1-570D-4DA2-B02D-25BDDB1A9F4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
223219
{58B564A1-570D-4DA2-B02D-25BDDB1A9F4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
224220
{58B564A1-570D-4DA2-B02D-25BDDB1A9F4F}.Release|Any CPU.Build.0 = Release|Any CPU
225-
{15945D4B-FF56-4BCC-B598-2718D199DD08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
226-
{15945D4B-FF56-4BCC-B598-2718D199DD08}.Debug|Any CPU.Build.0 = Debug|Any CPU
227-
{15945D4B-FF56-4BCC-B598-2718D199DD08}.Release|Any CPU.ActiveCfg = Release|Any CPU
228-
{15945D4B-FF56-4BCC-B598-2718D199DD08}.Release|Any CPU.Build.0 = Release|Any CPU
229-
{C0487169-8F81-497F-919E-EB42B1D0243F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
230-
{C0487169-8F81-497F-919E-EB42B1D0243F}.Debug|Any CPU.Build.0 = Debug|Any CPU
231-
{C0487169-8F81-497F-919E-EB42B1D0243F}.Release|Any CPU.ActiveCfg = Release|Any CPU
232-
{C0487169-8F81-497F-919E-EB42B1D0243F}.Release|Any CPU.Build.0 = Release|Any CPU
233221
{D1243BAB-23CA-4566-A2A3-3ADA2C2DC3AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
234222
{D1243BAB-23CA-4566-A2A3-3ADA2C2DC3AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
235223
{D1243BAB-23CA-4566-A2A3-3ADA2C2DC3AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -286,8 +274,6 @@ Global
286274
{64CC4E44-CE3A-4319-BF3F-6CF8BD513870} = {0998E45F-8BCE-4791-A944-962CD54E2D80}
287275
{52C7D9B6-E8C8-47D0-9471-652D278D7D77} = {C8F58966-94BF-407F-914A-8654F8B8AE3B}
288276
{58B564A1-570D-4DA2-B02D-25BDDB1A9F4F} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
289-
{15945D4B-FF56-4BCC-B598-2718D199DD08} = {C8F58966-94BF-407F-914A-8654F8B8AE3B}
290-
{C0487169-8F81-497F-919E-EB42B1D0243F} = {C8F58966-94BF-407F-914A-8654F8B8AE3B}
291277
{D1243BAB-23CA-4566-A2A3-3ADA2C2DC3AF} = {4C173212-371D-45D8-BA83-9226194F48DC}
292278
{3E8E5C8C-59A6-4A9A-B55D-46AB14431B2A} = {172B608B-E6F3-41CC-9949-203A76BA247C}
293279
{E34BCFA0-CAA4-412C-AA1C-75DB8D67D157} = {172B608B-E6F3-41CC-9949-203A76BA247C}

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ include build-tools/scripts/msbuild.mk
5252
prepare:: $(BUILD_PROPS) src/Java.Runtime.Environment/Java.Runtime.Environment.dll.config
5353

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

5857
prepare-bootstrap: prepare-external bin/Build$(CONFIGURATION)/Java.Interop.BootstrapTasks.dll

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ The `Configuration.Override.props` file is `<Import/>`ed by
7070

7171
Overridable MSBuild properties include:
7272

73-
* `$(CecilSourceDirectory)`: Directory for the `cecil` sources.
74-
Defaults to `external/cecil`.
73+
* `$(CecilSourceDirectory)`: If the empty string, Cecil will be obtained from
74+
NuGet packages. Otherwise, `$(UtilityOutputFullPath)Xamarin.Android.Cecil.dll`
75+
will be used to reference Cecil.
7576
* `$(JdkJvmPath)`: Full path name to the JVM native library to link
7677
[`java-interop`](src/java-interop) against. By default this is
7778
probed for from numerous locations within

build-tools/scripts/PrepareWindows.targets

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
SourceUris="$(_NuGetUri)"
1818
DestinationFiles="$(_NuGet)"
1919
/>
20-
<Exec Command="$(_NuGet) restore Mono.Cecil.sln" WorkingDirectory="$(_TopDir)\external\cecil" />
2120
<Exec Command="$(_NuGet) restore Java.Interop.sln" WorkingDirectory="$(_TopDir)" />
2221
<JdkInfo
2322
JdksRoot="$(ProgramFiles)\Java"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Condition=" '$(_XamarinAndroidCecilPath)' == '' ">
4+
<PackageReference Include="Mono.Cecil" Version="0.11.2" />
5+
</ItemGroup>
6+
<ItemGroup Condition=" '$(_XamarinAndroidCecilPath)' != '' ">
7+
<Reference Include="$(_XamarinAndroidCecilPath)" />
8+
</ItemGroup>
9+
</Project>

external/Mono.Cecil.AssemblyInfo.cs

Lines changed: 0 additions & 4 deletions
This file was deleted.

external/Mono.Cecil.overrides

Lines changed: 0 additions & 9 deletions
This file was deleted.

external/cecil

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)