public Collect ( String assembly ) : IEnumerable |
||
assembly | String | |
Résultat | IEnumerable |
/// <summary> /// Gets all assemblies to embed. /// </summary> private List<String> GetAssemblies() { List<String> assemblies = new List<String>(); // Create the collector ManagedReferenceCollector collector = new ManagedReferenceCollector(); collector.Logger = new ExecutionLogger(this); collector.SearchDirectories = this.SearchDirectories.Select(f => f.ItemSpec).ToList(); // Collect the main assembly references assemblies.AddRange(collector.Collect(this.MainAssembly.ToString())); // Collect the additionnal assemblies references foreach (String includeAssembly in this.IncludedAssemblies.Select(f => f.ItemSpec).ToList()) { assemblies.AddRange(collector.Collect(includeAssembly)); } // Remove redundant entries assemblies = assemblies.Distinct().ToList(); // Remove excluded assemblies List<String> excludes = this.ExcludedAssemblies.Select(f => Path.GetFileName(f.ItemSpec)).ToList(); assemblies = assemblies.Where(assembly => !excludes.Contains(Path.GetFileName(assembly))).ToList(); return assemblies; }
private static void GenerateNative(IProgressMonitor monitor, BuildResult result, MonobjcProject project, ConfigurationSelector configuration, BundleMaker maker) { // Create a directory for generation String tempDir = Path.Combine(project.GetOutputFileName(configuration).ParentDirectory, ".native"); Directory.CreateDirectory(tempDir); // Build a list of all folders to visit when collecting managed references String mainAssembly = project.GetOutputFileName(configuration); String configurationDir = Path.GetDirectoryName(mainAssembly); List<String> searchDirs = new List<String>(); searchDirs.Add(configurationDir); // For each reference, add its base dir foreach (ProjectReference reference in project.References) { String[] files = reference.GetReferencedFileNames(configuration); foreach (string file in files) { String dir = Path.GetDirectoryName(file); searchDirs.Add(dir); } } // Remove redundant entries searchDirs = searchDirs.Distinct().ToList(); // Collect all the assemblies monitor.BeginTask(GettextCatalog.GetString("Collecting assemblies..."), 0); ManagedReferenceCollector collector = new ManagedReferenceCollector(); collector.Logger = new BuildLogger(monitor, result); collector.SearchDirectories = searchDirs; monitor.EndTask(); // Collect the main assembly references List<String> assemblies = new List<String>(); assemblies.AddRange(collector.Collect(mainAssembly)); // Remove redundant entries assemblies = assemblies.Distinct().ToList(); // Generate the embedded executable monitor.BeginTask(GettextCatalog.GetString("Generating native code..."), 0); NativeCodeGenerator codeGenerator = new NativeCodeGenerator(); codeGenerator.Logger = new BuildLogger(monitor, result); codeGenerator.Assemblies = assemblies; codeGenerator.DeveloperToolsFolder = DeveloperToolsDesktopApplication.DeveloperToolsFolder; codeGenerator.TargetOSVersion = project.TargetOSVersion; codeGenerator.TargetArchitecture = project.TargetOSArch; // We embed the machine.config file; it depends on the target framework int version = (int) project.TargetFramework.ClrVersion; switch (version) { case 2: // ClrVersion.Net_2_0: codeGenerator.MachineConfiguration = "/Library/Frameworks/Mono.framework/Home/etc/mono/2.0/machine.config"; break; case 4: // ClrVersion.Net_4_0: codeGenerator.MachineConfiguration = "/Library/Frameworks/Mono.framework/Home/etc/mono/4.0/machine.config"; break; case 5: // ClrVersion.Net_4_5: codeGenerator.MachineConfiguration = "/Library/Frameworks/Mono.framework/Home/etc/mono/4.5/machine.config"; break; } // Launch the generation String executableFile = codeGenerator.Generate(tempDir); String libraryFile = Path.Combine(tempDir, "libmonobjc.dylib"); monitor.EndTask(); // Copy the native parts into the bundle monitor.BeginTask(GettextCatalog.GetString("Copying native code..."), 0); maker.CopyTo(executableFile, maker.MacOSDirectory); maker.CopyTo(libraryFile, maker.MacOSDirectory); monitor.EndTask(); // Change the paths executableFile = maker.Combine(maker.MacOSDirectory, executableFile); libraryFile = maker.Combine(maker.MacOSDirectory, libraryFile); // Relocate the libraries monitor.BeginTask(GettextCatalog.GetString("Relocating native code..."), 0); NativeCodeRelocator relocator = new NativeCodeRelocator(); relocator.Logger = new BuildLogger(monitor, result); relocator.DependencyPattern = new List<string> {"Mono.framework"}; relocator.Relocate(executableFile, maker.MacOSDirectory); relocator.Relocate(libraryFile, maker.MacOSDirectory); monitor.EndTask(); }