bool MingwMakefileGenerator::writeMakefile(QTextStream &t)
{
    writeHeader(t);
    if (writeDummyMakefile(t))
        return true;

    if(project->first("TEMPLATE") == "app" ||
       project->first("TEMPLATE") == "lib" ||
       project->first("TEMPLATE") == "aux") {
        if(project->isActiveConfig("create_pc") && project->first("TEMPLATE") == "lib")
            writePkgConfigFile();

        if(Option::mkfile::do_stub_makefile) {
            t << "QMAKE    = " << var("QMAKE_QMAKE") << endl;
            const ProStringList &qut = project->values("QMAKE_EXTRA_TARGETS");
            for (ProStringList::ConstIterator it = qut.begin(); it != qut.end(); ++it)
                t << *it << " ";
            t << "first all clean install distclean uninstall: qmake\n"
              << "qmake_all:\n";
            writeMakeQmake(t);
            t << "FORCE:\n\n";
            return true;
        }
        writeMingwParts(t);
        return MakefileGenerator::writeMakefile(t);
    }
    else if(project->first("TEMPLATE") == "subdirs") {
        writeSubDirs(t);
        return true;
    }
    return false;
 }
Пример #2
0
bool
NmakeMakefileGenerator::writeMakefile(QTextStream &t)
{
    writeHeader(t);
    if (writeDummyMakefile(t))
        return true;

    if(project->first("TEMPLATE") == "app" ||
       project->first("TEMPLATE") == "lib" ||
       project->first("TEMPLATE") == "aux") {
#if 0
        if(Option::mkfile::do_stub_makefile)
            return MakefileGenerator::writeStubMakefile(t);
#endif
        if (!project->isHostBuild()) {
            const ProValueMap &variables = project->variables();
            if (project->isActiveConfig("wince")) {
                CeSdkHandler sdkhandler;
                sdkhandler.parse();
                const QString sdkName = variables["CE_SDK"].join(' ')
                                        + " (" + variables["CE_ARCH"].join(' ') + ")";
                const QList<CeSdkInfo> sdkList = sdkhandler.listAll();
                CeSdkInfo sdk;
                foreach (const CeSdkInfo &info, sdkList) {
                    if (info.name().compare(sdkName, Qt::CaseInsensitive ) == 0) {
                        sdk = info;
                        break;
                    }
                }
                if (sdk.isValid()) {
                    t << "\nINCLUDE = " << sdk.includePath();
                    t << "\nLIB = " << sdk.libPath();
                    t << "\nPATH = " << sdk.binPath() << "\n";
                } else {
                    QStringList sdkStringList;
                    foreach (const CeSdkInfo &info, sdkList)
                        sdkStringList << info.name();

                    fprintf(stderr, "Failed to find Windows CE SDK matching %s, found: %s\n"
                                    "SDK needs to be specified in mkspec (using: %s/qmake.conf)\n"
                                    "SDK name needs to match the following format: CE_SDK (CE_ARCH)\n",
                            qPrintable(sdkName), qPrintable(sdkStringList.join(", ")),
                            qPrintable(variables["QMAKESPEC"].first().toQString()));
                    return false;
                }
            } 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")) {
                    const ProStringList hostArch = project->values("QMAKE_TARGET.arch");
                    if (hostArch.contains("x86_64"))
                        compiler = QStringLiteral("amd64");
                    else
                        compiler = QStringLiteral("x86_amd64");
                    compilerArch = QStringLiteral("amd64");
                } else {
                    arch = QStringLiteral("x86");
                }

                const QString msvcVer = project->first("MSVC_VER").toQString();
                if (msvcVer.isEmpty()) {
                    fprintf(stderr, "Mkspec does not specify MSVC_VER. Cannot continue.\n");
                    return false;
                }
                const QString winsdkVer = project->first("WINSDK_VER").toQString();
                if (winsdkVer.isEmpty()) {
                    fprintf(stderr, "Mkspec does not specify WINSDK_VER. Cannot continue.\n");
                    return false;
                }
                const QString targetVer = project->first("WINTARGET_VER").toQString();
                if (targetVer.isEmpty()) {
                    fprintf(stderr, "Mkspec does not specify WINTARGET_VER. Cannot continue.\n");
                    return false;
                }

                const bool isPhone = project->isActiveConfig(QStringLiteral("winphone"));
#ifdef Q_OS_WIN
                QString regKeyPrefix;
#if !defined(Q_OS_WIN64) && _WIN32_WINNT >= 0x0501
                BOOL isWow64;
                IsWow64Process(GetCurrentProcess(), &isWow64);
                if (!isWow64)
                    regKeyPrefix = QStringLiteral("Software\\");
                else
#endif
                    regKeyPrefix = QStringLiteral("Software\\Wow6432Node\\");

                QString regKey = regKeyPrefix + QStringLiteral("Microsoft\\VisualStudio\\") + msvcVer + ("\\Setup\\VC\\ProductDir");
                const QString vcInstallDir = qt_readRegistryKey(HKEY_LOCAL_MACHINE, regKey);
                if (vcInstallDir.isEmpty()) {
                    fprintf(stderr, "Failed to find the Visual Studio installation directory.\n");
                    return false;
                }

                regKey = regKeyPrefix
                        + (isPhone ? QStringLiteral("Microsoft\\Microsoft SDKs\\WindowsPhone\\v")
                                   : QStringLiteral("Microsoft\\Microsoft SDKs\\Windows\\v"))
                        + winsdkVer + QStringLiteral("\\InstallationFolder");
                const QString kitDir = qt_readRegistryKey(HKEY_LOCAL_MACHINE, regKey);
                if (kitDir.isEmpty()) {
                    fprintf(stderr, "Failed to find the Windows Kit installation directory.\n");
                    return false;
                }
#else
                const QString vcInstallDir = "/fake/vc_install_dir";
                const QString kitDir = "/fake/sdk_install_dir";
#endif // Q_OS_WIN

                QStringList incDirs;
                QStringList libDirs;
                QStringList binDirs;
                if (isPhone) {
                    QString sdkDir = vcInstallDir + QStringLiteral("/WPSDK/") + targetVer;
                    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;
                    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
                            << vcInstallDir + QStringLiteral("/lib/") + compilerArch;
                    binDirs << vcInstallDir + QStringLiteral("/bin/") + compiler
                            << vcInstallDir + QStringLiteral("/../Common7/IDE");
                    libDirs << kitDir + QStringLiteral("/Lib/") + targetVer + ("/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';
            }
        }