Пример #1
0
        DTSdkSettings LoadSdkSettings(MacOSXSdkVersion sdk)
        {
            string filename = GetSdkPlistFilename(sdk.ToString());

            if (!File.Exists(filename))
            {
                return(null);
            }

            var plist    = PDictionary.FromFile(filename);
            var settings = new DTSdkSettings();

            settings.CanonicalName = plist.GetString("CanonicalName").Value;

            var props = plist.Get <PDictionary> ("DefaultProperties");

            PString gcc;

            if (!props.TryGetValue <PString> ("GCC_VERSION", out gcc))
            {
                settings.DTCompiler = "com.apple.compilers.llvm.clang.1_0";
            }
            else
            {
                settings.DTCompiler = gcc.Value;
            }

            settings.DTSDKBuild = GrabRootString(Path.Combine(DeveloperRoot, SYSTEM_VERSION_PLIST), "ProductBuildVersion");

            return(settings);
        }
Пример #2
0
 MacOSXSdkVersion ReadVersion(string versionPath)
 {
     try {
         return(MacOSXSdkVersion.Parse(File.ReadAllText(versionPath).Trim()));
     } catch (Exception ex) {
         LoggingService.LogError("Failed to read Xamarin.Mac version", ex);
         return(new MacOSXSdkVersion());
     }
 }
Пример #3
0
        static PDictionary CreateDefaultVersionsPlist(MacOSXSdkVersion version)
        {
            var versions = new PDictionary();

            versions.Add("KnownVersions", CreateKnownVersions());
            versions.Add("RecommendedXcodeVersion", new PString("8.0"));
            versions.Add("MinExtensionVersion", CreateMinExtensionVersions());
            versions.Add("Features", CreateDefaultFeatures(version));

            return(versions);
        }
Пример #4
0
 void Init()
 {
     IsInstalled = File.Exists(Path.Combine(DesktopPlatform, "Info.plist"));
     if (IsInstalled)
     {
         InstalledSdkVersions = EnumerateSdks(Path.Combine(SdkDeveloperRoot, "SDKs"), "MacOSX");
     }
     else
     {
         InstalledSdkVersions = new MacOSXSdkVersion[0];
     }
 }
Пример #5
0
 public MacOSXSdkVersion GetClosestInstalledSdk(MacOSXSdkVersion v)
 {
     // sorted low to high, so get first that's >= requested version
     foreach (var i in GetInstalledSdkVersions())
     {
         if (i.CompareTo(v) >= 0)
         {
             return(i);
         }
     }
     return(MacOSXSdkVersion.UseDefault);
 }
