⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mingw_make.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.**** This file is part of the qmake application of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file.  Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://trolltech.com/products/qt/licenses/licensing/opensource/**** If you are unsure which license is appropriate for your use, please** review the following information:** http://trolltech.com/products/qt/licenses/licensing/licensingoverview** or contact the sales department at sales@trolltech.com.**** In addition, as a special exception, Trolltech gives you certain** additional rights. These rights are described in the Trolltech GPL** Exception version 1.0, which can be found at** http://www.trolltech.com/products/qt/gplexception/ and in the file** GPL_EXCEPTION.txt in this package.**** In addition, as a special exception, Trolltech, as the sole copyright** holder for Qt Designer, grants users of the Qt/Eclipse Integration** plug-in the right for the Qt/Eclipse Integration to link to** functionality provided by Qt Designer and its related libraries.**** Trolltech reserves all rights not expressly granted herein.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include "mingw_make.h"#include "option.h"#include <qregexp.h>#include <qdir.h>#include <stdlib.h>#include <time.h>MingwMakefileGenerator::MingwMakefileGenerator() : Win32MakefileGenerator(), init_flag(false){    if (Option::shellPath.isEmpty())        quote = "\"";    else        quote = "'";}bool MingwMakefileGenerator::isWindowsShell() const{#ifdef Q_OS_WIN    return Option::shellPath.isEmpty();#else    return Win32MakefileGenerator::isWindowsShell();#endif}QString MingwMakefileGenerator::escapeDependencyPath(const QString &path) const{    QString ret = path;    ret.remove('\"');    ret.replace('\\', "/");    ret.replace(' ', "\\ ");    return ret;}QString MingwMakefileGenerator::getLibTarget(){    return QString("lib" + project->first("TARGET") + project->first("TARGET_VERSION_EXT") + ".a");}bool MingwMakefileGenerator::findLibraries(){    QStringList &l = project->values("QMAKE_LIBS");    QList<QMakeLocalFileName> dirs;    {        QStringList &libpaths = project->values("QMAKE_LIBDIR");        for(QStringList::Iterator libpathit = libpaths.begin();            libpathit != libpaths.end(); ++libpathit)            dirs.append(QMakeLocalFileName((*libpathit)));    }    QStringList::Iterator it = l.begin();    while (it != l.end()) {        if ((*it).startsWith("-l")) {            QString steam = (*it).mid(2);            QString suffix;            if (!project->isEmpty("QMAKE_" + steam.toUpper() + "_SUFFIX"))                suffix = project->first("QMAKE_" + steam.toUpper() + "_SUFFIX");            QString extension;            for (QList<QMakeLocalFileName>::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {                int ver = findHighestVersion((*dir_it).local(), steam, "dll.a|a");                if (ver != -1) {                    extension += QString::number(ver);                    break;                }            }	        extension += suffix;	        (*it) += extension;	    } else if((*it).startsWith("-L")) {            dirs.append(QMakeLocalFileName((*it).mid(2)));        }        ++it;    }    return true;}bool MingwMakefileGenerator::writeMakefile(QTextStream &t){    writeHeader(t);    if(!project->values("QMAKE_FAILED_REQUIREMENTS").isEmpty()) {        t << "all clean:" << "\n\t"          << "@echo \"Some of the required modules ("          << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"          << "@echo \"Skipped.\"" << endl << endl;        writeMakeQmake(t);        return true;    }    if(project->first("TEMPLATE") == "app" ||       project->first("TEMPLATE") == "lib") {        if(Option::mkfile::do_stub_makefile) {            t << "QMAKE    = "        << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl;            QStringList &qut = project->values("QMAKE_EXTRA_TARGETS");            for(QStringList::ConstIterator it = qut.begin(); it != qut.end(); ++it)                t << *it << " ";            t << "first all clean install distclean uninstall: qmake" << endl              << "qmake_all:" << endl;            writeMakeQmake(t);            if(project->isEmpty("QMAKE_NOFORCE"))                t << "FORCE:" << endl << endl;            return true;        }        writeMingwParts(t);        return MakefileGenerator::writeMakefile(t);    }    else if(project->first("TEMPLATE") == "subdirs") {        writeSubDirs(t);        return true;    }    return false; }void createLdObjectScriptFile(const QString &fileName, const QStringList &objList){    QString filePath = Option::output_dir + QDir::separator() + fileName;    QFile file(filePath);    if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {        QTextStream t(&file);        t << "INPUT(" << endl;        for (QStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {            if (QDir::isRelativePath(*it))		t << "./" << *it << endl;	    else		t << *it << endl;        }        t << ");" << endl;	t.flush();        file.close();    }}void createArObjectScriptFile(const QString &fileName, const QString &target, const QStringList &objList){    QString filePath = Option::output_dir + QDir::separator() + fileName;    QFile file(filePath);    if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {        QTextStream t(&file);        t << "CREATE " << target << endl;        for (QStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {            if (QDir::isRelativePath(*it))		t << "ADDMOD " << *it << endl;	    else		t << *it << endl;        }        t << "SAVE" << endl;	t.flush();        file.close();    }}void MingwMakefileGenerator::writeMingwParts(QTextStream &t){    writeStandardParts(t);    if (!preCompHeaderOut.isEmpty()) {	QString header = project->first("PRECOMPILED_HEADER");	QString cHeader = preCompHeaderOut + Option::dir_sep + "c";	t << escapeDependencyPath(cHeader) << ": " << escapeDependencyPath(header) << " "          << escapeDependencyPaths(findDependencies(header)).join(" \\\n\t\t")	  << "\n\t" << mkdir_p_asstring(preCompHeaderOut)	  << "\n\t" << "$(CC) -x c-header -c $(CFLAGS) $(INCPATH) -o " << cHeader << " " << header          << endl << endl;	QString cppHeader = preCompHeaderOut + Option::dir_sep + "c++";	t << escapeDependencyPath(cppHeader) << ": " << escapeDependencyPath(header) << " "          << escapeDependencyPaths(findDependencies(header)).join(" \\\n\t\t")	  << "\n\t" << mkdir_p_asstring(preCompHeaderOut)	  << "\n\t" << "$(CXX) -x c++-header -c $(CXXFLAGS) $(INCPATH) -o " << cppHeader << " " << header          << endl << endl;    }}void MingwMakefileGenerator::init(){    if(init_flag)        return;    init_flag = true;    /* this should probably not be here, but I'm using it to wrap the .t files */    if(project->first("TEMPLATE") == "app")        project->values("QMAKE_APP_FLAG").append("1");    else if(project->first("TEMPLATE") == "lib")        project->values("QMAKE_LIB_FLAG").append("1");    else if(project->first("TEMPLATE") == "subdirs") {        MakefileGenerator::init();        if(project->isEmpty("QMAKE_COPY_FILE"))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -