Beispiel #1
0
        public void InitializeCommon()
        {
            SelectRegistrar();
            SelectMonoNative();

            RuntimeOptions = RuntimeOptions.Create(this, HttpMessageHandler, TlsProvider);

            if (RequiresXcodeHeaders && SdkVersion < SdkVersions.GetVersion(this))
            {
                switch (Platform)
                {
                case ApplePlatform.iOS:
                case ApplePlatform.TVOS:
                case ApplePlatform.WatchOS:
                    throw ErrorHelper.CreateError(180, Errors.MX0180, ProductName, PlatformName, SdkVersions.GetVersion(this), SdkVersions.Xcode);

                case ApplePlatform.MacOSX:
                    throw ErrorHelper.CreateError(179, Errors.MX0179, ProductName, PlatformName, SdkVersions.GetVersion(this), SdkVersions.Xcode);

                default:
                    // Default to the iOS error message, it's better than showing MX0071 (unknown platform), which would be completely unrelated
                    goto case ApplePlatform.iOS;
                }
            }

            if (DeploymentTarget != null)
            {
                if (DeploymentTarget < Xamarin.SdkVersions.GetMinVersion(this))
                {
                    throw new ProductException(73, true, Errors.MT0073, Constants.Version, DeploymentTarget, Xamarin.SdkVersions.GetMinVersion(this), PlatformName, ProductName);
                }
                if (DeploymentTarget > Xamarin.SdkVersions.GetVersion(this))
                {
                    throw new ProductException(74, true, Errors.MX0074, Constants.Version, DeploymentTarget, Xamarin.SdkVersions.GetVersion(this), PlatformName, ProductName);
                }
            }

            if (Platform == ApplePlatform.WatchOS && EnableCoopGC.HasValue && !EnableCoopGC.Value)
            {
                throw ErrorHelper.CreateError(88, Errors.MT0088);
            }

            if (!EnableCoopGC.HasValue)
            {
                EnableCoopGC = Platform == ApplePlatform.WatchOS;
            }

            SetObjectiveCExceptionMode();
            SetManagedExceptionMode();

            if (SymbolMode == SymbolMode.Default)
            {
#if MONOTOUCH
                SymbolMode = EnableBitCode ? SymbolMode.Code : SymbolMode.Linker;
#else
                SymbolMode = SymbolMode.Linker;
#endif
            }

#if MONOTOUCH
            if (EnableBitCode && SymbolMode != SymbolMode.Code)
            {
                // This is a warning because:
                // * The user will get a linker error anyway if they do this.
                // * I see it as quite unlikely that anybody will in fact try this (it must be manually set in the additional mtouch arguments).
                // * I find it more probable that Apple will remove the -u restriction, in which case someone might actually want to try this, and if it's a warning, we won't prevent it.
                ErrorHelper.Warning(115, Errors.MT0115);
            }
#endif

            if (!DebugTrack.HasValue)
            {
                DebugTrack = false;
            }
            else if (DebugTrack.Value && !EnableDebug)
            {
                ErrorHelper.Warning(32, Errors.MT0032);
            }

            if (!package_managed_debug_symbols.HasValue)
            {
                package_managed_debug_symbols = EnableDebug;
            }
            else if (package_managed_debug_symbols.Value && IsLLVM)
            {
                ErrorHelper.Warning(3007, Errors.MX3007);
            }

            Optimizations.Initialize(this, out var messages);
            ErrorHelper.Show(messages);
            if (Driver.Verbosity > 3)
            {
                Driver.Log(4, $"Enabled optimizations: {Optimizations}");
            }
        }
