Example #1
0
 public bool IsStaticBuild()
 {
     if (qtConfig == null)
     {
         qtConfig = new QtConfig(qtDir);
     }
     return(qtConfig.BuildType == BuildType.Static);
 }
Example #2
0
 public string Namespace()
 {
     if (qtConfig == null)
     {
         qtConfig = new QtConfig(qtDir);
     }
     return(qtConfig.Namespace);
 }
Example #3
0
 public bool is64Bit()
 {
     if (qtConfig == null)
     {
         qtConfig = new QtConfig(qtDir);
     }
     return(qtConfig.Is64Bit);
 }
Example #4
0
 public string LibInfix()
 {
     if (qtConfig == null)
     {
         qtConfig = new QtConfig(qtDir);
     }
     return(qtConfig.LibInfix);
 }
Example #5
0
        /// <summary>
        /// Check if all Qt versions are valid and readable.
        /// </summary>
        /// Also sets the default Qt version to the newest version, if needed.
        /// <param name="errorMessage"></param>
        /// <returns>true, if we found an invalid version</returns>
        public bool HasInvalidVersions(out string errorMessage)
        {
            var validVersions   = new Dictionary <string, QtConfig>();
            var invalidVersions = new List <string>();

            foreach (var v in GetVersions())
            {
                if (v == "$(DefaultQtVersion)")
                {
                    continue;
                }

                var vPath = GetInstallPath(v);

                if (string.IsNullOrEmpty(vPath))
                {
                    invalidVersions.Add(v);
                    continue;
                }

                if (vPath.StartsWith("SSH:") || vPath.StartsWith("WSL:"))
                {
                    continue;
                }

                var qmakePath = Path.Combine(vPath, "bin", "qmake.exe");
                if (!File.Exists(qmakePath))
                {
                    qmakePath = Path.Combine(vPath, "qmake.exe");
                }
                if (!File.Exists(qmakePath))
                {
                    invalidVersions.Add(v);
                    continue;
                }

                validVersions[v] = new QtConfig(vPath);
            }

            if (invalidVersions.Count > 0)
            {
                errorMessage = "These Qt version are inaccessible:\n";
                foreach (var invalidVersion in invalidVersions)
                {
                    errorMessage += invalidVersion + " in " + GetInstallPath(invalidVersion) + "\n";
                }
                errorMessage += "Make sure that you have read access to all files in your Qt directories.";

                // Is the default Qt version invalid?
                var isDefaultQtVersionInvalid = false;
                var defaultQtVersionName      = GetDefaultVersion();
                if (string.IsNullOrEmpty(defaultQtVersionName))
                {
                    isDefaultQtVersionInvalid = true;
                }
                else
                {
                    foreach (var name in invalidVersions)
                    {
                        if (name == defaultQtVersionName)
                        {
                            isDefaultQtVersionInvalid = true;
                            break;
                        }
                    }
                }

                // find the newest valid Qt version that can be used as default version
                if (isDefaultQtVersionInvalid && validVersions.Count > 0)
                {
                    QtConfig defaultQtVersionConfig = null;
                    foreach (var vNameConfig in validVersions)
                    {
                        var vName = vNameConfig.Key;
                        var v     = vNameConfig.Value;
                        if (defaultQtVersionConfig == null)
                        {
                            defaultQtVersionConfig = v;
                            defaultQtVersionName   = vName;
                            continue;
                        }
                        if (defaultQtVersionConfig.VersionMajor < v.VersionMajor ||
                            (defaultQtVersionConfig.VersionMajor == v.VersionMajor && (defaultQtVersionConfig.VersionMinor < v.VersionMinor ||
                                                                                       (defaultQtVersionConfig.VersionMinor == v.VersionMinor && defaultQtVersionConfig.VersionPatch < v.VersionPatch))))
                        {
                            defaultQtVersionConfig = v;
                            defaultQtVersionName   = vName;
                        }
                    }
                    if (defaultQtVersionConfig != null)
                    {
                        SaveDefaultVersion(defaultQtVersionName);
                    }
                }

                return(true);
            }
            errorMessage = null;
            return(false);
        }