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

📄 pbuilder_pbx.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/******************************************************************************** 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 "pbuilder_pbx.h"#include "option.h"#include "meta.h"#include <qdir.h>#include <qregexp.h>#include <qcryptographichash.h>#include <qdebug.h>#include <stdlib.h>#include <time.h>#ifdef Q_OS_UNIX#  include <sys/types.h>#  include <sys/stat.h>#endif#ifdef Q_OS_DARWIN#include <ApplicationServices/ApplicationServices.h>#include <private/qcore_mac_p.h>#endif//#define GENERATE_AGGREGRATE_SUBDIR// Note: this is fairly hacky, but it does the job...static QString qtMD5(const QByteArray &src){    QByteArray digest = QCryptographicHash::hash(src, QCryptographicHash::Md5);    return QString::fromLatin1(digest.toHex());}ProjectBuilderMakefileGenerator::ProjectBuilderMakefileGenerator() : UnixMakefileGenerator(){}boolProjectBuilderMakefileGenerator::writeMakefile(QTextStream &t){    writingUnixMakefileGenerator = false;    if(!project->values("QMAKE_FAILED_REQUIREMENTS").isEmpty()) {        /* for now just dump, I need to generated an empty xml or something.. */        fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n",                var("QMAKE_FAILED_REQUIREMENTS").toLatin1().constData());        return true;    }    project->values("MAKEFILE").clear();    project->values("MAKEFILE").append("Makefile");    if(project->first("TEMPLATE") == "app" || project->first("TEMPLATE") == "lib")        return writeMakeParts(t);    else if(project->first("TEMPLATE") == "subdirs")        return writeSubDirs(t);    return false;}struct ProjectBuilderSubDirs {    QMakeProject *project;    QString subdir;    bool autoDelete;    ProjectBuilderSubDirs(QMakeProject *p, QString s, bool a=true) : project(p), subdir(s), autoDelete(a) { }    ~ProjectBuilderSubDirs() {        if(autoDelete)            delete project;    }};boolProjectBuilderMakefileGenerator::writeSubDirs(QTextStream &t){    if(project->isActiveConfig("generate_pbxbuild_makefile")) {        QString mkwrap = fileFixify(pbx_dir + Option::dir_sep + ".." + Option::dir_sep + project->first("MAKEFILE"),                                    qmake_getpwd());        QFile mkwrapf(mkwrap);        if(mkwrapf.open(QIODevice::WriteOnly | QIODevice::Text)) {            debug_msg(1, "pbuilder: Creating file: %s", mkwrap.toLatin1().constData());            QTextStream mkwrapt(&mkwrapf);            writingUnixMakefileGenerator = true;            UnixMakefileGenerator::writeSubDirs(mkwrapt);            writingUnixMakefileGenerator = false;        }    }    //HEADER    const int pbVersion = pbuilderVersion();    t << "// !$*UTF8*$!" << "\n"      << "{" << "\n"      << "\t" << writeSettings("archiveVersion", "1", SettingsNoQuote) << ";" << "\n"      << "\t" << "classes = {" << "\n" << "\t" << "};" << "\n"      << "\t" << writeSettings("objectVersion", QString::number(pbVersion), SettingsNoQuote) << ";" << "\n"      << "\t" << "objects = {" << endl;    //SUBDIRS    QList<ProjectBuilderSubDirs*> pb_subdirs;    pb_subdirs.append(new ProjectBuilderSubDirs(project, QString(), false));    QString oldpwd = qmake_getpwd();    QMap<QString, QStringList> groups;    for(int pb_subdir = 0; pb_subdir < pb_subdirs.size(); ++pb_subdir) {        ProjectBuilderSubDirs *pb = pb_subdirs[pb_subdir];        const QStringList subdirs = pb->project->values("SUBDIRS");        for(int subdir = 0; subdir < subdirs.count(); subdir++) {            QString tmp = subdirs[subdir];            if(!pb->project->isEmpty(tmp + ".file"))                tmp = pb->project->first(tmp + ".file");            else if(!pb->project->isEmpty(tmp + ".subdir"))                tmp = pb->project->first(tmp + ".subdir");            if(fileInfo(tmp).isRelative() && !pb->subdir.isEmpty()) {                QString subdir = pb->subdir;                if(!subdir.endsWith(Option::dir_sep))                    subdir += Option::dir_sep;                tmp = subdir + tmp;            }            QFileInfo fi(fileInfo(Option::fixPathToLocalOS(tmp, true)));            if(fi.exists()) {                if(fi.isDir()) {                    QString profile = tmp;                    if(!profile.endsWith(Option::dir_sep))                        profile += Option::dir_sep;                    profile += fi.baseName() + ".pro";                    fi = QFileInfo(profile);                }                QMakeProject tmp_proj;                QString dir = fi.path(), fn = fi.fileName();                if(!dir.isEmpty()) {                    if(!qmake_setpwd(dir))                        fprintf(stderr, "Cannot find directory: %s\n", dir.toLatin1().constData());                }                if(tmp_proj.read(fn)) {                    if(Option::debug_level) {                        QMap<QString, QStringList> &vars = tmp_proj.variables();                        for(QMap<QString, QStringList>::Iterator it = vars.begin();                            it != vars.end(); ++it) {                            if(it.key().left(1) != "." && !it.value().isEmpty())                                debug_msg(1, "%s: %s === %s", fn.toLatin1().constData(), it.key().toLatin1().constData(),                                          it.value().join(" :: ").toLatin1().constData());                        }                    }                    if(tmp_proj.first("TEMPLATE") == "subdirs") {                        QMakeProject *pp = new QMakeProject(&tmp_proj);                        pp->read(0);                        pb_subdirs += new ProjectBuilderSubDirs(pp, dir);                    } else if(tmp_proj.first("TEMPLATE") == "app" || tmp_proj.first("TEMPLATE") == "lib") {                        QString pbxproj = qmake_getpwd() + Option::dir_sep + tmp_proj.first("TARGET") + projectSuffix();                        if(!exists(pbxproj)) {                            warn_msg(WarnLogic, "Ignored (not found) '%s'", pbxproj.toLatin1().constData());                            goto nextfile; // # Dirty!                        }                        const QString project_key = keyFor(pbxproj + "_PROJECTREF");                        project->values("QMAKE_PBX_SUBDIRS") += pbxproj;                        //PROJECTREF                        {                            bool in_root = true;                            QString name = qmake_getpwd();                            if(project->isActiveConfig("flat")) {                                QString flat_file = fileFixify(name, oldpwd, Option::output_dir, FileFixifyRelative);                                if(flat_file.indexOf(Option::dir_sep) != -1) {                                    QStringList dirs = flat_file.split(Option::dir_sep);                                    name = dirs.back();                                }                            } else {                                QString flat_file = fileFixify(name, oldpwd, Option::output_dir, FileFixifyRelative);                                if(QDir::isRelativePath(flat_file) && flat_file.indexOf(Option::dir_sep) != -1) {                                    QString last_grp("QMAKE_SUBDIR_PBX_HEIR_GROUP");                                    QStringList dirs = flat_file.split(Option::dir_sep);                                    name = dirs.back();                                    for(QStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {                                        QString new_grp(last_grp + Option::dir_sep + (*dir_it)), new_grp_key(keyFor(new_grp));                                        if(dir_it == dirs.begin()) {                                            if(!groups.contains(new_grp))                                                project->values("QMAKE_SUBDIR_PBX_GROUPS").append(new_grp_key);                                        } else {                                            if(!groups[last_grp].contains(new_grp_key))                                                groups[last_grp] += new_grp_key;                                        }                                        last_grp = new_grp;                                    }                                    groups[last_grp] += project_key;                                    in_root = false;                                }                            }                            if(in_root)                                project->values("QMAKE_SUBDIR_PBX_GROUPS") += project_key;                            t << "\t\t" << project_key << " = {" << "\n"                              << "\t\t\t" << writeSettings("isa", "PBXFileReference", SettingsNoQuote) << ";" << "\n"                              << "\t\t\t" << writeSettings("lastKnownFileType", "wrapper.pb-project") << ";" << "\n"                              << "\t\t\t" << writeSettings("name", escapeFilePath(tmp_proj.first("TARGET") + projectSuffix())) << ";" << "\n"                              << "\t\t\t" << writeSettings("path", pbxproj) << ";" << "\n"                              << "\t\t\t" << writeSettings("refType", "0", SettingsNoQuote) << ";" << "\n"                              << "\t\t\t" << writeSettings("sourceTree", "<absolute>") << ";" << "\n"                              << "\t\t" << "};" << "\n";                            //WRAPPER                            t << "\t\t" << keyFor(pbxproj + "_WRAPPER") << " = {" << "\n"                              << "\t\t\t" << writeSettings("isa", "PBXReferenceProxy", SettingsNoQuote) << ";" << "\n";                            if(tmp_proj.first("TEMPLATE") == "app") {                                t << "\t\t\t" << writeSettings("fileType", "wrapper.application") << ";" << "\n"                                  << "\t\t\t" << writeSettings("path", tmp_proj.first("TARGET") + ".app") << ";" << "\n";                            } else {                                t << "\t\t\t" << writeSettings("fileType", "compiled.mach-o.dylib") << ";" << "\n"                                  << "\t\t\t" << writeSettings("path", tmp_proj.first("TARGET") + ".dylib") << ";" << "\n";                            }                            t << "\t\t\t" << writeSettings("refType", "3", SettingsNoQuote) << ";" << "\n"

⌨️ 快捷键说明

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