예제 #1
0
 private static void ParseCmdOptions(string[] args)
 {
     // Initialize possible options
     // http://www.ndesk.org/Options for more info
     optionsParser.Add("t|test=", "The name|id of the {test} to be executed.", v => testName = v);
     optionsParser.Add("r|repeat=", "The number of {TIMES} to repeat the test tin a single loop to get the total timming.\nThis must be an integer.\nDefault to 1000.", v => loopCount = Int32.Parse(v));
     optionsParser.Add("h|?|help", "Help with options descriptions", v => ShowHelp());
     optionsParser.Add("q|quiet", "Application will only display errors messages", o => ConfigureLog("ERROR"));
     optionsParser.Add("v|verbose", "Application will only display errors messages", o => ConfigureLog("TRACE"));
     // Parse options
     try
     {
         parsedOptions = optionsParser.Parse(args);
         foreach (var i in parsedOptions)
         {
             Console.WriteLine(i);
         }
     }
     catch (Mono.Options.OptionException e)
     {
         logger.Error("Error parsing argument options", e);
         Console.WriteLine("Invalid options: ");
         Console.WriteLine(e.Message);
         Console.WriteLine();
         Console.WriteLine("Try '--help' for more information.");
         ApplicationExit(-1);
     }
 }
예제 #2
0
 public WindowsPathResolver()
 {
     m_options = new Mono.Options.OptionSet();
     m_options.Add("v|verbose", "Verbose mode", v => { m_verbose = true; });
     m_options.Add("f|file", "Want file resolution", v => { m_resolution = Resolution.File; });
     m_options.Add("d|directory", "Want directory resolution", v => { m_resolution = Resolution.Directory; });
     m_options.Add("cmake", "CMake style path", v => { m_path_style = PathStyle.CMake; });
     m_options.Add("h|help", "Show help page", v => { m_show_help = true; });
 }
예제 #3
0
        public ParametersModel Parse(string[] args)
        {
            var p = new ParametersModel();
              var options = new Mono.Options.OptionSet();

              options.Add("h|help", "prints the help", s => p.Action = ActionType.WriteDescription);
              options.Add("v|vault=", "use the specified vault", s => p.Vault = s);
              options.Add("u|user="******"use the specified user", s => p.User = s);
              options.Add("s|server=", "use the specified server", s => p.Server = s);
              options.Add("p|password="******"use the specified password", s => p.Password = s);
              options.Add("destroy-by-class=", "destroy objects of the following classes, use Comma ',' as a separator for multiple classes",
            s => {
              p.Action = ActionType.DestroyObjectsOfClasses;
              p.DestroyObjectOfClasses = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            });
              options.Add("destroy-by-objecttype=", "destroy objects of the specified object types, use Comma ',' as a separator for multiple classes",
            s =>
            {
              p.Action = ActionType.DestroyObjectsOfObjectTypes;
              p.DestroyObjectsOfObjectTypes = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            });
              options.Add("lc|list-classes", "list all classes and their object counts", s => p.Action = ActionType.ListClassesAndObjects);
              options.Add("lo|list-objecttypes", "list all object types and their object counts", s => p.Action = ActionType.ListObjectTypesAndObjects);

              options.Parse(args);
              p.Options = options;
              return p;
        }
예제 #4
0
        public ParametersModel Parse(string[] args)
        {
            var p       = new ParametersModel();
            var options = new Mono.Options.OptionSet();

            options.Add("h|help", "prints the help", s => p.Action                   = ActionType.WriteDescription);
            options.Add("v|vault=", "use the specified vault", s => p.Vault          = s);
            options.Add("u|user="******"use the specified user", s => p.User             = s);
            options.Add("s|server=", "use the specified server", s => p.Server       = s);
            options.Add("p|password="******"use the specified password", s => p.Password = s);
            options.Add("destroy-by-class=", "destroy objects of the following classes, use Comma ',' as a separator for multiple classes",
                        s => {
                p.Action = ActionType.DestroyObjectsOfClasses;
                p.DestroyObjectOfClasses = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            });
            options.Add("destroy-by-objecttype=", "destroy objects of the specified object types, use Comma ',' as a separator for multiple classes",
                        s =>
            {
                p.Action = ActionType.DestroyObjectsOfObjectTypes;
                p.DestroyObjectsOfObjectTypes = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            });
            options.Add("lc|list-classes", "list all classes and their object counts", s => p.Action          = ActionType.ListClassesAndObjects);
            options.Add("lo|list-objecttypes", "list all object types and their object counts", s => p.Action = ActionType.ListObjectTypesAndObjects);

            options.Parse(args);
            p.Options = options;
            return(p);
        }
예제 #5
0
    public ParametersModel GetParameters(string[] args)
    {
      var p = new ParametersModel();
      var optionSet = new Mono.Options.OptionSet();

      optionSet.Add("s=|source-file", "specify the source file to watch", s => p.SourceFile = s);
      optionSet.Add("t=|target-file", "specify the target file path", s => p.TargetFile = s);
      optionSet.Add("?|h|help", "prints this description", s => p.Action = ActionType.Help);
      p.OptionSet = optionSet;

      optionSet.Parse(args);

      return p;
    }
