diff options
Diffstat (limited to 'qmake/generators/win32')
-rw-r--r-- | qmake/generators/win32/msbuild_objectmodel.cpp | 4 | ||||
-rw-r--r-- | qmake/generators/win32/msbuild_objectmodel.h | 3 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_nmake.cpp | 64 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_nmake.h | 1 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_objectmodel.cpp | 33 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_objectmodel.h | 5 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_vcproj.cpp | 132 |
7 files changed, 82 insertions, 160 deletions
diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index 9cc125d396..129fb28e01 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -614,7 +614,6 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) << attrTag("Label", "ProjectConfigurations"); bool isWinRT = false; - bool isWinPhone = false; for (int i = 0; i < tool.SingleProjects.count(); ++i) { xml << tag("ProjectConfiguration") << attrTag("Include" , tool.SingleProjects.at(i).Configuration.Name) @@ -622,7 +621,6 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) << tagValue("Platform", tool.SingleProjects.at(i).PlatformName) << closetag(); isWinRT = isWinRT || tool.SingleProjects.at(i).Configuration.WinRT; - isWinPhone = isWinPhone || tool.SingleProjects.at(i).Configuration.WinPhone; } xml << closetag() @@ -636,7 +634,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) xml << tagValue("MinimumVisualStudioVersion", tool.Version) << tagValue("DefaultLanguage", "en") << tagValue("AppContainerApplication", "true") - << tagValue("ApplicationType", isWinPhone ? "Windows Phone" : "Windows Store") + << tagValue("ApplicationType", "Windows Store") << tagValue("ApplicationTypeRevision", tool.SdkVersion); if (tool.SdkVersion == "10.0") { const QString ucrtVersion = qgetenv("UCRTVERSION"); diff --git a/qmake/generators/win32/msbuild_objectmodel.h b/qmake/generators/win32/msbuild_objectmodel.h index 4bec517fa6..2e77537916 100644 --- a/qmake/generators/win32/msbuild_objectmodel.h +++ b/qmake/generators/win32/msbuild_objectmodel.h @@ -32,12 +32,9 @@ #include "project.h" #include "xmloutput.h" #include "msvc_objectmodel.h" -#include <qatomic.h> #include <qlist.h> #include <qstring.h> -#include <qstringlist.h> #include <qmap.h> -#include <qdebug.h> QT_BEGIN_NAMESPACE diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 92043e829f..8ac462da6b 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -124,7 +124,6 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) return false; } - const bool isPhone = project->isActiveConfig(QStringLiteral("winphone")); #ifdef Q_OS_WIN QString regKey; if (msvcVer == QStringLiteral("15.0")) @@ -137,12 +136,7 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) return false; } - QString windowsPath; - if (isPhone) { - windowsPath = "Software\\Microsoft\\Microsoft SDKs\\WindowsPhoneApp\\v"; - } else { - windowsPath = "Software\\Microsoft\\Microsoft SDKs\\Windows\\v"; - } + const QString windowsPath = "Software\\Microsoft\\Microsoft SDKs\\Windows\\v"; regKey = windowsPath + winsdkVer + QStringLiteral("\\InstallationFolder"); const QString kitDir = qt_readRegistryKey(HKEY_LOCAL_MACHINE, regKey, KEY_WOW64_32KEY); @@ -228,23 +222,6 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) libDirs << crtLib + QStringLiteral("/ucrt/") + arch; libDirs << crtLib + QStringLiteral("/um/") + arch; - } else if (isPhone) { - QString sdkDir = vcInstallDir; - if (!QDir(sdkDir).exists()) { - fprintf(stderr, "Failed to find the Windows Phone SDK in %s.\n" - "Check that it is properly installed.\n", - qPrintable(QDir::toNativeSeparators(sdkDir))); - return false; - } - incDirs << sdkDir + QStringLiteral("/include"); - libDirs << sdkDir + QStringLiteral("/lib/store/") + compilerArch - << sdkDir + QStringLiteral("/lib/") + compilerArch; - binDirs << sdkDir + QStringLiteral("/bin/") + compiler; - libDirs << kitDir + QStringLiteral("/lib/") + arch; - incDirs << kitDir + QStringLiteral("/include") - << kitDir + QStringLiteral("/include/abi") - << kitDir + QStringLiteral("/include/mincore") - << kitDir + QStringLiteral("/include/minwin"); } else { incDirs << vcInstallDir + QStringLiteral("/include"); libDirs << vcInstallDir + QStringLiteral("/lib/store/") + compilerArch @@ -589,9 +566,9 @@ void NmakeMakefileGenerator::writeBuildRulesPart(QTextStream &t) if(!project->isEmpty("QMAKE_PRE_LINK")) t << "\n\t" <<var("QMAKE_PRE_LINK"); if(project->isActiveConfig("staticlib")) { - t << "\n\t$(LIBAPP) $(LIBFLAGS) " << var("QMAKE_LINK_O_FLAG") << "$(DESTDIR_TARGET) @<<\n\t " - << "$(OBJECTS)" - << "\n<<"; + t << "\n\t$(LIBAPP) $(LIBFLAGS) " << var("QMAKE_LINK_O_FLAG") << "$(DESTDIR_TARGET) @<<\n\t "; + writeResponseFileFiles(t, project->values("OBJECTS")); + t << "<<"; } else { const bool embedManifest = ((templateName == "app" && project->isActiveConfig("embed_manifest_exe")) || (templateName == "lib" && project->isActiveConfig("embed_manifest_dll") @@ -675,11 +652,36 @@ void NmakeMakefileGenerator::writeLinkCommand(QTextStream &t, const QString &ext t << "$(LINKER) $(LFLAGS)"; if (!extraFlags.isEmpty()) t << ' ' << extraFlags; - t << " " << var("QMAKE_LINK_O_FLAG") << "$(DESTDIR_TARGET) @<<\n" - << "$(OBJECTS) $(LIBS)"; + t << " " << var("QMAKE_LINK_O_FLAG") << "$(DESTDIR_TARGET) @<<\n"; + writeResponseFileFiles(t, project->values("OBJECTS")); + t << "$(LIBS)\n"; if (!extraInlineFileContent.isEmpty()) - t << ' ' << extraInlineFileContent; - t << "\n<<"; + t << extraInlineFileContent << '\n'; + t << "<<"; +} + +void NmakeMakefileGenerator::writeResponseFileFiles(QTextStream &t, const ProStringList &files) +{ + // Add line breaks in file lists in reponse files to work around LNK1170. + // The actual line length limit is 131070, but let's use a smaller limit + // in case other tools are similarly hampered. + const int maxLineLength = 1000; + int len = 0; + for (const ProString &file : files) { + const ProString escapedFilePath = escapeFilePath(file); + if (len) { + if (len + escapedFilePath.length() > maxLineLength) { + t << '\n'; + len = 0; + } else { + t << ' '; + len++; + } + } + t << escapedFilePath; + len += escapedFilePath.length(); + } + t << '\n'; } int NmakeMakefileGenerator::msvcVersion() const diff --git a/qmake/generators/win32/msvc_nmake.h b/qmake/generators/win32/msvc_nmake.h index 9c88934e36..f782f9d734 100644 --- a/qmake/generators/win32/msvc_nmake.h +++ b/qmake/generators/win32/msvc_nmake.h @@ -40,6 +40,7 @@ class NmakeMakefileGenerator : public Win32MakefileGenerator void writeImplicitRulesPart(QTextStream &t); void writeBuildRulesPart(QTextStream &t); void writeLinkCommand(QTextStream &t, const QString &extraFlags = QString(), const QString &extraInlineFileContent = QString()); + void writeResponseFileFiles(QTextStream &t, const ProStringList &files); int msvcVersion() const; void init(); static QStringList sourceFilesForImplicitRulesFilter(); diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index ac57a3379c..60734b4d1b 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -33,13 +33,43 @@ #include <ioutils.h> #include <qscopedpointer.h> -#include <qstringlist.h> #include <qfileinfo.h> using namespace QMakeInternal; QT_BEGIN_NAMESPACE +static DotNET vsVersionFromString(const char *versionString) +{ + struct VSVersionMapping + { + const char *str; + DotNET version; + }; + static VSVersionMapping mapping[] = { + "7.0", NET2002, + "7.1", NET2003, + "8.0", NET2005, + "9.0", NET2008, + "10.0", NET2010, + "11.0", NET2012, + "12.0", NET2013, + "14.0", NET2015, + "15.0", NET2017 + }; + DotNET result = NETUnknown; + for (const auto entry : mapping) { + if (strcmp(entry.str, versionString) == 0) + return entry.version; + } + return result; +} + +DotNET vsVersionFromString(const ProString &versionString) +{ + return vsVersionFromString(versionString.toLatin1().constData()); +} + // XML Tags --------------------------------------------------------- const char _Configuration[] = "Configuration"; const char _Configurations[] = "Configurations"; @@ -2136,7 +2166,6 @@ VCPreLinkEventTool::VCPreLinkEventTool() VCConfiguration::VCConfiguration() : WinRT(false), - WinPhone(false), ATLMinimizesCRunTimeLibraryUsage(unset), BuildBrowserInformation(unset), CharacterSet(charSetNotSet), diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h index f9734e8e1b..10d44970ff 100644 --- a/qmake/generators/win32/msvc_objectmodel.h +++ b/qmake/generators/win32/msvc_objectmodel.h @@ -34,7 +34,6 @@ #include <proitems.h> -#include <qatomic.h> #include <qlist.h> #include <qstring.h> #include <qstringlist.h> @@ -56,6 +55,8 @@ enum DotNET { NET2017 = 0xe0 }; +DotNET vsVersionFromString(const ProString &versionString); + /* This Object model is of course VERY simplyfied, and does not actually follow the original MSVC @@ -869,7 +870,7 @@ public: bool suppressUnknownOptionWarnings; DotNET CompilerVersion; - bool WinRT, WinPhone; + bool WinRT; // Variables triState ATLMinimizesCRunTimeLibraryUsage; diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index a7312d0124..48b8bea812 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -35,7 +35,6 @@ #include <qdir.h> #include <qdiriterator.h> #include <qcryptographichash.h> -#include <qregexp.h> #include <qhash.h> #include <quuid.h> @@ -57,98 +56,6 @@ const char _GUIDFormFiles[] = "{99349809-55BA-4b9d-BF79-8FDBB0286EB3} const char _GUIDExtraCompilerFiles[] = "{E0D8C965-CC5F-43d7-AD63-FAEF0BBC0F85}"; const char _GUIDDeploymentFiles[] = "{D9D6E243-F8AF-46E4-B9FD-80ECBC20BA3E}"; const char _GUIDDistributionFiles[] = "{B83CAF91-C7BF-462F-B76C-EA11631F866C}"; -QT_END_NAMESPACE - -#ifdef Q_OS_WIN32 -#include <qt_windows.h> -#include <registry_p.h> - -QT_BEGIN_NAMESPACE - -struct DotNetCombo { - DotNET version; - const char *versionStr; - const char *regKey; -} dotNetCombo[] = { - {NET2017, "MSVC.NET 2017 (15.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VS7\\15.0"}, - {NET2015, "MSVC.NET 2015 (14.0)", "Software\\Microsoft\\VisualStudio\\14.0\\Setup\\VC\\ProductDir"}, - {NET2013, "MSVC.NET 2013 (12.0)", "Software\\Microsoft\\VisualStudio\\12.0\\Setup\\VC\\ProductDir"}, - {NET2013, "MSVC.NET 2013 Express Edition (12.0)", "Software\\Microsoft\\VCExpress\\12.0\\Setup\\VC\\ProductDir"}, - {NET2012, "MSVC.NET 2012 (11.0)", "Software\\Microsoft\\VisualStudio\\11.0\\Setup\\VC\\ProductDir"}, - {NET2012, "MSVC.NET 2012 Express Edition (11.0)", "Software\\Microsoft\\VCExpress\\11.0\\Setup\\VC\\ProductDir"}, - {NET2010, "MSVC.NET 2010 (10.0)", "Software\\Microsoft\\VisualStudio\\10.0\\Setup\\VC\\ProductDir"}, - {NET2010, "MSVC.NET 2010 Express Edition (10.0)", "Software\\Microsoft\\VCExpress\\10.0\\Setup\\VC\\ProductDir"}, - {NET2008, "MSVC.NET 2008 (9.0)", "Software\\Microsoft\\VisualStudio\\9.0\\Setup\\VC\\ProductDir"}, - {NET2008, "MSVC.NET 2008 Express Edition (9.0)", "Software\\Microsoft\\VCExpress\\9.0\\Setup\\VC\\ProductDir"}, - {NET2005, "MSVC.NET 2005 (8.0)", "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir"}, - {NET2005, "MSVC.NET 2005 Express Edition (8.0)", "Software\\Microsoft\\VCExpress\\8.0\\Setup\\VC\\ProductDir"}, - {NET2003, "MSVC.NET 2003 (7.1)", "Software\\Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir"}, - {NET2002, "MSVC.NET 2002 (7.0)", "Software\\Microsoft\\VisualStudio\\7.0\\Setup\\VC\\ProductDir"}, - {NETUnknown, "", ""}, -}; - -QT_END_NAMESPACE -#endif - -QT_BEGIN_NAMESPACE -DotNET which_dotnet_version(const QByteArray &preferredVersion = QByteArray()) -{ -#ifndef Q_OS_WIN32 - Q_UNUSED(preferredVersion); - return NET2002; // Always generate 7.0 versions on other platforms -#else - // Only search for the version once - static DotNET current_version = NETUnknown; - if(current_version != NETUnknown) - return current_version; - - // Fallback to .NET 2002 - current_version = NET2002; - - const DotNetCombo *lowestInstalledVersion = 0; - QHash<DotNET, QString> installPaths; - int installed = 0; - int i = 0; - for(; dotNetCombo[i].version; ++i) { - QString path = qt_readRegistryKey(HKEY_LOCAL_MACHINE, dotNetCombo[i].regKey, - KEY_WOW64_32KEY); - if (!path.isEmpty() && installPaths.value(dotNetCombo[i].version) != path) { - lowestInstalledVersion = &dotNetCombo[i]; - installPaths.insert(lowestInstalledVersion->version, path); - ++installed; - current_version = lowestInstalledVersion->version; - if (QByteArray(lowestInstalledVersion->versionStr).contains(preferredVersion)) { - installed = 1; - break; - } - } - } - - if (installed < 2) - return current_version; - - // More than one version installed, search directory path - QString paths = qgetenv("PATH"); - const QStringList pathlist = paths.split(QLatin1Char(';')); - for (const QString &path : pathlist) { - for (i = 0; dotNetCombo[i].version; ++i) { - const QString productPath = installPaths.value(dotNetCombo[i].version); - if (productPath.isEmpty()) - continue; - if (path.startsWith(productPath, Qt::CaseInsensitive)) { - current_version = dotNetCombo[i].version; - return current_version; - } - } - } - - warn_msg(WarnLogic, "Generator: MSVC.NET: Found more than one version of Visual Studio, but" - " none in your PATH. Falling back to lowest version (%s)", - qPrintable(lowestInstalledVersion->versionStr)); - - return current_version; -#endif -}; // Flatfile Tags ---------------------------------------------------- const char _slnHeader70[] = "Microsoft Visual Studio Solution File, Format Version 7.00"; @@ -384,20 +291,16 @@ QString VcprojGenerator::retrievePlatformToolSet() const if (!envVar.isEmpty()) return envVar; - QString suffix; - if (project->isActiveConfig("winphone")) - suffix = '_' + project->first("WINTARGET_VER").toQString().toLower(); - switch (vcProject.Configuration.CompilerVersion) { case NET2012: - return QStringLiteral("v110") + suffix; + return QStringLiteral("v110"); case NET2013: - return QStringLiteral("v120") + suffix; + return QStringLiteral("v120"); case NET2015: - return QStringLiteral("v140") + suffix; + return QStringLiteral("v140"); case NET2017: - return QStringLiteral("v141") + suffix; + return QStringLiteral("v141"); default: return QString(); } @@ -624,7 +527,7 @@ void VcprojGenerator::writeSubDirs(QTextStream &t) return; } - switch (which_dotnet_version(project->first("MSVC_VER").toLatin1())) { + switch (vcProject.Configuration.CompilerVersion) { case NET2017: t << _slnHeader141; break; @@ -654,7 +557,8 @@ void VcprojGenerator::writeSubDirs(QTextStream &t) break; default: t << _slnHeader70; - warn_msg(WarnLogic, "Generator: MSVC.NET: Unknown version (%d) of MSVC detected for .sln", which_dotnet_version()); + warn_msg(WarnLogic, "Generator: MSVC.NET: Unknown version (%d) of MSVC detected for .sln", + vcProject.Configuration.CompilerVersion); break; } @@ -969,7 +873,7 @@ void VcprojGenerator::initProject() // Own elements ----------------------------- vcProject.Name = project->first("QMAKE_ORIG_TARGET").toQString(); - switch (which_dotnet_version(project->first("MSVC_VER").toLatin1())) { + switch (vcProject.Configuration.CompilerVersion) { case NET2017: vcProject.Version = "15.00"; break; @@ -1001,7 +905,7 @@ void VcprojGenerator::initProject() break; default: vcProject.Version = "7.00"; - warn_msg(WarnLogic, "Generator: MSVC.NET: Unknown version (%d) of MSVC detected for .vcproj", which_dotnet_version()); + warn_msg(WarnLogic, "Generator: MSVC.NET: Unknown version (%d) of MSVC detected for .vcproj", vcProject.Configuration.CompilerVersion); break; } @@ -1025,12 +929,11 @@ void VcprojGenerator::initConfiguration() // - to know of certain compiler/linker options VCConfiguration &conf = vcProject.Configuration; conf.suppressUnknownOptionWarnings = project->isActiveConfig("suppress_vcproj_warnings"); - conf.CompilerVersion = which_dotnet_version(project->first("MSVC_VER").toLatin1()); + conf.CompilerVersion = vsVersionFromString(project->first("MSVC_VER")); if (conf.CompilerVersion >= NET2012) { conf.WinRT = project->isActiveConfig("winrt"); if (conf.WinRT) { - conf.WinPhone = project->isActiveConfig("winphone"); // Saner defaults conf.compiler.UsePrecompiledHeader = pchNone; conf.compiler.CompileAsWinRT = _False; @@ -1431,18 +1334,9 @@ void VcprojGenerator::initWinDeployQtTool() // structure (for instance for plugins). However, the MDILXapCompile call // itself contains the original subdirectories as parameters and hence the // call fails. - // Neither there is a way to disable this behavior for Windows Phone, nor - // to influence the parameters. Hence the only way to get a build - // done is to recreate the directory structure manually by invoking - // windeployqt a second time, so that the MDILXapCompile call succeeds and - // deployment continues. - if (conf.WinPhone) { - conf.windeployqt.CommandLine = commandLine - + QStringLiteral(" -list relative -dir \"$(MSBuildProjectDirectory)\\") - + var("OBJECTS_DIR") - + QStringLiteral("MSIL\" \"$(OutDir)\\$(TargetName).exe\" ") - + QLatin1String(" && "); - } + // Hence the only way to get a build done is to recreate the directory + // structure manually by invoking windeployqt a second time, so that + // the MDILXapCompile call succeeds and deployment continues. conf.windeployqt.CommandLine += commandLine + QStringLiteral(" -list relative -dir \"$(MSBuildProjectDirectory)\" \"$(OutDir)\\$(TargetName).exe\" > ") + MakefileGenerator::shellQuote(conf.windeployqt.Record); |