From ede5be6ea0990123384513e701e29d131e76e29a Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Mon, 2 Sep 2013 10:51:17 +0200 Subject: Create clean makefiles for winrt builds Change-Id: I33b74b98e04c1a9ca15ae07fad88f88dd4ce0669 Reviewed-by: Joerg Bornemann --- qmake/generators/win32/msvc_nmake.cpp | 93 +++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) (limited to 'qmake/generators') diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index f7b85d3621..3185e68ecc 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -42,13 +42,27 @@ #include "msvc_nmake.h" #include "option.h" #include "cesdkhandler.h" + #include #include #include + +#include + #include QT_BEGIN_NAMESPACE +static QString nmakePathList(const QStringList &list) +{ + QStringList pathList; + foreach (const QString &path, list) + pathList.append(QDir::cleanPath(path)); + + return QDir::toNativeSeparators(pathList.join(QLatin1Char(';'))) + .replace('#', QStringLiteral("^#")).replace('$', QStringLiteral("$$")); +} + NmakeMakefileGenerator::NmakeMakefileGenerator() : Win32MakefileGenerator(), init_flag(false), usePCH(false) { @@ -100,6 +114,85 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) return false; } } +#ifdef Q_OS_WIN + else if (project->isActiveConfig(QStringLiteral("winrt"))) { + QString arch = project->first("VCPROJ_ARCH").toQString().toLower(); + QString compiler; + QString compilerArch; + if (arch == QStringLiteral("arm")) { + compiler = QStringLiteral("x86_arm"); + compilerArch = QStringLiteral("arm"); + } else if (arch == QStringLiteral("x64")) { + compiler = QStringLiteral("x86_amd64"); + compilerArch = QStringLiteral("amd64"); + } +#ifdef Q_OS_WIN64 + const QString regKey = QStringLiteral("Software\\Wow6432Node\\Microsoft\\VisualStudio\\11.0\\Setup\\VC\\ProductDir"); +#else + const QString regKey = QStringLiteral("Software\\Microsoft\\VisualStudio\\11.0\\Setup\\VC\\ProductDir"); +#endif + const QString vcInstallDir = qt_readRegistryKey(HKEY_LOCAL_MACHINE, regKey); + if (vcInstallDir.isEmpty()) { + fprintf(stderr, "Failed to find the Visual Studio 2012 installation directory.\n" + "Is it installed?.\n"); + return false; + } + + QStringList incDirs; + QStringList libDirs; + QStringList binDirs; + const bool isPhone = project->isActiveConfig(QStringLiteral("winphone")); + if (isPhone) { + QString sdkDir = vcInstallDir + QStringLiteral("/WPSDK/WP80"); + 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/") + compilerArch; + binDirs << sdkDir + QStringLiteral("/bin/") + compiler; + + QString kitDir = vcInstallDir + QStringLiteral("/../../Windows Phone Kits/8.0"); + if (!QDir(kitDir).exists()) { + fprintf(stderr, "Failed to find the Windows Phone Kit in %s.\n" + "Check that it is properly installed.\n", + qPrintable(QDir::toNativeSeparators(kitDir))); + return false; + } + 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/") + compilerArch; + binDirs << vcInstallDir + QStringLiteral("/bin/") + compiler + << vcInstallDir + QStringLiteral("/../Common7/IDE"); + + QString kitDir = vcInstallDir + QStringLiteral("/../../Windows Kits/8.0"); + if (!QDir(kitDir).exists()) { + fprintf(stderr, "Failed to find the Windows Kit in %s.\n" + "Check that it is properly installed.\n", + qPrintable(QDir::toNativeSeparators(kitDir))); + return false; + } + libDirs << kitDir + QStringLiteral("/Lib/win8/um/") + arch; + incDirs << kitDir + QStringLiteral("/include/um") + << kitDir + QStringLiteral("/include/shared") + << kitDir + QStringLiteral("/include/winrt"); + } + + // Inherit PATH + binDirs << QString::fromLocal8Bit(qgetenv("PATH")).split(QLatin1Char(';')); + + t << "\nINCLUDE = " << nmakePathList(incDirs); + t << "\nLIB = " << nmakePathList(libDirs); + t << "\nPATH = " << nmakePathList(binDirs) << '\n'; + } +#endif // Q_OS_WIN } writeNmakeParts(t); return MakefileGenerator::writeMakefile(t); -- cgit v1.2.3