/// <summary> /// Gets the name of the install of the library. /// </summary> /// <param name = "nativeBinary">The native binary.</param> /// <returns>The install name.</returns> public static String GetInstallName(String nativeBinary) { String arguments = String.Format(CultureInfo.InvariantCulture, "-D \"{0}\"", nativeBinary); ProcessHelper helper = new ProcessHelper(Executable, arguments); String output = helper.ExecuteAndReturnOutput (); String installName = String.Empty; Match match = OTOOL_ID_REGEX.Match(output); if (match != null && match.Success) { installName = match.Result("${library}"); } return installName; }
/// <summary> /// Gets the dependencies of the native binary. /// </summary> /// <param name = "nativeBinary">The native binary.</param> /// <returns>The dependencies list</returns> public static IEnumerable<string> GetDependencies(String nativeBinary) { String arguments = String.Format(CultureInfo.InvariantCulture, "-L \"{0}\"", nativeBinary); ProcessHelper helper = new ProcessHelper(Executable, arguments); String output = helper.ExecuteAndReturnOutput (); List<String> dependencies = new List<String>(); MatchCollection matches = OTOOL_LIST_REGEX.Matches(output); if (matches.Count > 0) { dependencies.AddRange(from Match match in matches select match.Result("${library}")); } return dependencies; }
/// <summary> /// Returns the architectures for the given file. /// </summary> /// <param name = "file">The file.</param> /// <returns>The result of the command.</returns> public static MacOSArchitecture GetArchitecture(String file) { String arguments = String.Format (CultureInfo.InvariantCulture, "-info \"{0}\"", file); ProcessHelper helper = new ProcessHelper (Executable, arguments); String output = helper.ExecuteAndReturnOutput (); MacOSArchitecture architecture = MacOSArchitecture.None; if (output.Contains ("i386")) { architecture |= MacOSArchitecture.X86; } if (output.Contains ("x86_64")) { architecture |= MacOSArchitecture.X8664; } if (output.Contains ("ppc7400")) { architecture |= MacOSArchitecture.PPC; } return architecture; }
private static String CompileInternal(String modelDir, String destinationDir) { if (FileExtensions.UpToDate(modelDir, destinationDir)) { return null; } String arguments = String.Format(CultureInfo.InvariantCulture, "\"{0}\" \"{1}\"", modelDir, destinationDir); ProcessHelper helper = new ProcessHelper(Executable, arguments); String output = helper.ExecuteAndReturnOutput(); return output; }
/// <summary> /// Generate the specified infoPlist and outputFolder. /// </summary> /// <param name='infoPlist'> /// Info plist. /// </param> /// <param name='outputFolder'> /// Output folder. /// </param> public String Generate(String infoPlist, String outputFolder) { // Load the Info.plist file PListDocument document = PListDocument.LoadFromFile (infoPlist); if (document == null) { this.Logger.LogError ("Cannot parse document: " + infoPlist); return String.Empty; } if (document.Root == null) { this.Logger.LogError ("Document has no root: " + infoPlist); return String.Empty; } if (document.Root.Dict == null) { this.Logger.LogError ("Document has no dict: " + infoPlist); return String.Empty; } // Extract bundle identifier PListString identifier = document.Root.Dict ["CFBundleIdentifier"] as PListString; if (identifier == null || String.IsNullOrWhiteSpace (identifier.Value)) { this.Logger.LogError ("Document has no 'CFBundleIdentifier': " + infoPlist); return String.Empty; } // Extract bundle version PListString version = document.Root.Dict ["CFBundleShortVersionString"] as PListString; if (version == null || String.IsNullOrWhiteSpace (version.Value)) { this.Logger.LogError ("Document has no 'CFBundleShortVersionString': " + infoPlist); return String.Empty; } // Launch the generation String file = Path.Combine (outputFolder, "receigen.h"); StringBuilder arguments = new StringBuilder (); arguments.AppendFormat (" --identifier {0} ", identifier.Value); arguments.AppendFormat (" --version {0} ", version.Value); this.Logger.LogDebug ("Calling '" + this.Executable + "' with '" + arguments + "'"); ProcessHelper helper = new ProcessHelper (this.Executable, arguments.ToString ()); String output = helper.ExecuteAndReturnOutput (); Directory.CreateDirectory(Path.GetDirectoryName(file)); File.WriteAllText(file, output); return "Done"; }
private static PListDocument CompileInternal(String xibFile, String destination) { if (FileExtensions.UpToDate(xibFile, destination)) { return null; } String arguments = String.Format(CultureInfo.InvariantCulture, "--errors --warnings --notices --compile \"{0}\" \"{1}\"", destination, xibFile); ProcessHelper helper = new ProcessHelper(Executable, arguments); String output = helper.ExecuteAndReturnOutput (); try { output = output.Trim(); PListDocument document = PListDocument.LoadFromXml(output); return document; } catch (Exception) { Console.WriteLine("XibTool cannot parse output:"); Console.WriteLine("-----"); Console.WriteLine(output); Console.WriteLine("-----"); return null; } }
private void Link(String directory, String objectFile, String outputFile, String nativeOptions, List<Dictionary<String, String>> assemblies, List<Dictionary<String, String>> configurations, Dictionary<String, String> machineConfig) { // Build the command line StringBuilder builder = new StringBuilder(); builder.AppendFormat(" {0} -L\"{1}\" ", nativeOptions, directory); builder.AppendFormat(" {0} ", this.NativeLDFLAGS ?? String.Empty); // Add the pkg-config flags for Mono String monoLibrary = this.UseSGEN ? "monosgen-2" : "mono-2"; using (ProcessHelper helper = new ProcessHelper("pkg-config", String.Format("{0} {1}", "--libs", monoLibrary))) { helper.Logger = this.Logger; String result = helper.ExecuteAndReturnOutput (); result = result.Replace("\n", String.Empty); builder.Append(result); } // Add zlib shared library if (this.Compress) { builder.Append(" -lz "); } // Add Monobjc shared library builder.AppendFormat(" -lmonobjc "); // Add all the static libraries foreach (Dictionary<string, string> dictionary in assemblies) { builder.AppendFormat(" -l{0}", dictionary[KEY_SYMBOL]); } foreach (Dictionary<string, string> dictionary in configurations) { builder.AppendFormat(" -l{0}", dictionary[KEY_SYMBOL]); } if (machineConfig != null) { builder.AppendFormat(" -l{0}", machineConfig[KEY_SYMBOL]); } // Append required framework for Receigen if (this.UseReceigen) { builder.AppendFormat(" -framework {0}", "AppKit"); builder.AppendFormat(" -framework {0}", "Foundation"); //builder.AppendFormat(" -framework {0}", "Security"); //builder.AppendFormat(" -framework {0}", "IOKit"); } builder.AppendFormat(" -o \"{0}\" \"{1}\" ", outputFile, objectFile); // TODO: I18N this.Logger.LogInfo("Linking..."); this.Logger.LogDebug(String.Format("Arguments: '{0}'", builder.ToString())); using (ProcessHelper helper = new ProcessHelper(this.NativeCompiler, builder.ToString())) { helper.Logger = this.Logger; helper.Execute(); } }
private void Compile(String directory, String sourceFile, String objectFile, String nativeOptions) { // Build the command line StringBuilder builder = new StringBuilder(); builder.AppendFormat(" -Os -gdwarf-2 {0} -I\"{1}\" ", nativeOptions, directory); builder.AppendFormat(" -c \"{0}\" -o \"{1}\" ", sourceFile, objectFile); builder.AppendFormat(" {0} ", this.NativeCFLAGS ?? String.Empty); if (this.UseReceigen) { builder.AppendFormat(" -DRECEIGEN "); } // Add the pkg-config flags for Mono String monoLibrary = this.UseSGEN ? "monosgen-2" : "mono-2"; using (ProcessHelper helper = new ProcessHelper("pkg-config", String.Format("{0} {1}", "--cflags", monoLibrary))) { helper.Logger = this.Logger; String result = helper.ExecuteAndReturnOutput (); result = result.Replace("\n", String.Empty); builder.Append(result); } // TODO: I18N this.Logger.LogInfo("Compiling..."); this.Logger.LogDebug(String.Format("Arguments: '{0}'", builder.ToString())); using (ProcessHelper helper = new ProcessHelper(this.NativeCompiler, builder.ToString())) { helper.Logger = this.Logger; helper.Execute(); } }