Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[illink] consolidate & remove hardcoded assembly names #9662

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/Microsoft.Android.Sdk.ILLink/ApplyPreserveAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;

using Mono.Cecil;
using Mono.Linker;
using Mono.Linker.Steps;

using Mono.Cecil;
using Xamarin.Android.Tasks;

namespace Microsoft.Android.Sdk.ILLink
{
Expand All @@ -25,7 +24,7 @@ public override SubStepTargets Targets {

public override bool IsActiveFor (AssemblyDefinition assembly)
{
return !Profile.IsSdkAssembly (assembly) && Annotations.GetAction (assembly) == AssemblyAction.Link;
return !MonoAndroidHelper.IsFrameworkAssembly (assembly) && Annotations.GetAction (assembly) == AssemblyAction.Link;
}

public override void ProcessType (TypeDefinition type)
Expand Down
7 changes: 2 additions & 5 deletions src/Microsoft.Android.Sdk.ILLink/MarkJavaObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Mono.Linker.Steps;
using Java.Interop.Tools.Cecil;
using Xamarin.Android.Tasks;
using Profile = Microsoft.Android.Sdk.ILLink.Profile;

namespace MonoDroid.Tuner {

Expand All @@ -27,9 +26,7 @@ public override void Initialize (LinkContext context, MarkContext markContext)

bool IsActiveFor (AssemblyDefinition assembly)
{
if (Profile.IsSdkAssembly (assembly))
return false;
if (Profile.IsProductAssembly (assembly))
if (MonoAndroidHelper.IsFrameworkAssembly (assembly))
return false;

return assembly.MainModule.HasTypeReference ("System.Net.Http.HttpMessageHandler") ||
Expand Down Expand Up @@ -397,7 +394,7 @@ static bool IsImplementor (TypeDefinition type, IMetadataResolver cache)

static bool IsUserType (TypeDefinition type)
{
return !MonoAndroidHelper.IsFrameworkAssembly (type.Module.Assembly.Name.Name + ".dll");
return !MonoAndroidHelper.IsFrameworkAssembly (type.Module.Assembly);
}

void PreserveImplementor (TypeDefinition type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
<PackageReference Include="Microsoft.NET.ILLink" Version="$(MicrosoftNETILLinkTasksPackageVersion)" />
<ProjectReference Include="..\Xamarin.Android.Build.Tasks\Xamarin.Android.Build.Tasks.csproj" ReferenceOutputAssembly="False" />

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

<!--Include shared linker sources-->
<Compile Include="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\AddKeepAlivesStep.cs" Link="MonoDroid.Tuner\AddKeepAlivesStep.cs" />
<Compile Include="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\AndroidLinkConfiguration.cs" Link="MonoDroid.Tuner\AndroidLinkConfiguration.cs" />
Expand All @@ -20,8 +18,6 @@
<Compile Include="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\FixLegacyResourceDesignerStep.cs" Link="MonoDroid.Tuner\FixLegacyResourceDesignerStep.cs" />
<Compile Include="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\LinkDesignerBase.cs" Link="MonoDroid.Tuner\LinkDesignerBase.cs" />
<Compile Include="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\RemoveResourceDesignerStep.cs" Link="MonoDroid.Tuner\RemoveResourceDesignerStep.cs" />
<Compile Include="..\Xamarin.Android.Build.Tasks\Linker\MonoDroid.Tuner\MonoDroidProfile.cs" Link="MonoDroid.Tuner\MonoDroidProfile.cs" />
<Compile Include="..\Xamarin.Android.Build.Tasks\Linker\Mobile.Tuner\MobileProfile.cs" Link="Mobile.Tuner\MobileProfile.cs" />

<!--Other .NET for Android / Java.Interop files-->
<Compile Include="..\..\external\Java.Interop\src\Java.Interop.Tools.Cecil\Java.Interop.Tools.Cecil\CustomAttributeProviderRocks.cs" Link="Java.Interop\CustomAttributeProviderRocks.cs" />
Expand Down
7 changes: 2 additions & 5 deletions src/Microsoft.Android.Sdk.ILLink/PreserveApplications.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using System;
using System.Collections;
using System.Linq;

using Mono.Cecil;
using Mono.Linker;
using Mono.Linker.Steps;

using Mono.Tuner;
using Mobile.Tuner;

using Mono.Cecil;
using Xamarin.Android.Tasks;

namespace MonoDroid.Tuner {

Expand Down
13 changes: 8 additions & 5 deletions src/Microsoft.Android.Sdk.ILLink/PreserveExportedTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;

using Microsoft.Android.Sdk.ILLink;
using Mono.Cecil;
using Mono.Linker;
using Mono.Linker.Steps;

using Mono.Cecil;
using Microsoft.Android.Sdk.ILLink;
using Xamarin.Android.Tasks;

namespace Mono.Tuner {

Expand All @@ -24,7 +23,11 @@ public override SubStepTargets Targets {

public override bool IsActiveFor (AssemblyDefinition assembly)
{
return !Profile.IsSdkAssembly (assembly);
if (MonoAndroidHelper.IsFrameworkAssembly (assembly))
return false;

return assembly.MainModule.HasTypeReference ("Java.Interop.ExportAttribute") ||
assembly.MainModule.HasTypeReference ("Java.Interop.ExportFieldAttribute");
}

public override void ProcessField (FieldDefinition field)
Expand Down
7 changes: 2 additions & 5 deletions src/Microsoft.Android.Sdk.ILLink/PreserveJavaExceptions.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using System;
using System.Collections;
using System.Linq;

using Mono.Cecil;
using Mono.Linker;
using Mono.Linker.Steps;

using Mono.Tuner;
using Mobile.Tuner;

using Mono.Cecil;
using Xamarin.Android.Tasks;

namespace MonoDroid.Tuner {

Expand Down
52 changes: 0 additions & 52 deletions src/Microsoft.Android.Sdk.ILLink/Profile.cs

This file was deleted.

20 changes: 0 additions & 20 deletions src/Microsoft.Android.Sdk.ILLink/SetupStep.cs

This file was deleted.

8 changes: 2 additions & 6 deletions src/Microsoft.Android.Sdk.ILLink/StripEmbeddedLibraries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ protected override void ProcessAssembly (AssemblyDefinition assembly)
if (action == AssemblyAction.Skip || action == AssemblyAction.Delete)
return;

var fileName = assembly.Name.Name + ".dll";
if (MonoAndroidHelper.IsFrameworkAssembly (fileName) &&
!MonoAndroidHelper.FrameworkEmbeddedJarLookupTargets.Contains (fileName) &&
!MonoAndroidHelper.FrameworkEmbeddedNativeLibraryAssemblies.Contains (fileName))
if (MonoAndroidHelper.IsFrameworkAssembly (assembly))
return;

bool assembly_modified = false;
foreach (var mod in assembly.Modules) {
foreach (var r in mod.Resources.ToArray ()) {
if (ShouldStripResource (r)) {
Context.LogMessage ($" Stripped {r.Name} from {fileName}");
Context.LogMessage ($" Stripped {r.Name} from {assembly.Name.Name}.dll");
mod.Resources.Remove (r);
assembly_modified = true;
}
Expand Down
Loading
Loading