Update mcs/class/System.Core/System/TimeZoneInfo.cs
[mono.git] / mcs / tools / tuner / Mono.Tuner / CustomizeActions.cs
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4 using System.IO;
5 using System.Linq;
6
7 using Mono.Linker;
8 using Mono.Linker.Steps;
9
10 using Mono.Cecil;
11 using Mono.Cecil.Cil;
12
13 namespace Mono.Tuner {
14
15         public class CustomizeActions : BaseStep {
16
17                 readonly bool link_sdk_only;
18                 readonly HashSet<string> skipped_assemblies;
19
20                 public CustomizeActions (bool link_sdk_only, IEnumerable<string> skipped_assemblies)
21                 {
22                         this.link_sdk_only = link_sdk_only;
23                         this.skipped_assemblies = new HashSet<string> (skipped_assemblies);
24                 }
25
26                 protected override void ProcessAssembly (AssemblyDefinition assembly)
27                 {
28                         if (IsSkipped (assembly)) {
29                                 ProcessUserAssembly (assembly);
30                                 return;
31                         }
32
33                         if (!link_sdk_only) {
34                                 if (!Annotations.HasAction (assembly)) // stray assembly not picked up when resolving references
35                                         Annotations.SetAction (assembly, AssemblyAction.Link);
36
37                                 return;
38                         }
39
40                         if (Profile.IsSdkAssembly (assembly) || Profile.IsProductAssembly (assembly)) {
41                                 Annotations.SetAction (assembly, AssemblyAction.Link);
42                                 return;
43                         }
44
45                         ProcessUserAssembly (assembly);
46                 }
47
48                 bool IsSkipped (AssemblyDefinition assembly)
49                 {
50                         return skipped_assemblies.Contains (assembly.Name.Name);
51                 }
52
53                 void ProcessUserAssembly (AssemblyDefinition assembly)
54                 {
55                         ResolveFromAssemblyStep.ProcessLibrary (Context, assembly);
56                 }
57         }
58 }