Skip to content

Commit 168c94d

Browse files
authored
[build] Allow overriding Cecil location (dotnet#328)
There is a philosophically confusing question due to the interaction between the Java.Interop, xamarin-android, and mono repos: Which repo "owns" Cecil? The Java.Interop repo has a Cecil submodule. The mono repo has a Cecil submodule. (*Two*, if you count the indirect one from the Linker submodule, but that shouldn't be used.) The xamarin-android repo references both Java.Interop & mono. If we have a fix in Cecil, what all needs bumping? A present, the answer is *everything*, because the mono reference is included into a variety of mono-built utilities (*as source*, not an assembly), while the Java.Interop reference built into `Xamarin.Android.Cecil.dll` and used by the Xamarin.Android build process. This is somewhat confusing, and means that more work needs to be done to apply fixes everywhere. Try to simplify things by adding a new `$(CecilSourceDirectory)` MSBuild property to `Configuration.props`. The intent is to allow a xamarin-android checkout to *override* `$(CecilSourceDirectory)` so that the Java.Interop build will the *mono* reference, thus permitting a degree of consistency and understanding not previously available. Thus, which repo "owns" Cecil? The mono repo will; the Java.Interop reference will be ignored *when building from xamarin-android*.
1 parent ca27edd commit 168c94d

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

Configuration.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
Condition="Exists('$(MSBuildThisFileDirectory)bin\Build$(Configuration)\MonoInfo.props')"
1515
/>
1616
<PropertyGroup>
17+
<CecilSourceDirectory Condition=" '$(CecilSourceDirectory)' == '' ">$(MSBuildThisFileDirectory)external\cecil</CecilSourceDirectory>
1718
<UtilityOutputFullPath Condition=" '$(UtilityOutputFullPath)' == '' ">$(MSBuildThisFileDirectory)bin\$(Configuration)\</UtilityOutputFullPath>
1819
</PropertyGroup>
20+
<PropertyGroup>
21+
<CecilFullPath>$([System.IO.Path]::GetFullPath ('$(CecilSourceDirectory)'))</CecilFullPath>
22+
</PropertyGroup>
1923
</Project>

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ it within other project files.
7070

7171
Overridable MSBuild properties include:
7272

73+
* `$(CecilSourceDirectory)`: Directory for the `cecil` sources.
74+
Defaults to `external/cecil`.
7375
* `$(JdkJvmPath)`: Full path name to the JVM native library to link
7476
[`java-interop`](src/java-interop) against. By default this is
7577
probed for from numerious locations within

src/Xamarin.Android.Cecil/Xamarin.Android.Cecil.targets

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<CecilDirectory>$(MSBuildThisFileDirectory)\..\..\external\cecil</CecilDirectory>
54
<CecilPreparedFlag>prepared.flag</CecilPreparedFlag>
65
<OutputPath Condition=" '$(OutputPath)' == '' ">..\..\bin\$(Configuration)</OutputPath>
76
<CecilOutputPath>$([System.IO.Path]::Combine ($(MSBuildThisFileDirectory), $(OutputPath)))</CecilOutputPath>
87
<CecilOutputPath>$([System.IO.Path]::GetFullPath ($(CecilOutputPath)))</CecilOutputPath>
98
<CecilAssemblies>$(OutputPath)\Xamarin.Android.Cecil.dll;$(OutputPath)\Xamarin.Android.Cecil.Mdb.dll</CecilAssemblies>
109
</PropertyGroup>
1110
<ItemGroup>
12-
<_CecilProject Include="$(CecilDirectory)\Mono.Cecil.csproj" />
13-
<_CecilProject Include="$(CecilDirectory)\symbols\mdb\Mono.Cecil.Mdb.csproj" />
14-
<_CecilSource Include="$(CecilDirectory)\**\*.cs" />
11+
<_CecilProject Include="$(CecilFullPath)\Mono.Cecil.csproj" />
12+
<_CecilProject Include="$(CecilFullPath)\symbols\mdb\Mono.Cecil.Mdb.csproj" />
13+
<_CecilSource Include="$(CecilFullPath)\**\*.cs" />
1514
</ItemGroup>
1615
<Target Name="BuildCecil"
1716
Inputs="@(_CecilSource)"

0 commit comments

Comments
 (0)