diff --git a/tools/mtouch/Assembly.cs b/tools/mtouch/Assembly.cs index 2cc37af066..33a03d365f 100644 --- a/tools/mtouch/Assembly.cs +++ b/tools/mtouch/Assembly.cs @@ -27,19 +27,33 @@ namespace Xamarin.Bundler { public List AotDataFiles = new List (); - HashSet dependencies; + HashSet dependency_map; + bool has_dependency_map; + + public bool HasDependencyMap { + get { + return has_dependency_map; + } + } public IEnumerable Dylibs { get { return dylibs; } } + public HashSet DependencyMap { + get { + return dependency_map; + } + } + // Recursively list all the assemblies the specified assembly depends on. HashSet ComputeDependencies (List warnings) { - if (dependencies != null) - return dependencies; + if (dependency_map != null) + return dependency_map; - dependencies = new HashSet (); + dependency_map = new HashSet (); + has_dependency_map = true; foreach (var ar in AssemblyDefinition.MainModule.AssemblyReferences) { var found = false; @@ -54,21 +68,28 @@ namespace Xamarin.Bundler { if (a.AssemblyDefinition.Name.Name == ar.Name) { // gotcha - if (!dependencies.Contains (a.FullPath)) { - dependencies.Add (a.FullPath); - dependencies.UnionWith (a.ComputeDependencies (warnings)); + if (!dependency_map.Contains (a.FullPath)) { + dependency_map.Add (a.FullPath); + dependency_map.UnionWith (a.ComputeDependencies (warnings)); } found = true; break; } } - if (!found) + if (!found) { warnings.Add (new MonoTouchException (3005, false, "The dependency '{0}' of the assembly '{1}' was not found. Please review the project's references.", ar.FullName, AssemblyDefinition.FullName)); + has_dependency_map = false; + } } - return dependencies; + return dependency_map; + } + + public void ComputeDependencyMap (List exceptions) + { + ComputeDependencies (exceptions); } // returns false if the assembly was not copied (because it was already up-to-date). @@ -201,19 +222,13 @@ namespace Xamarin.Bundler { if (!File.Exists (s)) throw new MonoTouchException (3004, true, "Could not AOT the assembly '{0}' because it doesn't exist.", s); - - HashSet dependencies = null; + List deps = null; List outputs = new List (); var warnings = new List (); - dependencies = ComputeDependencies (warnings); - - if (warnings.Count > 0) { - ErrorHelper.Show (warnings); - ErrorHelper.Warning (3006, "Could not compute a complete dependency map for the project. This will result in slower build times because Xamarin.iOS can't properly detect what needs to be rebuilt (and what does not need to be rebuilt). Please review previous warnings for more details."); - } else { - deps = new List (dependencies.ToArray ()); + if (has_dependency_map) { + deps = new List (dependency_map.ToArray ()); deps.Add (s); deps.Add (Driver.GetAotCompiler (App, Target.Is64Build)); } diff --git a/tools/mtouch/Target.cs b/tools/mtouch/Target.cs index 39639864f9..e3c30d2b3a 100644 --- a/tools/mtouch/Target.cs +++ b/tools/mtouch/Target.cs @@ -647,6 +647,15 @@ namespace Xamarin.Bundler public void Compile () { + // Compute the dependency map, and show warnings if there are any problems. + List exceptions = new List (); + foreach (var a in Assemblies) + a.ComputeDependencyMap (exceptions); + if (exceptions.Count > 0) { + ErrorHelper.Show (exceptions); + ErrorHelper.Warning (3006, "Could not compute a complete dependency map for the project. This will result in slower build times because Xamarin.iOS can't properly detect what needs to be rebuilt (and what does not need to be rebuilt). Please review previous warnings for more details."); + } + // Compile the managed assemblies into object files or shared libraries if (App.IsDeviceBuild) { foreach (var a in Assemblies)