Пример #6
0
        public bool SdkIsInstalled(MacOSXSdkVersion version)
        {
            foreach (var v in InstalledSdkVersions)
            {
                if (v.Equals(version))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #7
0
        static MacOSXSdkVersion[] EnumerateSdks(string sdkDir, string name)
        {
            if (!Directory.Exists(sdkDir))
            {
                return(new MacOSXSdkVersion[0]);
            }

            var sdks = new List <string> ();

            foreach (var dir in Directory.GetDirectories(sdkDir))
            {
                string dirName = Path.GetFileName(dir);
                if (!dirName.StartsWith(name, StringComparison.Ordinal) || !dirName.EndsWith(".sdk", StringComparison.Ordinal))
                {
                    continue;
                }

                if (!File.Exists(Path.Combine(dir, "SDKSettings.plist")))
                {
                    continue;
                }

                int verLength = dirName.Length - (name.Length + ".sdk".Length);
                if (verLength == 0)
                {
                    continue;
                }

                dirName = dirName.Substring(name.Length, verLength);
                sdks.Add(dirName);
            }

            var vs = new List <MacOSXSdkVersion> ();

            foreach (var s in sdks)
            {
                try {
                    vs.Add(MacOSXSdkVersion.Parse(s));
                } catch (Exception ex) {
                    LoggingService.LogError("Could not parse {0} SDK version '{1}':\n{2}", name, s, ex);
                }
            }

            var versions = vs.ToArray();

            Array.Sort(versions);

            return(versions);
        }
Пример #8
0
        void NotInstalled(string pathMissing, bool error = true)
        {
            lastWriteTimes.Clear();
            IsInstalled = false;
            Version     = new MacOSXSdkVersion();

            if (error)
            {
                LoggingService.LogError("Xamarin.Mac not installed. Can't find {0}.", pathMissing);
            }
            else
            {
                LoggingService.LogInfo("Xamarin.Mac not installed. Can't find {0}.", pathMissing);
            }
        }
Пример #9
0
        MacOSXSdkVersion ReadVersion()
        {
            var versionFile = Path.Combine(SdkDir, "Version");

            if (File.Exists(versionFile))
            {
                try {
                    return(MacOSXSdkVersion.Parse(File.ReadAllText(versionFile).Trim()));
                } catch (Exception ex) {
                    LoggingService.LogError("Failed to read MonoMac version", ex);
                }
            }

            return(new MacOSXSdkVersion());
        }
Пример #10
0
        void NotInstalled(string pathMissing, bool error = true)
        {
            versions = new PDictionary();
            lastWriteTimes.Clear();
            IsInstalled = false;
            Version     = new MacOSXSdkVersion();

            SdkNotInstalledReason = string.Format("Xamarin.Mac not installed. Can't find {0}.", pathMissing);

            if (error)
            {
                LoggingService.LogError(SdkNotInstalledReason);
            }
            else
            {
                LoggingService.LogInfo(SdkNotInstalledReason);
            }
        }
Пример #11
0
        public DTSdkSettings GetSdkSettings(MacOSXSdkVersion sdk)
        {
            Dictionary <string, DTSdkSettings> cache = sdkSettingsCache;

            DTSdkSettings settings;

            if (cache.TryGetValue(sdk.ToString(), out settings))
            {
                return(settings);
            }

            try {
                settings = LoadSdkSettings(sdk);
            } catch (Exception ex) {
                LoggingService.LogError(string.Format("Error loading settings for SDK MacOSX {0}", sdk), ex);
            }

            cache[sdk.ToString()] = settings;

            return(settings);
        }
Пример #12
0
        static PArray CreateDefaultFeatures(MacOSXSdkVersion version)
        {
            var features = new PArray();

            if (version >= new MacOSXSdkVersion(1, 9, 0))
            {
                features.Add(new PString("activation"));
            }
            if (version >= new MacOSXSdkVersion(1, 11, 0) && version < new MacOSXSdkVersion(2, 5, 0))
            {
                features.Add(new PString("ref-counting"));
            }
            if (version >= new MacOSXSdkVersion(2, 5, 0))
            {
                features.Add(new PString("modern-http-client"));
            }
            if (version >= new MacOSXSdkVersion(2, 10, 0))
            {
                features.Add(new PString("mono-symbol-archive"));
            }

            return(features);
        }
Пример #13
0
        void Init()
        {
            IsInstalled = File.Exists(LegacyFrameworkAssembly);

            if (IsInstalled)
            {
                lastExeWrite = File.GetLastWriteTimeUtc(LegacyFrameworkAssembly);
                Version      = ReadVersion();
                if (Version.IsUseDefault)
                {
                    LoggingService.LogInfo("Found MonoMac.");
                }
                else
                {
                    LoggingService.LogInfo("Found MonoMac, version {0}.", Version);
                }
            }
            else
            {
                lastExeWrite = DateTime.MinValue;
                Version      = new MacOSXSdkVersion();
                LoggingService.LogInfo("MonoMac not installed. Can't find {0}.", LegacyFrameworkAssembly);
            }
        }
Пример #14
0
 public string GetSdkPath(MacOSXSdkVersion version)
 {
     return(GetSdkPath(version.ToString()));
 }