예제 #6
0
        void SetupStartupOptions()
        {
            var args = Environment.GetCommandLineArgs();

            var p = new Mono.Options.OptionSet();

            p.Add("unityProcessId=", "Unity Process Id", (int i) => StartupOptions.UnityProcessId        = i);
            p.Add("unityRestServerUrl=", "Unity REST Server URL", s => StartupOptions.UnityRestServerUrl = s);

            LoggingService.Log(MonoDevelop.Core.Logging.LogLevel.Info, "ARGS: " + String.Join("!", args));

            try
            {
                p.Parse(args);
            }
            catch (Mono.Options.OptionException e)
            {
                LoggingService.LogInfo("OptionException: " + e.ToString());
            }

            LoggingService.LogInfo("Unity Process ID: " + StartupOptions.UnityProcessId);
            LoggingService.LogInfo("Unity REST Server Url: " + StartupOptions.UnityRestServerUrl);
        }
		void SetupStartupOptions ()
		{
			var args = Environment.GetCommandLineArgs ();

			var p = new Mono.Options.OptionSet ();
			p.Add ("unityProcessId=", "Unity Process Id", (int i) => StartupOptions.UnityProcessId = i);
			p.Add("unityRestServerUrl=", "Unity REST Server URL", s => StartupOptions.UnityRestServerUrl = s);

			LoggingService.Log (MonoDevelop.Core.Logging.LogLevel.Info, "ARGS: " + String.Join("!",args));

			try 
			{
				p.Parse (args);
			} 
			catch(Mono.Options.OptionException e)
			{
				LoggingService.LogInfo("OptionException: " + e.ToString());
			}

			LoggingService.LogInfo("Unity Process ID: " + StartupOptions.UnityProcessId);
			LoggingService.LogInfo("Unity REST Server Url: " + StartupOptions.UnityRestServerUrl);
		}
