-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[build] Remove Mono submodule (#3371)
Context: https://github.com/xamarin/xamarin-android/projects/10 One of the goals behind the Mono SDK archive was to enable product builds without having the entire Mono source tree present, which means it should be possible to remove the Mono git submodule and build the entire xamarin-android repo without any issues. At the same time, we want to keep the ability to build Mono from source, if necessary, for situations when a developer works on the BCL or the runtime itself and there's no appropriate binary archive present. To support these two requirements: * Remove the Mono submodule * Put Mono repo commit reference into the `.external` file * Make distinction between "commercial" and "regular" bits in the `.external` file so that we don't attempt to check out everything mentioned in there in situations when a developer doesn't have access to the commercial bits. * Use Mono linker sources from the archive * Remove `zlib-helper.c` from the `libmonodroid` build - the API implemented in there is no longer used by Mono. * `Xamarin.Android.Cecil.dll` and `Xamarin.Android.Cecil.Mdb.dll` are no longer built from source. Instead we use Cecil to reshape `Mono.Cecil` and conjure the two renamed and re-signed assemblies. * All the code which used `Xamarin.Android.Cecil` project reference now simply references the conjured assemblies (which are also added to the bundle) * Third Party Notices are generated from licenses found in the Mono archive. * Windows build downloads also the Darwin archive - in order to be able to use Mono Linker sources as well as licenses contained in this archive.
- Loading branch information
Showing
43 changed files
with
636 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
xamarin/monodroid:master@237e0bd9f105b9842778ef82161a20c6d4497a40 | ||
mono/mono:2019-06@afcf28a3660b069721e5c441dfe5bb7548e3204f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
build-tools/conjure-xamarin-android-cecil/conjure-xamarin-android-cecil.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
using Mono.Cecil; | ||
|
||
public class ConjureXamarinAndroidCecil | ||
{ | ||
const string BaseNameReplacement = "Xamarin.Android.Cecil"; | ||
const string CecilAssemblyName = BaseNameReplacement; | ||
const string CecilMdbAssemblyName = BaseNameReplacement + ".Mdb"; | ||
|
||
static readonly List<string> internalsVisibleTo = new List<string> { | ||
"Xamarin.Android.Cecil.Pdb, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db", | ||
"Xamarin.Android.Cecil.Mdb, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db" | ||
}; | ||
|
||
public static int Main (string[] args) | ||
{ | ||
if (args.Length < 2) { | ||
Console.WriteLine ("Usage: <input directory> <output directory>"); | ||
Console.WriteLine (" <input directory> must have Mono.Cecil.dll and Mono.Cecil.Mdb.dll assemblies"); | ||
return 1; | ||
} | ||
|
||
string inputDir = args [0]; | ||
string inputFilePath = Path.Combine (inputDir, "Mono.Cecil.dll"); | ||
string outputDirPath = args [1]; | ||
|
||
var resolver = new DefaultAssemblyResolver (); | ||
resolver.AddSearchDirectory (Path.GetDirectoryName (inputFilePath)); | ||
var rp = new ReaderParameters () { | ||
AssemblyResolver = resolver, | ||
ReadSymbols = true | ||
}; | ||
var monoCecil = AssemblyDefinition.ReadAssembly (inputFilePath, rp); | ||
monoCecil.Name.Name = CecilAssemblyName; | ||
|
||
var ivtCtor = monoCecil.MainModule.ImportReference (typeof (System.Runtime.CompilerServices.InternalsVisibleToAttribute).GetConstructor (new []{typeof(string)})); | ||
foreach (string ivtParam in internalsVisibleTo) { | ||
var ca = new CustomAttribute (ivtCtor); | ||
ca.ConstructorArguments.Add (new CustomAttributeArgument (monoCecil.MainModule.TypeSystem.String, ivtParam)); | ||
monoCecil.CustomAttributes.Add (ca); | ||
} | ||
|
||
var wp = new WriterParameters { | ||
WriteSymbols = true | ||
}; | ||
|
||
monoCecil.Write (Path.Combine (outputDirPath, $"{CecilAssemblyName}.dll"), wp); | ||
|
||
inputFilePath = Path.Combine (inputDir, "Mono.Cecil.Mdb.dll"); | ||
var monoCecilMdb = AssemblyDefinition.ReadAssembly (inputFilePath, rp); | ||
monoCecilMdb.Name.Name = CecilMdbAssemblyName; | ||
|
||
AssemblyNameReference monoCecilRef = monoCecilMdb.MainModule.AssemblyReferences.Single (r => String.Compare ("Mono.Cecil", r.Name, StringComparison.Ordinal) == 0); | ||
monoCecilRef.Name = CecilAssemblyName; | ||
monoCecilMdb.Write (Path.Combine (outputDirPath, $"{CecilMdbAssemblyName}.dll"), wp); | ||
|
||
return 0; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
build-tools/conjure-xamarin-android-cecil/conjure-xamarin-android-cecil.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{C876DA71-8573-4CEF-9149-716D72455ED4}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>Xamarin.Android.Prepare</RootNamespace> | ||
<AssemblyName>conjure-xamarin-android-cecil</AssemblyName> | ||
</PropertyGroup> | ||
<Import Project="..\..\Configuration.props" /> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<Optimize>false</Optimize> | ||
<OutputPath>..\..\bin\BuildDebug</OutputPath> | ||
<DefineConstants>DEBUG;</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<ExternalConsole>true</ExternalConsole> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<Optimize>true</Optimize> | ||
<OutputPath>..\..\bin\BuildRelease</OutputPath> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<ExternalConsole>true</ExternalConsole> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="Mono.Cecil"> | ||
<HintPath>$(XamarinAndroidSourcePath)external\mono\sdks\out\android-bcl\monodroid_tools\Mono.Cecil.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="conjure-xamarin-android-cecil.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.