Beispiel #2
0
        public void InitializeCommon()
        {
            SelectRegistrar();
            SelectMonoNative();

            RuntimeOptions = RuntimeOptions.Create(this, HttpMessageHandler, TlsProvider);

            if (RequiresXcodeHeaders && SdkVersion < SdkVersions.GetVersion(Platform))
            {
                throw ErrorHelper.CreateError(91, Errors.MX0091, ProductName, PlatformName, SdkVersions.GetVersion(Platform), SdkVersions.Xcode, Error91LinkerSuggestion);
            }

            if (DeploymentTarget != null)
            {
                if (DeploymentTarget < Xamarin.SdkVersions.GetMinVersion(Platform))
                {
                    throw new ProductException(73, true, Errors.MT0073, Constants.Version, DeploymentTarget, Xamarin.SdkVersions.GetMinVersion(Platform), PlatformName, ProductName);
                }
                if (DeploymentTarget > Xamarin.SdkVersions.GetVersion(Platform))
                {
                    throw new ProductException(74, true, Errors.MX0074, Constants.Version, DeploymentTarget, Xamarin.SdkVersions.GetVersion(Platform), PlatformName, ProductName);
                }
            }

            if (Platform == ApplePlatform.WatchOS && EnableCoopGC.HasValue && !EnableCoopGC.Value)
            {
                throw ErrorHelper.CreateError(88, Errors.MT0088);
            }

            if (!EnableCoopGC.HasValue)
            {
                EnableCoopGC = Platform == ApplePlatform.WatchOS;
            }

            if (EnableCoopGC.Value)
            {
                switch (MarshalObjectiveCExceptions)
                {
                case MarshalObjectiveCExceptionMode.UnwindManagedCode:
                case MarshalObjectiveCExceptionMode.Disable:
                    throw ErrorHelper.CreateError(89, Errors.MT0089, "--marshal-objectivec-exceptions", MarshalObjectiveCExceptions.ToString().ToLowerInvariant());
                }
                switch (MarshalManagedExceptions)
                {
                case MarshalManagedExceptionMode.UnwindNativeCode:
                case MarshalManagedExceptionMode.Disable:
                    throw ErrorHelper.CreateError(89, Errors.MT0089, "--marshal-managed-exceptions", MarshalManagedExceptions.ToString().ToLowerInvariant());
                }
            }


            bool isSimulatorOrDesktopDebug = EnableDebug;

#if MTOUCH
            isSimulatorOrDesktopDebug &= IsSimulatorBuild;
#endif

            if (MarshalObjectiveCExceptions == MarshalObjectiveCExceptionMode.Default)
            {
                if (EnableCoopGC.Value || (Platform == ApplePlatform.MacOSX && EnableDebug))
                {
                    MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.ThrowManagedException;
                }
                else
                {
                    MarshalObjectiveCExceptions = isSimulatorOrDesktopDebug ? MarshalObjectiveCExceptionMode.UnwindManagedCode : MarshalObjectiveCExceptionMode.Disable;
                }
            }

            if (MarshalManagedExceptions == MarshalManagedExceptionMode.Default)
            {
                if (EnableCoopGC.Value)
                {
                    MarshalManagedExceptions = MarshalManagedExceptionMode.ThrowObjectiveCException;
                }
                else
                {
                    MarshalManagedExceptions = isSimulatorOrDesktopDebug ? MarshalManagedExceptionMode.UnwindNativeCode : MarshalManagedExceptionMode.Disable;
                }
                IsDefaultMarshalManagedExceptionMode = true;
            }

            if (SymbolMode == SymbolMode.Default)
            {
#if MONOTOUCH
                SymbolMode = EnableBitCode ? SymbolMode.Code : SymbolMode.Linker;
#else
                SymbolMode = SymbolMode.Linker;
#endif
            }

#if MONOTOUCH
            if (EnableBitCode && SymbolMode != SymbolMode.Code)
            {
                // This is a warning because:
                // * The user will get a linker error anyway if they do this.
                // * I see it as quite unlikely that anybody will in fact try this (it must be manually set in the additional mtouch arguments).
                // * I find it more probable that Apple will remove the -u restriction, in which case someone might actually want to try this, and if it's a warning, we won't prevent it.
                ErrorHelper.Warning(115, Errors.MT0115);
            }
#endif

            if (!DebugTrack.HasValue)
            {
                DebugTrack = false;
            }
            else if (DebugTrack.Value && !EnableDebug)
            {
                ErrorHelper.Warning(32, Errors.MT0032);
            }

            if (!package_managed_debug_symbols.HasValue)
            {
                package_managed_debug_symbols = EnableDebug;
            }
            else if (package_managed_debug_symbols.Value && IsLLVM)
            {
                ErrorHelper.Warning(3007, Errors.MX3007);
            }

            Optimizations.Initialize(this);
        }