[mtouch] Fix --dot:<path> to honor the path passed. (#5626)
Also change output to use the full path to files as nodes, instead of just the filename, and instead use a label to set what's shown to just the filename. This makes the graph correct when we have multiple files with the same name, but different paths.
This commit is contained in:
Родитель
ffda8b93ba
Коммит
bfab0ee22a
|
@ -74,7 +74,7 @@ namespace Xamarin.Bundler
|
|||
throw new AggregateException (exceptions);
|
||||
}
|
||||
|
||||
public void Dot (string file)
|
||||
public void Dot (Application app, string file)
|
||||
{
|
||||
var nodes = new HashSet<string> ();
|
||||
var queue = new Queue<BuildTask> (this);
|
||||
|
@ -82,12 +82,17 @@ namespace Xamarin.Bundler
|
|||
var action_nodes = new HashSet<string> ();
|
||||
var output_nodes = new HashSet<string> ();
|
||||
var all_nodes = new HashSet<string> ();
|
||||
var all_files = new HashSet<string> ();
|
||||
var circular_ref_nodes = new HashSet<string> ();
|
||||
|
||||
var render_file = new Func<string, string> ((v) =>
|
||||
{
|
||||
if (Path.GetDirectoryName (v).EndsWith (".framework", StringComparison.Ordinal))
|
||||
return Path.GetFileName (Path.GetDirectoryName (v));
|
||||
v = Path.GetDirectoryName (v);
|
||||
var cache = v.IndexOf (app.Cache.Location, StringComparison.Ordinal);
|
||||
if (cache >= 0)
|
||||
return v.Substring (app.Cache.Location.Length).TrimStart (Path.DirectorySeparatorChar);
|
||||
|
||||
return Path.GetFileName (v);
|
||||
});
|
||||
|
||||
|
@ -110,22 +115,28 @@ namespace Xamarin.Bundler
|
|||
action_nodes.Add (action_node);
|
||||
|
||||
var inputs = task.Inputs.ToArray ();
|
||||
all_files.UnionWith (inputs);
|
||||
for (int i = 0; i < inputs.Length; i++) {
|
||||
var node = $"\"{render_file (inputs [i])}\"";
|
||||
var node = $"\"{inputs [i]}\"";
|
||||
all_nodes.Add (node);
|
||||
input_nodes.Add (node);
|
||||
nodes.Add ($"{node} -> {action_node}");
|
||||
}
|
||||
|
||||
var outputs = task.Outputs.ToArray ();
|
||||
all_files.UnionWith (outputs);
|
||||
for (int i = 0; i < outputs.Length; i++) {
|
||||
var node = $"\"{render_file (outputs [i])}\"";
|
||||
var node = $"\"{outputs [i]}\"";
|
||||
all_nodes.Add (node);
|
||||
output_nodes.Add (node);
|
||||
nodes.Add ($"{action_node} -> {node}");
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var af in all_files) {
|
||||
nodes.Add ($"\"{af}\" [label=\"{render_file (af)}\"]");
|
||||
}
|
||||
|
||||
using (var writer = new StreamWriter (file)) {
|
||||
writer.WriteLine ("digraph build {");
|
||||
writer.WriteLine ("\trankdir=LR;");
|
||||
|
|
|
@ -890,8 +890,8 @@ namespace Xamarin.Bundler {
|
|||
CompilePInvokeWrappers ();
|
||||
BuildApp ();
|
||||
|
||||
if (Driver.Dot)
|
||||
build_tasks.Dot (Path.Combine (Cache.Location, "build.dot"));
|
||||
if (Driver.DotFile != null)
|
||||
build_tasks.Dot (this, Driver.DotFile.Length > 0 ? Driver.DotFile : Path.Combine (Cache.Location, "build.dot"));
|
||||
|
||||
Driver.Watch ("Building build tasks", 1);
|
||||
build_tasks.Execute ();
|
||||
|
|
|
@ -123,15 +123,15 @@ namespace Xamarin.Bundler
|
|||
//
|
||||
// Output generation
|
||||
static bool force = false;
|
||||
static bool dot;
|
||||
static string dotfile;
|
||||
static string cross_prefix = Environment.GetEnvironmentVariable ("MONO_CROSS_PREFIX");
|
||||
static string extra_args = Environment.GetEnvironmentVariable ("MTOUCH_ENV_OPTIONS");
|
||||
|
||||
static int verbose = GetDefaultVerbosity ();
|
||||
|
||||
public static bool Dot {
|
||||
public static string DotFile {
|
||||
get {
|
||||
return dot;
|
||||
return dotfile;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -919,7 +919,7 @@ namespace Xamarin.Bundler
|
|||
{ "h|?|help", "Displays the help", v => SetAction (Action.Help) },
|
||||
{ "version", "Output version information and exit.", v => SetAction (Action.Version) },
|
||||
{ "f|force", "Forces the recompilation of code, regardless of timestamps", v=>force = true },
|
||||
{ "dot:", "Generate a dot file to visualize the build tree.", v => dot = true },
|
||||
{ "dot:", "Generate a dot file to visualize the build tree.", v => dotfile = v ?? string.Empty },
|
||||
{ "cache=", "Specify the directory where object files will be cached", v => app.Cache.Location = v },
|
||||
{ "aot=", "Arguments to the static compiler",
|
||||
v => app.AotArguments = v + (v.EndsWith (",", StringComparison.Ordinal) ? String.Empty : ",") + app.AotArguments
|
||||
|
|
Загрузка…
Ссылка в новой задаче