diff --git a/tools/common/BuildTasks.cs b/tools/common/BuildTasks.cs index 105734041d..85011a846c 100644 --- a/tools/common/BuildTasks.cs +++ b/tools/common/BuildTasks.cs @@ -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 (); var queue = new Queue (this); @@ -82,12 +82,17 @@ namespace Xamarin.Bundler var action_nodes = new HashSet (); var output_nodes = new HashSet (); var all_nodes = new HashSet (); + var all_files = new HashSet (); var circular_ref_nodes = new HashSet (); var render_file = new Func ((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;"); diff --git a/tools/mtouch/Application.cs b/tools/mtouch/Application.cs index c16bc2f411..d59f8b613d 100644 --- a/tools/mtouch/Application.cs +++ b/tools/mtouch/Application.cs @@ -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 (); diff --git a/tools/mtouch/mtouch.cs b/tools/mtouch/mtouch.cs index 281476b89e..af35ac242d 100644 --- a/tools/mtouch/mtouch.cs +++ b/tools/mtouch/mtouch.cs @@ -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