public void Compile() { // Compile the managed assemblies into object files or shared libraries if (App.IsDeviceBuild) { foreach (var a in Assemblies) { a.CreateCompilationTasks(compile_tasks, BuildDirectory, Abis); } } // The static registrar. List <string> registration_methods = null; if (App.Registrar == RegistrarMode.Static) { var registrar_m = Path.Combine(ArchDirectory, "registrar.m"); var registrar_h = Path.Combine(ArchDirectory, "registrar.h"); if (!Application.IsUptodate(Assemblies.Select(v => v.FullPath), new string[] { registrar_m, registrar_h })) { StaticRegistrar.Generate(Assemblies.Select((a) => a.AssemblyDefinition), registrar_h, registrar_m); registration_methods = new List <string> (); registration_methods.Add("xamarin_create_classes"); Driver.Watch("Registrar", 1); } else { Driver.Log(3, "Target '{0}' is up-to-date.", registrar_m); } RegistrarTask.Create(compile_tasks, Abis, this, registrar_m); } if (App.Registrar == RegistrarMode.Dynamic && App.IsSimulatorBuild && App.LinkMode == LinkMode.None) { if (registration_methods == null) { registration_methods = new List <string> (); } string method; string library; switch (App.Platform) { case ApplePlatform.iOS: method = "xamarin_create_classes_Xamarin_iOS"; library = "Xamarin.iOS.registrar.a"; break; case ApplePlatform.WatchOS: method = "xamarin_create_classes_Xamarin_WatchOS"; library = "Xamarin.WatchOS.registrar.a"; break; case ApplePlatform.TVOS: method = "xamarin_create_classes_Xamarin_TVOS"; library = "Xamarin.TVOS.registrar.a"; break; default: throw ErrorHelper.CreateError(71, "Unknown platform: {0}. This usually indicates a bug in Xamarin.iOS; please file a bug report at http://bugzilla.xamarin.com with a test case.", App.Platform); } registration_methods.Add(method); link_with.Add(Path.Combine(Driver.GetProductSdkDirectory(App), "usr", "lib", library)); } // The main method. foreach (var abi in Abis) { MainTask.Create(compile_tasks, this, abi, Assemblies, App.AssemblyName, registration_methods); } // Start compiling. compile_tasks.ExecuteInParallel(); if (App.FastDev) { foreach (var a in Assemblies) { if (a.Dylibs == null) { continue; } foreach (var dylib in a.Dylibs) { LinkWith(dylib); } } } Driver.Watch("Compile", 1); }
public void Compile() { var tasks = new List <BuildTask> (); // Compile the managed assemblies into object files or shared libraries if (App.IsDeviceBuild) { foreach (var a in Assemblies) { a.CreateCompilationTasks(tasks, BuildDirectory, Abis); } } // The static registrar. List <string> registration_methods = null; if (App.Registrar == RegistrarMode.Static || App.Registrar == RegistrarMode.LegacyStatic) { var registrar_m = Path.Combine(ArchDirectory, "registrar.m"); if (!Application.IsUptodate(Assemblies.Select(v => v.FullPath), new string[] { registrar_m })) { registrar_m = Driver.RunRegistrar(this, Assemblies, BuildDirectory, BuildDirectory, App.Registrar == RegistrarMode.LegacyStatic, Is64Build, registrar_m); registration_methods = new List <string> (); registration_methods.Add("xamarin_create_classes"); Driver.Watch("Registrar", 1); } else { Driver.Log(3, "Target '{0}' is up-to-date.", registrar_m); } foreach (var abi in Abis) { RegistrarTask.Create(tasks, abi, this, registrar_m); } } if (App.Registrar == RegistrarMode.Dynamic && App.IsSimulatorBuild && App.LinkMode == LinkMode.None && App.IsUnified) { if (registration_methods == null) { registration_methods = new List <string> (); } string method; string library; switch (App.Platform) { case ApplePlatform.iOS: method = "xamarin_create_classes_Xamarin_iOS"; library = "Xamarin.iOS.registrar.a"; break; case ApplePlatform.WatchOS: method = "xamarin_create_classes_Xamarin_WatchOS"; library = "Xamarin.WatchOS.registrar.a"; break; case ApplePlatform.TVOS: method = "xamarin_create_classes_Xamarin_TVOS"; library = "Xamarin.TVOS.registrar.a"; break; default: throw ErrorHelper.CreateError(71, "Unknown platform: {0}. This usually indicates a bug in Xamarin.iOS; please file a bug report at http://bugzilla.xamarin.com with a test case.", App.Platform); } registration_methods.Add(method); link_with.Add(Path.Combine(Driver.ProductSdkDirectory, "usr", "lib", library)); if (App.Platform == ApplePlatform.iOS) { foreach (var assembly in Assemblies) { if (!assembly.IsFrameworkAssembly) { continue; } switch (Path.GetFileNameWithoutExtension(assembly.FileName)) { case "MonoTouch.Dialog-1": registration_methods.Add("xamarin_create_classes_MonoTouch_Dialog_1"); link_with.Add(Path.Combine(Driver.ProductSdkDirectory, "usr", "lib", "MonoTouch.Dialog-1.registrar.a")); break; // MonoTouch.NUnitLite doesn't quite work yet, because its generated registrar code uses types // from the generated registrar code for MonoTouch.Dialog-1 (and there is no header file (yet) // for those types). // case "MonoTouch.NUnitLite": // registration_methods.Add ("xamarin_create_classes_MonoTouch_NUnitLite"); // link_with.Add (Path.Combine (MTouch.MonoTouchIPhoneSimulatorDirectory, "usr", "lib", "MonoTouch.NUnitLite.registrar.a")); // break; } } } } // The main method. foreach (var abi in Abis) { MainTask.Create(tasks, this, abi, Assemblies, App.AssemblyName, registration_methods); } // Start compiling. if (tasks.Count > 0) { Action <BuildTask> action = null; action = (v) => { var next = v.Execute(); if (next != null) { Parallel.ForEach(next, new ParallelOptions() { MaxDegreeOfParallelism = Environment.ProcessorCount }, action); } }; Parallel.ForEach(tasks, new ParallelOptions() { MaxDegreeOfParallelism = Environment.ProcessorCount }, action); } if (App.FastDev) { foreach (var a in Assemblies) { if (a.Dylibs == null) { continue; } foreach (var dylib in a.Dylibs) { LinkWith(dylib); } } } Driver.Watch("Compile", 1); }