Exemple #1
0
 /// <summary>
 /// Read platform name from qmake.conf.
 /// </summary>
 private void SetupPlatformSpecificData(QMakeQuery qmakeQuery)
 {
     if (qmakeConf == null)
     {
         qmakeConf = new QMakeConf(this, qmakeQuery);
     }
     vsPlatformName = (is64Bit()) ? @"x64" : @"Win32";
 }
Exemple #2
0
        public bool isWinRT()
        {
            var    qmakeQuery = new QMakeQuery(this);
            string qmakeXSpec;

            try {
                qmakeXSpec = qmakeQuery["QMAKE_XSPEC"];
            } catch {
                throw new QtVSException("Error starting qmake process");
            }

            if (string.IsNullOrEmpty(qmakeXSpec))
            {
                throw new QtVSException("Error: unexpected result of qmake query");
            }

            return(qmakeXSpec.StartsWith("winrt"));
        }
Exemple #3
0
        public QMakeConf(VersionInformation versionInfo, QMakeQuery qmakeQuery = null)
        {
            Entries            = new Hashtable();
            QMakeSpecDirectory = Path.Combine(versionInfo.qtDir, "mkspecs", "default");
            var qmakeConf = Path.Combine(QMakeSpecDirectory, "qmake.conf");

            // Starting from Qt5 beta2 there is no more "\\mkspecs\\default" folder available
            // To find location of "qmake.conf" there is a need to run "qmake -query" command
            // This is what happens below.
            if (!File.Exists(qmakeConf))
            {
                if (qmakeQuery == null)
                {
                    qmakeQuery = new QMakeQuery(versionInfo);
                }

                string qtPrefix = qmakeQuery["QT_INSTALL_PREFIX"];
                if (string.IsNullOrEmpty(qtPrefix))
                {
                    throw new QtVSException("qmake error: no value for QT_INSTALL_PREFIX");
                }

                string qtArchData = qmakeQuery["QT_INSTALL_ARCHDATA"];
                if (string.IsNullOrEmpty(qtArchData))
                {
                    throw new QtVSException("qmake error: no value for QT_INSTALL_ARCHDATA");
                }

                string qmakeXSpec = qmakeQuery["QMAKE_XSPEC"];
                if (string.IsNullOrEmpty(qtArchData))
                {
                    throw new QtVSException("qmake error: no value for QMAKE_XSPEC");
                }

                qmakeConf = Path.Combine(qtPrefix, qtArchData, "mkspecs", qmakeXSpec, "qmake.conf");

                if (!File.Exists(qmakeConf))
                {
                    throw new QtVSException("qmake.conf expected at " + qmakeConf + " not found");
                }
            }

            ParseFile(qmakeConf);
        }
Exemple #4
0
        private VersionInformation(string qtDirIn)
        {
            qtDir = qtDirIn;

            try {
                var qmakeQuery = new QMakeQuery(this);
                SetupPlatformSpecificData(qmakeQuery);

                // Find version number
                var strVersion = qmakeQuery["QT_VERSION"];
                if (!string.IsNullOrEmpty(strVersion))
                {
                    var versionParts = strVersion.Split('.');
                    if (versionParts.Length != 3)
                    {
                        qtDir = null;
                        return;
                    }
                    qtMajor = uint.Parse(versionParts[0]);
                    qtMinor = uint.Parse(versionParts[1]);
                    qtPatch = uint.Parse(versionParts[2]);
                }
                else
                {
                    var inF         = new StreamReader(Locate_qglobal_h());
                    var rgxpVersion = new Regex("#define\\s*QT_VERSION\\s*0x(?<number>\\d+)", RegexOptions.Multiline);
                    var contents    = inF.ReadToEnd();
                    inF.Close();
                    var matchObj = rgxpVersion.Match(contents);
                    if (!matchObj.Success)
                    {
                        qtDir = null;
                        return;
                    }

                    strVersion = matchObj.Groups[1].ToString();
                    var version = Convert.ToUInt32(strVersion, 16);
                    qtMajor = version >> 16;
                    qtMinor = (version >> 8) & 0xFF;
                    qtPatch = version & 0xFF;
                }

                try {
                    QtInstallDocs = qmakeQuery["QT_INSTALL_DOCS"];
                } catch { }
            } catch {
                qtDir = null;
                return;
            }

            // Get VS project settings
            try {
                var tempProData = new StringBuilder();
                tempProData.AppendLine("SOURCES = main.cpp");

                var modules = QtModules.Instance.GetAvailableModules()
                              .Where((QtModule mi) => mi.Selectable);

                foreach (QtModule mi in modules)
                {
                    tempProData.AppendLine(string.Format(
                                               "qtHaveModule({0}): HEADERS += {0}.h", mi.proVarQT));
                }

                var randomName = Path.GetRandomFileName();
                var tempDir    = Path.Combine(Path.GetTempPath(), randomName);
                Directory.CreateDirectory(tempDir);

                var tempPro = Path.Combine(tempDir, string.Format("{0}.pro", randomName));
                File.WriteAllText(tempPro, tempProData.ToString());

                var qmake = new QMakeImport(this, tempPro);
                qmake.DisableWarnings = true;
                qmake.Run(setVCVars: true);

                var tempVcxproj = Path.Combine(tempDir, string.Format("{0}.vcxproj", randomName));
                var msbuildProj = MsBuildProject.Load(tempVcxproj);

                Directory.Delete(tempDir, recursive: true);

                var availableModules = msbuildProj.GetItems("ClInclude")
                                       .Select((string s) => Path.GetFileNameWithoutExtension(s));

                _IsModuleAvailable = modules.ToDictionary(
                    (QtModule mi) => mi.proVarQT,
                    (QtModule mi) => availableModules.Contains(mi.proVarQT));

                VC_MinimumVisualStudioVersion =
                    msbuildProj.GetProperty("MinimumVisualStudioVersion");
                VC_ApplicationTypeRevision =
                    msbuildProj.GetProperty("ApplicationTypeRevision");
                VC_WindowsTargetPlatformVersion =
                    msbuildProj.GetProperty("WindowsTargetPlatformVersion");
                VC_WindowsTargetPlatformMinVersion =
                    msbuildProj.GetProperty("WindowsTargetPlatformMinVersion");
                VC_PlatformToolset =
                    msbuildProj.GetProperty("PlatformToolset");
                VC_Link_TargetMachine =
                    msbuildProj.GetProperty("Link", "TargetMachine");
            } catch (Exception e) {
                throw new QtVSException("Error reading VS project settings", e);
            }
        }