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

📄 projectgenerator.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 "projectgenerator.h"#include "option.h"#include <qdatetime.h>#include <qdir.h>#include <qfile.h>#include <qfileinfo.h>#include <qregexp.h>QString project_builtin_regx() //calculate the builtin regular expression..{    QString ret;    QStringList builtin_exts;    builtin_exts << Option::c_ext << Option::ui_ext << Option::yacc_ext << Option::lex_ext << ".ts" << ".qrc";    builtin_exts += Option::h_ext + Option::cpp_ext;    for(int i = 0; i < builtin_exts.size(); ++i) {        if(!ret.isEmpty())            ret += "; ";        ret += QString("*") + builtin_exts[i];    }    return ret;}ProjectGenerator::ProjectGenerator() : MakefileGenerator(), init_flag(false){}voidProjectGenerator::init(){    if(init_flag)        return;    int file_count = 0;    init_flag = true;    verifyCompilers();    project->read(QMakeProject::ReadFeatures);    project->variables()["CONFIG"].clear();    QMap<QString, QStringList> &v = project->variables();    QString templ = Option::user_template.isEmpty() ? QString("app") : Option::user_template;    if(!Option::user_template_prefix.isEmpty())        templ.prepend(Option::user_template_prefix);    v["TEMPLATE_ASSIGN"] += templ;    //figure out target    if(Option::output.fileName() == "-")        v["TARGET_ASSIGN"] = QStringList("unknown");    else        v["TARGET_ASSIGN"] = QStringList(QFileInfo(Option::output).baseName());    //the scary stuff    if(project->first("TEMPLATE_ASSIGN") != "subdirs") {        QString builtin_regex = project_builtin_regx();        QStringList dirs = Option::projfile::project_dirs;        if(Option::projfile::do_pwd) {            if(!v["INCLUDEPATH"].contains("."))                v["INCLUDEPATH"] += ".";            dirs.prepend(qmake_getpwd());        }        for(int i = 0; i < dirs.count(); ++i) {            QString dir, regex, pd = dirs.at(i);            bool add_depend = false;            if(exists(pd)) {                QFileInfo fi(fileInfo(pd));                if(fi.isDir()) {                    dir = pd;                    add_depend = true;                    if(dir.right(1) != Option::dir_sep)                        dir += Option::dir_sep;                    if(Option::recursive) {                        QStringList files = QDir(dir).entryList(QDir::Files);                        for(int i = 0; i < (int)files.count(); i++) {                            if(files[i] != "." && files[i] != "..")                                dirs.append(dir + files[i] + QDir::separator() + builtin_regex);                        }                    }                    regex = builtin_regex;                } else {                    QString file = pd;                    int s = file.lastIndexOf(Option::dir_sep);                    if(s != -1)                        dir = file.left(s+1);                    if(addFile(file)) {                        add_depend = true;                        file_count++;                    }                }            } else { //regexp                regex = pd;            }            if(!regex.isEmpty()) {                int s = regex.lastIndexOf(Option::dir_sep);                if(s != -1) {                    dir = regex.left(s+1);                    regex = regex.right(regex.length() - (s+1));                }                if(Option::recursive) {                    QStringList entries = QDir(dir).entryList(QDir::Dirs);                    for(int i = 0; i < (int)entries.count(); i++) {                        if(entries[i] != "." && entries[i] != "..") {                            dirs.append(dir + entries[i] + QDir::separator() + regex);                        }                    }                }                QStringList files = QDir(dir).entryList(QDir::nameFiltersFromString(regex));                for(int i = 0; i < (int)files.count(); i++) {                    QString file = dir + files[i];                    if (addFile(file)) {                        add_depend = true;                        file_count++;                    }                }            }            if(add_depend && !dir.isEmpty() && !v["DEPENDPATH"].contains(dir, Qt::CaseInsensitive)) {                QFileInfo fi(fileInfo(dir));                if(fi.absoluteFilePath() != qmake_getpwd())                    v["DEPENDPATH"] += fileFixify(dir);            }        }    }    if(!file_count) { //shall we try a subdir?        QStringList knownDirs = Option::projfile::project_dirs;        if(Option::projfile::do_pwd)            knownDirs.prepend(".");        const QString out_file = fileFixify(Option::output.fileName());        for(int i = 0; i < knownDirs.count(); ++i) {            QString pd = knownDirs.at(i);            if(exists(pd)) {                QString newdir = pd;                QFileInfo fi(fileInfo(newdir));                if(fi.isDir()) {                    newdir = fileFixify(newdir);                    QStringList &subdirs = v["SUBDIRS"];                    if(exists(fi.filePath() + QDir::separator() + fi.fileName() + Option::pro_ext) &&                       !subdirs.contains(newdir, Qt::CaseInsensitive)) {                        subdirs.append(newdir);                    } else {                        QStringList profiles = QDir(newdir).entryList(QStringList("*" + Option::pro_ext), QDir::Files);                        for(int i = 0; i < (int)profiles.count(); i++) {                            QString nd = newdir;                            if(nd == ".")                                nd = "";                            else if(!nd.isEmpty() && !nd.endsWith(QString(QChar(QDir::separator()))))                                nd += QDir::separator();                            nd += profiles[i];                            fileFixify(nd);                            if(profiles[i] != "." && profiles[i] != ".." &&                               !subdirs.contains(nd, Qt::CaseInsensitive) && !out_file.endsWith(nd))                                subdirs.append(nd);                        }                    }                    if(Option::recursive) {                        QStringList dirs = QDir(newdir).entryList(QDir::Dirs);                        for(int i = 0; i < (int)dirs.count(); i++) {                            QString nd = fileFixify(newdir + QDir::separator() + dirs[i]);                            if(dirs[i] != "." && dirs[i] != ".." && !knownDirs.contains(nd, Qt::CaseInsensitive))                                knownDirs.append(nd);                        }                    }                }            } else { //regexp                QString regx = pd, dir;                int s = regx.lastIndexOf(Option::dir_sep);                if(s != -1) {                    dir = regx.left(s+1);                    regx = regx.right(regx.length() - (s+1));                }                QStringList files = QDir(dir).entryList(QDir::nameFiltersFromString(regx), QDir::Dirs);                QStringList &subdirs = v["SUBDIRS"];                for(int i = 0; i < (int)files.count(); i++) {                    QString newdir(dir + files[i]);                    QFileInfo fi(fileInfo(newdir));                    if(fi.fileName() != "." && fi.fileName() != "..") {                        newdir = fileFixify(newdir);                        if(exists(fi.filePath() + QDir::separator() + fi.fileName() + Option::pro_ext) &&                           !subdirs.contains(newdir)) {                           subdirs.append(newdir);                        } else {                            QStringList profiles = QDir(newdir).entryList(QStringList("*" + Option::pro_ext), QDir::Files);                            for(int i = 0; i < (int)profiles.count(); i++) {                                QString nd = newdir + QDir::separator() + files[i];                                fileFixify(nd);                                if(files[i] != "." && files[i] != ".." && !subdirs.contains(nd, Qt::CaseInsensitive)) {                                    if(newdir + files[i] != Option::output_dir + Option::output.fileName())                                        subdirs.append(nd);                                }                            }                        }                        if(Option::recursive && !knownDirs.contains(newdir, Qt::CaseInsensitive))                            knownDirs.append(newdir);                    }                }            }        }        v["TEMPLATE_ASSIGN"] = QStringList("subdirs");        return;    }    //setup deplist    QList<QMakeLocalFileName> deplist;    {        const QStringList &d = v["DEPENDPATH"];        for(int i = 0; i < d.size(); ++i)            deplist.append(QMakeLocalFileName(d[i]));    }    setDependencyPaths(deplist);    QStringList &h = v["HEADERS"];    bool no_qt_files = true;    QString srcs[] = { "SOURCES", "YACCSOURCES", "LEXSOURCES", "FORMS", QString() };    for(int i = 0; !srcs[i].isNull(); i++) {

⌨️ 快捷键说明

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