You've already forked linux-packaging-mono
Imported Upstream version 4.3.2.467
Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
@ -29,6 +29,8 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
@ -50,6 +52,32 @@ namespace Mono.Linker {
|
||||
|
||||
readonly Dictionary<object, Dictionary<IMetadataTokenProvider, object>> custom_annotations = new Dictionary<object, Dictionary<IMetadataTokenProvider, object>> ();
|
||||
|
||||
Stack<object> dependency_stack;
|
||||
System.Xml.XmlWriter writer;
|
||||
GZipStream zipStream;
|
||||
|
||||
public void PrepareDependenciesDump ()
|
||||
{
|
||||
PrepareDependenciesDump ("linker-dependencies.xml.gz");
|
||||
}
|
||||
|
||||
public void PrepareDependenciesDump (string filename)
|
||||
{
|
||||
dependency_stack = new Stack<object> ();
|
||||
System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings();
|
||||
settings.Indent = true;
|
||||
settings.IndentChars = "\t";
|
||||
var depsFile = File.OpenWrite (filename);
|
||||
zipStream = new GZipStream (depsFile, CompressionMode.Compress);
|
||||
|
||||
writer = System.Xml.XmlWriter.Create (zipStream, settings);
|
||||
writer.WriteStartDocument ();
|
||||
writer.WriteStartElement ("dependencies");
|
||||
writer.WriteStartAttribute ("version");
|
||||
writer.WriteString ("1.0");
|
||||
writer.WriteEndAttribute ();
|
||||
}
|
||||
|
||||
public AssemblyAction GetAction (AssemblyDefinition assembly)
|
||||
{
|
||||
AssemblyAction action;
|
||||
@ -86,6 +114,7 @@ namespace Mono.Linker {
|
||||
public void Mark (IMetadataTokenProvider provider)
|
||||
{
|
||||
marked.Add (provider);
|
||||
AddDependency (provider);
|
||||
}
|
||||
|
||||
public bool IsMarked (IMetadataTokenProvider provider)
|
||||
@ -237,5 +266,64 @@ namespace Mono.Linker {
|
||||
custom_annotations.Add (key, slots);
|
||||
return slots;
|
||||
}
|
||||
|
||||
public void AddDependency (object o)
|
||||
{
|
||||
if (writer == null)
|
||||
return;
|
||||
|
||||
KeyValuePair<object, object> pair = new KeyValuePair<object, object> (dependency_stack.Count > 0 ? dependency_stack.Peek () : null, o);
|
||||
writer.WriteStartElement ("edge");
|
||||
writer.WriteAttributeString ("b", TokenString (pair.Key));
|
||||
writer.WriteAttributeString ("e", TokenString (pair.Value));
|
||||
writer.WriteEndElement ();
|
||||
}
|
||||
|
||||
public void Push (object o)
|
||||
{
|
||||
if (writer == null)
|
||||
return;
|
||||
|
||||
if (dependency_stack.Count > 0)
|
||||
AddDependency (o);
|
||||
dependency_stack.Push (o);
|
||||
}
|
||||
|
||||
public void Pop ()
|
||||
{
|
||||
if (writer == null)
|
||||
return;
|
||||
|
||||
dependency_stack.Pop ();
|
||||
}
|
||||
|
||||
string TokenString (object o)
|
||||
{
|
||||
if (o == null)
|
||||
return "N:null";
|
||||
|
||||
if (o is IMetadataTokenProvider)
|
||||
return (o as IMetadataTokenProvider).MetadataToken.TokenType + ":" + o;
|
||||
|
||||
return "Other:" + o;
|
||||
}
|
||||
|
||||
public void SaveDependencies ()
|
||||
{
|
||||
if (writer == null)
|
||||
return;
|
||||
|
||||
writer.WriteEndElement ();
|
||||
writer.WriteEndDocument ();
|
||||
writer.Flush ();
|
||||
writer.Close ();
|
||||
zipStream.Close ();
|
||||
|
||||
writer.Dispose ();
|
||||
zipStream.Dispose ();
|
||||
writer = null;
|
||||
zipStream = null;
|
||||
dependency_stack = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user