Skip to content

Commit 9c3d7c5

Browse files
committed
[Build Tasks] Import mono linker sources
The `Xamarin.Android.Build.Tasks` and `Microsoft.Android.Sdk.ILLink` projects have been updated to only compile the linker sources that they require, rather than including everything from the `src/Xamarin.Android.Build.Tasks/Linker` folder. Linker sources from mono/mono@6dd9def have been added to `src/Xamarin.Android.Build.Tasks/Linker/External`. Adding the dozen or so files we still depend on directly to the repo removes one of the last dependencies we still have on the mono bundle. The `LinkAssembliesNoShrink` task is the main piece of XABT that depends on these mono linker sources. In the future we should try to see if we migrate this tasks functionality to some ILLink tool/task invocation.
1 parent b1b6a76 commit 9c3d7c5

26 files changed

+2486
-238
lines changed

Configuration.props

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@
113113
<MonoRequiredMaximumVersion Condition=" '$(MonoRequiredMaximumVersion)' == '' ">$(MonoRequiredMinimumVersion)</MonoRequiredMaximumVersion>
114114
<IgnoreMaxMonoVersion Condition=" '$(IgnoreMaxMonoVersion)' == '' And '$(RunningOnCI)' == 'true' ">False</IgnoreMaxMonoVersion>
115115
<IgnoreMaxMonoVersion Condition=" '$(IgnoreMaxMonoVersion)' == '' ">True</IgnoreMaxMonoVersion>
116-
<LinkerSourceDirectory>$(MSBuildThisFileDirectory)external\mono\sdks\out\android-sources\external\linker\src</LinkerSourceDirectory>
117116
<OpenTKSourceDirectory>$(MSBuildThisFileDirectory)external\opentk</OpenTKSourceDirectory>
118117
<MingwZlibRootDirectory Condition=" '$(ZlibRootDirectory)' == '' And '$(HostOS)' == 'Linux' ">\usr</MingwZlibRootDirectory>
119118
<MingwZlibRootDirectory Condition=" '$(ZlibRootDirectory)' == '' And '$(HostOS)' == 'Darwin' ">$(HostHomebrewPrefix)\opt\mingw-zlib\usr</MingwZlibRootDirectory>
@@ -166,7 +165,6 @@
166165
<AndroidSdkFullPath>$([System.IO.Path]::GetFullPath ('$(AndroidSdkDirectory)'))</AndroidSdkFullPath>
167166
<JavaInteropFullPath>$([System.IO.Path]::GetFullPath ('$(JavaInteropSourceDirectory)'))</JavaInteropFullPath>
168167
<MonoSourceFullPath>$([System.IO.Path]::GetFullPath ('$(MonoSourceDirectory)'))</MonoSourceFullPath>
169-
<LinkerSourceFullPath>$([System.IO.Path]::GetFullPath ('$(LinkerSourceDirectory)'))</LinkerSourceFullPath>
170168
<SqliteSourceFullPath>$([System.IO.Path]::GetFullPath ('$(SqliteSourceDirectory)'))</SqliteSourceFullPath>
171169
<OpenTKSourceFullPath>$([System.IO.Path]::GetFullPath ('$(OpenTKSourceDirectory)'))</OpenTKSourceFullPath>
172170
</PropertyGroup>

src/Microsoft.Android.Sdk.ILLink/Microsoft.Android.Sdk.ILLink.csproj

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,14 @@
1313

1414
<Compile Include="..\Xamarin.Android.Build.Tasks\obj\$(Configuration)\Profile.g.cs" Link="Profile.g.cs" />
1515

16-
<!--Include *everything* to start with-->
17-
<Compile Include="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\*.cs" Link="MonoDroid.Tuner\%(FileName).cs" />
18-
<Compile Include="..\Xamarin.Android.Build.Tasks\Linker\Mobile.Tuner\*.cs" Link="Mobile.Tuner\%(FileName).cs" />
19-
<Compile Remove="Mono.Tuner\**" />
20-
<EmbeddedResource Remove="Mono.Tuner\**" />
21-
<None Remove="Mono.Tuner\**" />
22-
23-
<!--Files that probably do not apply at all to the new linker-->
24-
<Compile Remove="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\AndroidLinkContext.cs" />
25-
<Compile Remove="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\Linker.cs" />
26-
<Compile Remove="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\LinkerOptions.cs" />
27-
28-
<!--Steps that are upstreamed, these are OK to remove-->
29-
<Compile Remove="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\ApplyPreserveAttribute.cs" />
30-
<Compile Remove="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\OutputStepWithTimestamps.cs" />
31-
<Compile Remove="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\PreserveCode.cs" />
32-
<Compile Remove="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\PreserveDynamicTypes.cs" />
33-
<Compile Remove="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\PreserveHttpAndroidClientHandler.cs" />
34-
<Compile Remove="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\PreserveLinqExpressions.cs" />
35-
<Compile Remove="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\PreserveRuntimeSerialization.cs" />
36-
<Compile Remove="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\PreserveTlsProvider.cs" />
37-
<Compile Remove="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\PreserveTypeConverters.cs" />
38-
<Compile Remove="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\RemoveAttributes.cs" />
39-
40-
<!--TODO: Subclasses MarkStep-->
41-
<Compile Remove="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\MonoDroidMarkStep.cs" />
16+
<!--Include required linker sources-->
17+
<Compile Include="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\Extensions.cs" Link="MonoDroid.Tuner\Extensions.cs" />
18+
<Compile Include="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\PreserveExportedTypes.cs" Link="MonoDroid.Tuner\PreserveExportedTypes.cs" />
19+
<Compile Include="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\MonoDroidProfile.cs" Link="MonoDroid.Tuner\MonoDroidProfile.cs" />
20+
<Compile Include="..\Xamarin.Android.Build.Tasks\Linker\Mobile.Tuner\MobileProfile.cs" Link="Mobile.Tuner\MobileProfile.cs" />
21+
22+
<!--TODO: Subclasses MarkStep
23+
<Compile Remove="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\MonoDroidMarkStep.cs" /-->
4224