예제 #8
0
        static void AddSharedOptions(Application app, Mono.Options.OptionSet options)
        {
            options.Add("warnaserror:", "An optional comma-separated list of warning codes that should be reported as errors (if no warnings are specified all warnings are reported as errors).", v =>
            {
                try {
                    if (!string.IsNullOrEmpty(v))
                    {
                        foreach (var code in v.Split(new char [] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            ErrorHelper.SetWarningLevel(ErrorHelper.WarningLevel.Error, int.Parse(code));
                        }
                    }
                    else
                    {
                        ErrorHelper.SetWarningLevel(ErrorHelper.WarningLevel.Error);
                    }
                } catch (Exception ex) {
                    ErrorHelper.Error(26, ex, "Could not parse the command line argument '{0}': {1}", "--warnaserror", ex.Message);
                }
            });
            options.Add("nowarn:", "An optional comma-separated list of warning codes to ignore (if no warnings are specified all warnings are ignored).", v =>
            {
                try {
                    if (!string.IsNullOrEmpty(v))
                    {
                        foreach (var code in v.Split(new char [] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            ErrorHelper.SetWarningLevel(ErrorHelper.WarningLevel.Disable, int.Parse(code));
                        }
                    }
                    else
                    {
                        ErrorHelper.SetWarningLevel(ErrorHelper.WarningLevel.Disable);
                    }
                } catch (Exception ex) {
                    ErrorHelper.Error(26, ex, "Could not parse the command line argument '{0}': {1}", "--nowarn", ex.Message);
                }
            });
            options.Add("coop:", "If the GC should run in cooperative mode.", v => { app.EnableCoopGC = ParseBool(v, "coop"); }, hidden: true);
            options.Add("sgen-conc", "Enable the *experimental* concurrent garbage collector.", v => { app.EnableSGenConc = true; });
            options.Add("marshal-objectivec-exceptions:", "Specify how Objective-C exceptions should be marshalled. Valid values: default, unwindmanagedcode, throwmanagedexception, abort and disable. The default depends on the target platform (on watchOS the default is 'throwmanagedexception', while on all other platforms it's 'disable').", v => {
                switch (v)
                {
                case "default":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.Default;
                    break;

                case "unwindmanaged":
                case "unwindmanagedcode":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.UnwindManagedCode;
                    break;

                case "throwmanaged":
                case "throwmanagedexception":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.ThrowManagedException;
                    break;

                case "abort":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.Abort;
                    break;

                case "disable":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.Disable;
                    break;

                default:
                    throw ErrorHelper.CreateError(26, "Could not parse the command line argument '{0}': {1}", "--marshal-objective-exceptions", $"Invalid value: {v}. Valid values are: default, unwindmanagedcode, throwmanagedexception, abort and disable.");
                }
            });
            options.Add("marshal-managed-exceptions:", "Specify how managed exceptions should be marshalled. Valid values: default, unwindnativecode, throwobjectivecexception, abort and disable. The default depends on the target platform (on watchOS the default is 'throwobjectivecexception', while on all other platform it's 'disable').", v => {
                switch (v)
                {
                case "default":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.Default;
                    break;

                case "unwindnative":
                case "unwindnativecode":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.UnwindNativeCode;
                    break;

                case "throwobjectivec":
                case "throwobjectivecexception":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.ThrowObjectiveCException;
                    break;

                case "abort":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.Abort;
                    break;

                case "disable":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.Disable;
                    break;

                default:
                    throw ErrorHelper.CreateError(26, "Could not parse the command line argument '{0}': {1}", "--marshal-managed-exceptions", $"Invalid value: {v}. Valid values are: default, unwindnativecode, throwobjectivecexception, abort and disable.");
                }
            });
            options.Add("j|jobs=", "The level of concurrency. Default is the number of processors.", v => {
                Jobs = int.Parse(v);
            });
            options.Add("embeddinator", "Enables Embeddinator targetting mode.", v => {
                app.Embeddinator = true;
            }, true);
            options.Add("dynamic-symbol-mode:", "Specify how dynamic symbols are treated so that they're not linked away by the native linker. Valid values: linker (pass \"-u symbol\" to the native linker), code (generate native code that uses the dynamic symbol), ignore (do nothing and hope for the best). The default is 'code' when using bitcode, and 'linker' otherwise.", (v) => {
                switch (v.ToLowerInvariant())
                {
                case "default":
                    app.SymbolMode = SymbolMode.Default;
                    break;

                case "linker":
                    app.SymbolMode = SymbolMode.Linker;
                    break;

                case "code":
                    app.SymbolMode = SymbolMode.Code;
                    break;

                case "ignore":
                    app.SymbolMode = SymbolMode.Ignore;
                    break;

                default:
                    throw ErrorHelper.CreateError(26, "Could not parse the command line argument '{0}': {1}", "--dynamic-symbol-mode", $"Invalid value: {v}. Valid values are: default, linker, code and ignore.");
                }
            });
            options.Add("ignore-dynamic-symbol:", "Specify that Xamarin.iOS/Xamarin.Mac should not try to prevent the linker from removing the specified symbol.", (v) => {
                app.IgnoredSymbols.Add(v);
            });
        }
예제 #9
0
        static void AddSharedOptions(Mono.Options.OptionSet options)
        {
            options.Add("coop:", "If the GC should run in cooperative mode.", v => { App.EnableCoopGC = ParseBool(v, "coop"); }, hidden: true);
            options.Add("marshal-objectivec-exceptions:", v => {
                switch (v)
                {
                case "default":
                    App.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.Default;
                    break;

                case "unwindmanaged":
                case "unwindmanagedcode":
                    App.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.UnwindManagedCode;
                    break;

                case "throwmanaged":
                case "throwmanagedexception":
                    App.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.ThrowManagedException;
                    break;

                case "abort":
                    App.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.Abort;
                    break;

                case "disable":
                    App.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.Disable;
                    break;

                default:
                    throw ErrorHelper.CreateError(26, "Could not parse the command line argument '{0}': {1}", "--marshal-objective-exceptions", "Invalid value: " + v);
                }
            });
            options.Add("marshal-managed-exceptions:", v => {
                switch (v)
                {
                case "default":
                    App.MarshalManagedExceptions = MarshalManagedExceptionMode.Default;
                    break;

                case "unwindnative":
                case "unwindnativecode":
                    App.MarshalManagedExceptions = MarshalManagedExceptionMode.UnwindNativeCode;
                    break;

                case "throwobjectivec":
                case "throwobjectivecexception":
                    App.MarshalManagedExceptions = MarshalManagedExceptionMode.ThrowObjectiveCException;
                    break;

                case "abort":
                    App.MarshalManagedExceptions = MarshalManagedExceptionMode.Abort;
                    break;

                case "disable":
                    App.MarshalManagedExceptions = MarshalManagedExceptionMode.Disable;
                    break;

                default:
                    throw ErrorHelper.CreateError(26, "Could not parse the command line argument '{0}': {1}", "--marshal-managed-exceptions", "Invalid value: " + v);
                }
            });
        }
예제 #10
0
        static void Main(string[] args)
        {
            Mono.Options.OptionSet opt_set = new Mono.Options.OptionSet();

            bool   show_help     = false;
            string project       = null;
            string path          = null;
            string vstudio_name  = null;
            bool   remove_suffix = true;

            opt_set.Add("h|help|?", "help message", v => { show_help = true; });
            opt_set.Add("path=", "path of vcproj project", (string s) => path       = s);
            opt_set.Add("project=", "vcproj project", (string s) => project         = s);
            opt_set.Add("visual=", "Visual Studio name", (string s) => vstudio_name = s);
            opt_set.Add("dont-remove-suffix", "Don't remove suffix to name", v => { remove_suffix = false; });

            opt_set.Parse(args);

            if (show_help)
            {
                showHelp(opt_set);
            }

            if (project == null)
            {
                Console.Error.WriteLine("Error : no project specified");
                showHelp(opt_set);
            }

            if (path == null)
            {
                Console.Error.WriteLine("Error : no path specified");
                showHelp(opt_set);
            }

            if (vstudio_name == null)
            {
                Console.Error.WriteLine("Error : no visual studio name specified");
                showHelp(opt_set);
            }

            VisualStudioKind vstudio = VisualStudioKind.Undef;

            if (vstudio_name == "Visual Studio 9 2008 Win64")
            {
                vstudio = VisualStudioKind.VCProj;
            }
            else if (vstudio_name == "Visual Studio 10 Win64")
            {
                vstudio = VisualStudioKind.VCXProj;
            }
            else if (vstudio_name == "Visual Studio 11 Win64")
            {
                vstudio = VisualStudioKind.VCXProj;
            }
            else if (vstudio_name == "Visual Studio 12 Win64")
            {
                vstudio = VisualStudioKind.VCXProj;
            }
            else if (vstudio_name == "Visual Studio 12 2013 Win64")
            {
                vstudio = VisualStudioKind.VCXProj;
            }
            else
            {
                Console.Error.WriteLine("Unknown visual studio name '{0}'", vstudio_name);
                Environment.Exit(-1);
            }

            string suffix = "";

            if (vstudio == VisualStudioKind.VCProj)
            {
                suffix = ".vcxproj";
            }
            else if (vstudio == VisualStudioKind.VCXProj)
            {
                suffix = ".vcxproj";
            }

            string filename = Path.Combine(path, project);

            if (remove_suffix)
            {
                filename = Path.ChangeExtension(filename, suffix);
            }
            else
            {
                filename = filename + suffix;
            }

            Console.WriteLine("Apply Whole Archive patch on MS Visual studio project '{0}'", filename);

            XmlDocument         vcprojXml = new XmlDocument();
            XmlNamespaceManager nsMgr     = new XmlNamespaceManager(new NameTable()); // pour la gestion des namespaces (VS2010 et +)

            try
            {
                vcprojXml.Load(filename);
                vcprojXml.Save(filename + ".backup");
            }
            catch (System.IO.FileNotFoundException e)
            {
                Console.Error.WriteLine(e.Message);
                Environment.Exit(-1);
            }
            catch (XmlException e)
            {
                Console.Error.WriteLine(e.Message);
                Environment.Exit(-1);
            }

            if (vstudio == VisualStudioKind.VCProj)
            {
                XmlNodeList configs = vcprojXml.SelectNodes("VisualStudioProject/Configurations/Configuration/Tool[@Name='VCLinkerTool']");
                foreach (XmlElement config in configs)
                {
                    // TODO les exceoptions ...
                    config.Attributes["LinkLibraryDependencies"].Value = "true";
                    config.SetAttribute("UseLibraryDependencyInputs", "true");
                }
                Console.Error.WriteLine("WARNING: ignoring libcmt library not implemented");
            }
            else if (vstudio == VisualStudioKind.VCXProj)
            {
                const string namespaceURI = "http://schemas.microsoft.com/developer/msbuild/2003";
                nsMgr.AddNamespace("msb", namespaceURI);

                XmlNodeList project_configs = vcprojXml.SelectNodes(@"/msb:Project/msb:ItemDefinitionGroup/msb:ProjectReference", nsMgr);

                foreach (XmlNode config in project_configs)
                {
                    // TODO les exceoptions ...
                    config.SelectOrCreateChild("msb", "LinkLibraryDependencies", nsMgr).InnerText    = "true";
                    config.SelectOrCreateChild("msb", "UseLibraryDependencyInputs", nsMgr).InnerText = "true";
                }

                XmlNodeList link_configs = vcprojXml.SelectNodes(@"/msb:Project/msb:ItemDefinitionGroup/msb:Link", nsMgr);

                foreach (XmlNode config in link_configs)
                {
                    // TODO les exceoptions ...
                    config.SelectOrCreateChild("msb", "IgnoreSpecificDefaultLibraries", nsMgr).InnerText = "libcmt.lib";
                }
            }

            try
            {
                vcprojXml.Save(filename);
            }
            catch (XmlException e)
            {
                Console.Error.WriteLine(e.Message);
                Environment.Exit(-1);
            }
        }
예제 #11
0
        public static void Main(string[] args)
        {
            bool show_help  = false;
            bool verbose    = false;
            bool add_prefix = false;

            Mono.Options.OptionSet opt_set = new Mono.Options.OptionSet();
            opt_set.Add("h|help|?", "help message", v => { show_help = true; });
            opt_set.Add("v|verbose", "verbose mode", v => { verbose = true; });
            opt_set.Add("add_prefix", "add xml prefix", v => { add_prefix = true; });
            string[] remaining_args = opt_set.Parse(args).ToArray();

            if (show_help || remaining_args.Length != 2)
            {
                showHelp(opt_set);
            }
            string pkglist_file = remaining_args[0];
            string output_file  = remaining_args[1];

            if (verbose)
            {
                Console.WriteLine("Loading {0} into {1}", pkglist_file, output_file);
            }

            string prefix = "";

            if (add_prefix)
            {
                prefix = "XML_";
            }

            XmlDocument document = new XmlDocument();

            document.Load(pkglist_file);

            StringBuilder buffer = new StringBuilder();

            buffer.Append("#\n# Generated file -- DO NOT EDIT --\n#\n\n");

            XmlNodeList   packages     = document.SelectNodes(string.Format("//packages/package[@available='true']"));
            List <string> package_list = new List <string>();

            foreach (XmlNode package_node in packages)
            {
                XmlElement package = package_node as XmlElement;
                String     name    = package.GetAttribute("name");
                if (name.StartsWith("arcane_"))
                {
                    continue;                                             // skips arcane libraries
                }
                if (verbose)
                {
                    Console.WriteLine("Loading delegated package {0}...", name);
                }
                String cmake_name = ToUpperCaseName(name);
                package_list.Add(cmake_name);

                buffer.AppendFormat("set({0}{1}_FOUND \"YES\")\n", prefix, cmake_name);
                buffer.AppendFormat("set({0}{1}_NAME \"{2}\")\n", prefix, cmake_name, name);
                XmlNodeList libraries = package.SelectNodes("lib-name");
                if (libraries.Count > 0)
                {
                    buffer.AppendFormat("set({0}{1}_LIBRARIES ", prefix, cmake_name);
                    foreach (XmlNode lib in libraries)
                    {
                        buffer.AppendFormat("\"{0}\" ", lib.InnerText);
                    }
                    buffer.Append(")\n");
                }

                XmlNodeList includes = package.SelectNodes("include");
                if (includes.Count > 0)
                {
                    buffer.AppendFormat("set({0}{1}_INCLUDE_DIRS ", prefix, cmake_name);
                    foreach (XmlNode inc in includes)
                    {
                        buffer.AppendFormat("\"{0}\" ", inc.InnerText);
                    }
                    buffer.Append(")\n");
                }

                XmlNodeList flags = package.SelectNodes("flags");
                if (flags.Count > 0)
                {
                    buffer.AppendFormat("set({0}{1}_FLAGS ", prefix, cmake_name);
                    foreach (XmlNode flag in flags)
                    {
                        buffer.AppendFormat("\"{0}\" ", flag.InnerText);
                    }
                    buffer.Append(")\n");
                }

                XmlNodeList target = package.SelectNodes("target-name");
                if (target.Count > 0)
                {
                    buffer.AppendFormat("set({0}{1}_TARGET_NAME ", prefix, cmake_name);
                    foreach (XmlNode t in target)
                    {
                        buffer.AppendFormat("\"{0}\" ", t.InnerText);
                    }
                    buffer.Append(")\n");
                }
            }

            buffer.Append("set(DELEGATED_DEPENDENCIES ");
            buffer.Append(string.Join(" ", package_list.ToArray()));
            buffer.Append(")\n");

            File.WriteAllText(output_file, buffer.ToString());
        }
예제 #12
0
        public static void Main(string[] args)
        {
            bool show_help = false;
            bool verbose   = false;

            Mono.Options.OptionSet opt_set = new Mono.Options.OptionSet();
            opt_set.Add("h|help|?", "help message", v => { show_help = true; });
            opt_set.Add("v|verbose", "verbose mode", v => { verbose = true; });
            string[] remaining_args = opt_set.Parse(args).ToArray();

            if (show_help || remaining_args.Length != 2)
            {
                showHelp(opt_set);
            }
            string pkglist_file = remaining_args[0];
            string output_file  = remaining_args[1];

            if (verbose)
            {
                Console.WriteLine("Loading {0} into {1}", pkglist_file, output_file);
            }

            var document = new XmlDocument();

            document.Load(pkglist_file);

            var packages = document.SelectNodes(string.Format("//packages/package[@available='true']"));

            var paths  = new List <String> ();
            var macros = new List <String> ();

            foreach (XmlNode package in packages)
            {
                var includes = package.SelectNodes(string.Format("include"));

                foreach (XmlNode include in includes)
                {
                    paths.Add(include.InnerText);
                }

                var defines = package.SelectNodes(string.Format("flags"));

                foreach (XmlNode define in defines)
                {
                    macros.Add(define.InnerText);
                }
            }

            var doc = new XmlDocument();

            doc.LoadXml(
                "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" +
                "<cdtprojectproperties>" +
                "<section name=\"org.eclipse.cdt.internal.ui.wizards.settingswizards.IncludePaths\">" +
                "<language name=\"C++ Source File\" />" +
                "</section>" +
                "<section name=\"org.eclipse.cdt.internal.ui.wizards.settingswizards.Macros\">" +
                "<language name=\"C++ Source File\" />" +
                "</section>" +
                "</cdtprojectproperties>"
                );

            XmlNode include_node = doc.SelectSingleNode(string.Format("//cdtprojectproperties/section[@name='org.eclipse.cdt.internal.ui.wizards.settingswizards.IncludePaths']/language"));

            foreach (var path in paths)
            {
                XmlElement p = doc.CreateElement("includepath");
                p.InnerText = path;
                include_node.AppendChild(p);
            }

            XmlNode define_node = doc.SelectSingleNode(string.Format("//cdtprojectproperties/section[@name='org.eclipse.cdt.internal.ui.wizards.settingswizards.Macros']/language"));

            foreach (var macro in macros)
            {
                XmlElement p = doc.CreateElement("macro");
                XmlElement n = doc.CreateElement("name");
                XmlElement v = doc.CreateElement("value");
                n.InnerText = macro;
                p.AppendChild(n);
                p.AppendChild(v);
                define_node.AppendChild(p);
            }

            doc.Save(output_file);
        }
예제 #13
0
        static void AddSharedOptions(Application app, Mono.Options.OptionSet options)
        {
            options.Add("warnaserror:", "An optional comma-separated list of warning codes that should be reported as errors (if no warnings are specified all warnings are reported as errors).", v =>
            {
                try {
                    if (!string.IsNullOrEmpty(v))
                    {
                        foreach (var code in v.Split(new char [] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            ErrorHelper.SetWarningLevel(ErrorHelper.WarningLevel.Error, int.Parse(code));
                        }
                    }
                    else
                    {
                        ErrorHelper.SetWarningLevel(ErrorHelper.WarningLevel.Error);
                    }
                } catch (Exception ex) {
                    ErrorHelper.Error(26, ex, "Could not parse the command line argument '{0}': {1}", "--warnaserror", ex.Message);
                }
            });
            options.Add("nowarn:", "An optional comma-separated list of warning codes to ignore (if no warnings are specified all warnings are ignored).", v =>
            {
                try {
                    if (!string.IsNullOrEmpty(v))
                    {
                        foreach (var code in v.Split(new char [] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            ErrorHelper.SetWarningLevel(ErrorHelper.WarningLevel.Disable, int.Parse(code));
                        }
                    }
                    else
                    {
                        ErrorHelper.SetWarningLevel(ErrorHelper.WarningLevel.Disable);
                    }
                } catch (Exception ex) {
                    ErrorHelper.Error(26, ex, "Could not parse the command line argument '{0}': {1}", "--nowarn", ex.Message);
                }
            });
            options.Add("coop:", "If the GC should run in cooperative mode.", v => { app.EnableCoopGC = ParseBool(v, "coop"); }, hidden: true);
            options.Add("sgen-conc", "Enable the *experimental* concurrent garbage collector.", v => { app.EnableSGenConc = true; });
            options.Add("marshal-objectivec-exceptions:", "Specify how Objective-C exceptions should be marshalled. Valid values: default, unwindmanagedcode, throwmanagedexception, abort and disable. The default depends on the target platform (on watchOS the default is 'throwmanagedexception', while on all other platforms it's 'disable').", v => {
                switch (v)
                {
                case "default":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.Default;
                    break;

                case "unwindmanaged":
                case "unwindmanagedcode":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.UnwindManagedCode;
                    break;

                case "throwmanaged":
                case "throwmanagedexception":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.ThrowManagedException;
                    break;

                case "abort":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.Abort;
                    break;

                case "disable":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.Disable;
                    break;

                default:
                    throw ErrorHelper.CreateError(26, "Could not parse the command line argument '{0}': {1}", "--marshal-objective-exceptions", $"Invalid value: {v}. Valid values are: default, unwindmanagedcode, throwmanagedexception, abort and disable.");
                }
            });
            options.Add("marshal-managed-exceptions:", "Specify how managed exceptions should be marshalled. Valid values: default, unwindnativecode, throwobjectivecexception, abort and disable. The default depends on the target platform (on watchOS the default is 'throwobjectivecexception', while on all other platform it's 'disable').", v => {
                switch (v)
                {
                case "default":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.Default;
                    break;

                case "unwindnative":
                case "unwindnativecode":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.UnwindNativeCode;
                    break;

                case "throwobjectivec":
                case "throwobjectivecexception":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.ThrowObjectiveCException;
                    break;

                case "abort":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.Abort;
                    break;

                case "disable":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.Disable;
                    break;

                default:
                    throw ErrorHelper.CreateError(26, "Could not parse the command line argument '{0}': {1}", "--marshal-managed-exceptions", $"Invalid value: {v}. Valid values are: default, unwindnativecode, throwobjectivecexception, abort and disable.");
                }
            });
            options.Add("j|jobs=", "The level of concurrency. Default is the number of processors.", v => {
                Jobs = int.Parse(v);
            });
        }
예제 #14
0
        static void AddSharedOptions(Application app, Mono.Options.OptionSet options)
        {
            options.Add("sdkroot=", "Specify the location of Apple SDKs, default to 'xcode-select' value.", v => sdk_root = v);
            options.Add("no-xcode-version-check", "Ignores the Xcode version check.", v => { min_xcode_version = null; }, true /* This is a non-documented option. Please discuss any customers running into the xcode version check on the maciosdev@ list before giving this option out to customers. */);
            options.Add("warnaserror:", "An optional comma-separated list of warning codes that should be reported as errors (if no warnings are specified all warnings are reported as errors).", v =>
            {
                try {
                    if (!string.IsNullOrEmpty(v))
                    {
                        foreach (var code in v.Split(new char [] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            ErrorHelper.SetWarningLevel(ErrorHelper.WarningLevel.Error, int.Parse(code));
                        }
                    }
                    else
                    {
                        ErrorHelper.SetWarningLevel(ErrorHelper.WarningLevel.Error);
                    }
                } catch (Exception ex) {
                    ErrorHelper.Error(26, ex, "Could not parse the command line argument '{0}': {1}", "--warnaserror", ex.Message);
                }
            });
            options.Add("nowarn:", "An optional comma-separated list of warning codes to ignore (if no warnings are specified all warnings are ignored).", v =>
            {
                try {
                    if (!string.IsNullOrEmpty(v))
                    {
                        foreach (var code in v.Split(new char [] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            ErrorHelper.SetWarningLevel(ErrorHelper.WarningLevel.Disable, int.Parse(code));
                        }
                    }
                    else
                    {
                        ErrorHelper.SetWarningLevel(ErrorHelper.WarningLevel.Disable);
                    }
                } catch (Exception ex) {
                    ErrorHelper.Error(26, ex, "Could not parse the command line argument '{0}': {1}", "--nowarn", ex.Message);
                }
            });
            options.Add("coop:", "If the GC should run in cooperative mode.", v => { app.EnableCoopGC = ParseBool(v, "coop"); }, hidden: true);
            options.Add("sgen-conc", "Enable the *experimental* concurrent garbage collector.", v => { app.EnableSGenConc = true; });
            options.Add("marshal-objectivec-exceptions:", "Specify how Objective-C exceptions should be marshalled. Valid values: default, unwindmanagedcode, throwmanagedexception, abort and disable. The default depends on the target platform (on watchOS the default is 'throwmanagedexception', while on all other platforms it's 'disable').", v => {
                switch (v)
                {
                case "default":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.Default;
                    break;

                case "unwindmanaged":
                case "unwindmanagedcode":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.UnwindManagedCode;
                    break;

                case "throwmanaged":
                case "throwmanagedexception":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.ThrowManagedException;
                    break;

                case "abort":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.Abort;
                    break;

                case "disable":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.Disable;
                    break;

                default:
                    throw ErrorHelper.CreateError(26, "Could not parse the command line argument '{0}': {1}", "--marshal-objective-exceptions", $"Invalid value: {v}. Valid values are: default, unwindmanagedcode, throwmanagedexception, abort and disable.");
                }
            });
            options.Add("marshal-managed-exceptions:", "Specify how managed exceptions should be marshalled. Valid values: default, unwindnativecode, throwobjectivecexception, abort and disable. The default depends on the target platform (on watchOS the default is 'throwobjectivecexception', while on all other platform it's 'disable').", v => {
                switch (v)
                {
                case "default":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.Default;
                    break;

                case "unwindnative":
                case "unwindnativecode":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.UnwindNativeCode;
                    break;

                case "throwobjectivec":
                case "throwobjectivecexception":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.ThrowObjectiveCException;
                    break;

                case "abort":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.Abort;
                    break;

                case "disable":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.Disable;
                    break;

                default:
                    throw ErrorHelper.CreateError(26, "Could not parse the command line argument '{0}': {1}", "--marshal-managed-exceptions", $"Invalid value: {v}. Valid values are: default, unwindnativecode, throwobjectivecexception, abort and disable.");
                }
            });
            options.Add("j|jobs=", "The level of concurrency. Default is the number of processors.", v => {
                Jobs = int.Parse(v);
            });
            options.Add("embeddinator", "Enables Embeddinator targetting mode.", v => {
                app.Embeddinator = true;
            }, true);
            options.Add("dynamic-symbol-mode:", "Specify how dynamic symbols are treated so that they're not linked away by the native linker. Valid values: linker (pass \"-u symbol\" to the native linker), code (generate native code that uses the dynamic symbol), ignore (do nothing and hope for the best). The default is 'code' when using bitcode, and 'linker' otherwise.", (v) => {
                switch (v.ToLowerInvariant())
                {
                case "default":
                    app.SymbolMode = SymbolMode.Default;
                    break;

                case "linker":
                    app.SymbolMode = SymbolMode.Linker;
                    break;

                case "code":
                    app.SymbolMode = SymbolMode.Code;
                    break;

                case "ignore":
                    app.SymbolMode = SymbolMode.Ignore;
                    break;

                default:
                    throw ErrorHelper.CreateError(26, "Could not parse the command line argument '{0}': {1}", "--dynamic-symbol-mode", $"Invalid value: {v}. Valid values are: default, linker, code and ignore.");
                }
            });
            options.Add("ignore-dynamic-symbol:", "Specify that Xamarin.iOS/Xamarin.Mac should not try to prevent the linker from removing the specified symbol.", (v) => {
                app.IgnoredSymbols.Add(v);
            });
            options.Add("root-assembly=", "Specifies any root assemblies. There must be at least one root assembly, usually the main executable.", (v) => {
                app.RootAssemblies.Add(v);
            });
            options.Add("optimize=", "A comma-delimited list of optimizations to enable/disable. To enable an optimization, use --optimize=[+]remove-uithread-checks. To disable an optimizations: --optimize=-remove-uithread-checks. Use '+all' to enable or '-all' disable all optimizations. Only compiler-generated code or code otherwise marked as safe to optimize will be optimized.\n" +
                        "Available optimizations:\n" +
                        "    dead-code-elimination: By default always enabled (requires the linker). Removes IL instructions the linker can determine will never be executed. This is most useful in combination with the inline-* optimizations, since inlined conditions almost always also results in blocks of code that will never be executed.\n" +
                        "    remove-uithread-checks: By default enabled for release builds (requires the linker). Remove all UI Thread checks (makes the app smaller, and slightly faster at runtime).\n" +
#if MONOTOUCH
                        "    inline-isdirectbinding: By default enabled (requires the linker). Tries to inline calls to NSObject.IsDirectBinding to load a constant value. Makes the app smaller, and slightly faster at runtime.\n" +
#else
                        "    inline-isdirectbinding: By default disabled, because it may require the linker. Tries to inline calls to NSObject.IsDirectBinding to load a constant value. Makes the app smaller, and slightly faster at runtime.\n" +
#endif
#if MONOTOUCH
                        "    remove-dynamic-registrar: By default enabled when the static registrar is enabled. Removes the dynamic registrar (makes the app smaller).\n" +
                        "    inline-runtime-arch: By default always enabled (requires the linker). Inlines calls to ObjCRuntime.Runtime.Arch to load a constant value. Makes the app smaller, and slightly faster at runtime.\n" +
#endif
                        "    blockliteral-setupblock: By default enabled when using the static registrar. Optimizes calls to BlockLiteral.SetupBlock to avoid having to calculate the block signature at runtime.\n" +
                        "    inline-intptr-size: By default enabled for builds that target a single architecture (requires the linker). Inlines calls to IntPtr.Size to load a constant value. Makes the app smaller, and slightly faster at runtime.\n" +
                        "    inline-dynamic-registration-supported: By default always enabled (requires the linker). Optimizes calls to Runtime.DynamicRegistrationSupported to be a constant value. Makes the app smaller, and slightly faster at runtime.\n" +
                        "    register-protocols: Remove unneeded metadata for protocol support. Makes the app smaller and reduces memory requirements.\n" +
#if !MONOTOUCH
                        "    trim-architectures: Remove unneeded architectures from bundled native libraries. Makes the app smaller and is required for macOS App Store submissions.\n" +
#else
                        "    remove-unsupported-il-for-bitcode: Remove IL that is not supported when compiling to bitcode, and replace with a NotSupportedException.\n" +
#endif
                        "",
                        (v) => {
                app.Optimizations.Parse(v);
            });
            options.Add(new Mono.Options.ResponseFileSource());
        }
예제 #15
0
        static void AddSharedOptions(Application app, Mono.Options.OptionSet options)
        {
            options.Add("coop:", "If the GC should run in cooperative mode.", v => { app.EnableCoopGC = ParseBool(v, "coop"); }, hidden: true);
            options.Add("sgen-conc", "Enable the concurrent garbage collector.", v => { app.EnableSGenConc = true; });
            options.Add("marshal-objectivec-exceptions:", "Specify how Objective-C exceptions should be marshalled. Valid values: default, unwindmanagedcode, throwmanagedexception, abort and disable. The default depends on the target platform (on watchOS the default is 'throwmanagedexception', while on all other platforms it's 'disable').", v => {
                switch (v)
                {
                case "default":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.Default;
                    break;

                case "unwindmanaged":
                case "unwindmanagedcode":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.UnwindManagedCode;
                    break;

                case "throwmanaged":
                case "throwmanagedexception":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.ThrowManagedException;
                    break;

                case "abort":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.Abort;
                    break;

                case "disable":
                    app.MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.Disable;
                    break;

                default:
                    throw ErrorHelper.CreateError(26, "Could not parse the command line argument '{0}': {1}", "--marshal-objective-exceptions", $"Invalid value: {v}. Valid values are: default, unwindmanagedcode, throwmanagedexception, abort and disable.");
                }
            });
            options.Add("marshal-managed-exceptions:", "Specify how managed exceptions should be marshalled. Valid values: default, unwindnativecode, throwobjectivecexception, abort and disable. The default depends on the target platform (on watchOS the default is 'throwobjectivecexception', while on all other platform it's 'disable').", v => {
                switch (v)
                {
                case "default":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.Default;
                    break;

                case "unwindnative":
                case "unwindnativecode":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.UnwindNativeCode;
                    break;

                case "throwobjectivec":
                case "throwobjectivecexception":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.ThrowObjectiveCException;
                    break;

                case "abort":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.Abort;
                    break;

                case "disable":
                    app.MarshalManagedExceptions = MarshalManagedExceptionMode.Disable;
                    break;

                default:
                    throw ErrorHelper.CreateError(26, "Could not parse the command line argument '{0}': {1}", "--marshal-managed-exceptions", $"Invalid value: {v}. Valid values are: default, unwindnativecode, throwobjectivecexception, abort and disable.");
                }
            });
            options.Add("j|jobs=", "The level of concurrency. Default is the number of processors.", v => {
                Jobs = int.Parse(v);
            });
        }
예제 #16
0
    public ParametersModel Parse(string[] args)
    {
      var p = new ParametersModel();
      var options = new Mono.Options.OptionSet();

      options.Add("h|help", "prints the help", s => p.Action = ActionType.WriteDescripton);
      options.Add("t|test-connection", "tries to connect to the server using the specified credentials", s => p.Action = ActionType.TestConnection);
      options.Add("b|base-folder=", "use the supplied directory as the base folder for the import", s => p.BaseFolder = s);
      options.Add("v|vault=", "use the specified vault", s => p.Vault = s);
      options.Add("u|user="******"use the specified user", s => p.User = s);
      options.Add("s|server=", "use the specified server", s => p.Server = s);
      options.Add("p|password="******"use the specified password", s => p.Password = s);
      options.Add("c|csv=", "import based on the csv file", s => { p.Action = ActionType.CsvImport; p.CsvImportFile = s; });
      options.Add("d|delimiter=", "csv delimiter", s => p.Delimiter = s);
      options.Add("destroy-by-class=", "destroy objects of the following classes, use Comma ',' as a separator for multiple classes",
        s => { 
          p.Action = ActionType.DestroyObjectsOfClasses;
          p.DestroyObjectOfClasses = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
        });
      options.Add("destroy-by-objecttype=", "destroy objects of the specified object types, use Comma ',' as a separator for multiple classes",
        s =>
        {
          p.Action = ActionType.DestroyObjectsOfObjectTypes;
          p.DestroyObjectsOfObjectTypes = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
        });
      options.Add("lc|list-classes", "list all classes and their object counts", s => p.Action = ActionType.ListClassesAndObjects);
      options.Add("lo|list-objecttypes", "list all object types and their object counts", s => p.Action = ActionType.ListObjectTypesAndObjects);

      options.Parse(args);
      p.Options = options;
      return p;
    }