Xamarin Public Jenkins (auto-signing) 6bdd276d05 Imported Upstream version 5.0.0.42
Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
2017-04-10 11:41:01 +00:00

58 lines
1.1 KiB
C#

using System;
using Mono.Linker;
using Mono.Linker.Steps;
using Mono.Cecil;
namespace Mono.Tuner {
public class RemoveResources : IStep {
readonly I18nAssemblies assemblies;
public RemoveResources (I18nAssemblies assemblies)
{
this.assemblies = assemblies;
}
public virtual void Process (LinkContext context)
{
AssemblyDefinition assembly;
if (!context.TryGetLinkedAssembly ("mscorlib", out assembly))
return;
// skip this if we're not linking mscorlib, e.g. --linkskip=mscorlib
if (context.Annotations.GetAction (assembly) != AssemblyAction.Link)
return;
var resources = assembly.MainModule.Resources;
for (int i = 0; i < resources.Count; i++) {
var resource = resources [i] as EmbeddedResource;
if (resource == null)
continue;
switch (resource.Name) {
case "collation.core.bin":
case "collation.tailoring.bin":
continue;
default:
if (!resource.Name.Contains ("cjk"))
continue;
if (IncludeCJK ())
continue;
resources.RemoveAt (i--);
break;
}
}
}
bool IncludeCJK ()
{
return (assemblies & I18nAssemblies.CJK) != 0;
}
}
}