4325
<!--Other Xamarin.Android / Java.Interop files-->
4426
<Compile Include="..\..\external\Java.Interop\src\Java.Interop.Tools.Cecil\Java.Interop.Tools.Cecil\CustomAttributeProviderRocks.cs" Link="Java.Interop\CustomAttributeProviderRocks.cs" />

src/Microsoft.Android.Sdk.ILLink/SetupStep.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Mono.Cecil;
66
using Mono.Linker;
77
using Mono.Linker.Steps;
8-
using Mono.Tuner;
98
using MonoDroid.Tuner;
109

1110
namespace Microsoft.Android.Sdk.ILLink
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
//
2+
// BaseStep.cs
3+
//
4+
// Author:
5+
// Jb Evain (jbevain@novell.com)
6+
//
7+
// (C) 2007 Novell, Inc.
8+
//
9+
// Permission is hereby granted, free of charge, to any person obtaining
10+
// a copy of this software and associated documentation files (the
11+
// "Software"), to deal in the Software without restriction, including
12+
// without limitation the rights to use, copy, modify, merge, publish,
13+
// distribute, sublicense, and/or sell copies of the Software, and to
14+
// permit persons to whom the Software is furnished to do so, subject to
15+
// the following conditions:
16+
//
17+
// The above copyright notice and this permission notice shall be
18+
// included in all copies or substantial portions of the Software.
19+
//
20+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24+
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26+
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27+
//
28+
29+
using Mono.Cecil;
30+
31+
namespace Mono.Linker.Steps {
32+
33+
public abstract class BaseStep : IStep {
34+
35+
private LinkContext _context;
36+
37+
public LinkContext Context {
38+
get { return _context; }
39+
}
40+
41+
public AnnotationStore Annotations {
42+
get { return _context.Annotations; }
43+
}
44+
45+
public Tracer Tracer {
46+
get { return _context.Tracer; }
47+
}
48+
49+
public MarkingHelpers MarkingHelpers => _context.MarkingHelpers;
50+
51+
public void Process (LinkContext context)
52+
{
53+
_context = context;
54+
55+
if (!ConditionToProcess ())
56+
return;
57+
58+
Process ();
59+
60+
foreach (AssemblyDefinition assembly in context.GetAssemblies ())
61+
ProcessAssembly (assembly);
62+
63+
EndProcess ();
64+
}
65+
66+
protected virtual bool ConditionToProcess ()
67+
{
68+
return true;
69+
}
70+
71+
protected virtual void Process ()
72+
{
73+
}
74+
75+
protected virtual void EndProcess ()
76+
{
77+
}
78+
79+
protected virtual void ProcessAssembly (AssemblyDefinition assembly)
80+
{
81+
}
82+
}
83+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// IStep.cs
3+
//
4+
// Author:
5+
// Jb Evain (jbevain@gmail.com)
6+
//
7+
// (C) 2006 Jb Evain
8+
//
9+
// Permission is hereby granted, free of charge, to any person obtaining
10+
// a copy of this software and associated documentation files (the
11+
// "Software"), to deal in the Software without restriction, including
12+
// without limitation the rights to use, copy, modify, merge, publish,
13+
// distribute, sublicense, and/or sell copies of the Software, and to
14+
// permit persons to whom the Software is furnished to do so, subject to
15+
// the following conditions:
16+
//
17+
// The above copyright notice and this permission notice shall be
18+
// included in all copies or substantial portions of the Software.
19+
//
20+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24+
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26+
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27+
//
28+
29+
namespace Mono.Linker.Steps {
30+
31+
public interface IStep {
32+
void Process (LinkContext context);
33+
}
34+
}

0 commit comments

Comments
 (0)