コード例 #1
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);
            });
        }
コード例 #2
0
ファイル: Driver.cs プロジェクト: seyi/xamarin-macios
        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);
            });
        }
コード例 #3
0
ファイル: Driver.cs プロジェクト: wbsabc/xamarin-macios
        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());
        }