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

📄 pbuilder_pbx.cpp

📁 qt专门用于嵌入式的图形开发GUI
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/****************************************************************************** $Id: qt/pbuilder_pbx.cpp   3.3.5   edited Aug 31 12:13 $**** Implementation of ProjectBuilderMakefileGenerator class.**** Copyright (C) 1992-2005 Trolltech AS.  All rights reserved.**** This file is part of qmake.**** This file may be distributed under the terms of the Q Public License** as defined by Trolltech AS of Norway and appearing in the file** LICENSE.QPL included in the packaging of this file.**** This file may be distributed and/or modified under the terms of the** GNU General Public License version 2 as published by the Free Software** Foundation and appearing in the file LICENSE.GPL included in the** packaging of this file.**** Licensees holding valid Qt Enterprise Edition licenses may use this** file in accordance with the Qt Commercial License Agreement provided** with the Software.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.**** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for**   information about Qt Commercial License Agreements.** See http://www.trolltech.com/qpl/ for QPL licensing information.** See http://www.trolltech.com/gpl/ for GPL licensing information.**** Contact info@trolltech.com if any conditions of this licensing are** not clear to you.************************************************************************/#include "pbuilder_pbx.h"#include "option.h"#include "meta.h"#include <qdir.h>#include <qdict.h>#include <qregexp.h>#include <stdlib.h>#include <time.h>#include "qtmd5.h"#ifdef Q_OS_UNIX#  include <sys/types.h>#  include <sys/stat.h>#endif// Note: this is fairly hacky, but it does the job...ProjectBuilderMakefileGenerator::ProjectBuilderMakefileGenerator(QMakeProject *p) : UnixMakefileGenerator(p){}boolProjectBuilderMakefileGenerator::writeMakefile(QTextStream &t){    if(!project->variables()["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").latin1());	return TRUE;    }    project->variables()["MAKEFILE"].clear();    project->variables()["MAKEFILE"].append("Makefile");    if(project->first("TEMPLATE") == "app" || project->first("TEMPLATE") == "lib")	return writeMakeParts(t);    else if(project->first("TEMPLATE") == "subdirs")	return writeSubdirs(t, FALSE);    return FALSE;}boolProjectBuilderMakefileGenerator::writeSubdirs(QTextStream &t, bool direct){    QString mkwrap = fileFixify(pbx_dir + Option::dir_sep + ".." + Option::dir_sep + project->first("MAKEFILE"),				QDir::currentDirPath());    QFile mkwrapf(mkwrap);    if(mkwrapf.open(IO_WriteOnly | IO_Translate)) {	debug_msg(1, "pbuilder: Creating file: %s", mkwrap.latin1());	QTextStream mkwrapt(&mkwrapf);	UnixMakefileGenerator::writeSubdirs(mkwrapt, direct);    }    //HEADER    const int pbVersion = pbuilderVersion();    t << "// !$*UTF8*$!" << "\n"      << "{" << "\n"      << "\t" << "archiveVersion = 1;" << "\n"      << "\t" << "classes = {" << "\n" << "\t" << "};" << "\n"      << "\t" << "objectVersion = " << pbVersion << ";" << "\n"      << "\t" << "objects = {" << endl;    //SUBDIRS    QStringList subdirs = project->variables()["SUBDIRS"];    QString oldpwd = QDir::currentDirPath();    QMap<QString, QStringList> groups;    for(QStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it) {	QFileInfo fi(Option::fixPathToLocalOS((*it), TRUE));	if(fi.exists()) {	    if(fi.isDir()) {		QString profile = (*it);		if(!profile.endsWith(Option::dir_sep))		    profile += Option::dir_sep;		profile += fi.baseName() + ".pro";		subdirs.append(profile);	    } else {		QMakeProject tmp_proj;		QString dir = fi.dirPath(), fn = fi.fileName();		if(!dir.isEmpty()) {		    if(!QDir::setCurrent(dir))			fprintf(stderr, "Cannot find directory: %s\n", dir.latin1());		}		if(tmp_proj.read(fn, oldpwd)) {		    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.data().isEmpty())				debug_msg(1, "%s: %s === %s", fn.latin1(), it.key().latin1(),					  it.data().join(" :: ").latin1());			}		    }		    if(tmp_proj.first("TEMPLATE") == "subdirs") {			subdirs += fileFixify(tmp_proj.variables()["SUBDIRS"]);		    } else if(tmp_proj.first("TEMPLATE") == "app" || tmp_proj.first("TEMPLATE") == "lib") {			QString pbxproj = QDir::currentDirPath() + Option::dir_sep + tmp_proj.first("TARGET") + projectSuffix();			if(!QFile::exists(pbxproj)) {			    warn_msg(WarnLogic, "Ignored (not found) '%s'", pbxproj.latin1());			    goto nextfile; // # Dirty!			}			project->variables()["QMAKE_PBX_SUBDIRS"] += pbxproj;			//PROJECTREF			{			    bool in_root = TRUE;			    QString name = QDir::currentDirPath();			    QString project_key = keyFor(pbxproj + "_PROJECTREF");			    if(project->isActiveConfig("flat")) {				QString flat_file = fileFixify(name, oldpwd, Option::output_dir, TRUE);				if(flat_file.find(Option::dir_sep) != -1) {				    QStringList dirs = QStringList::split(Option::dir_sep, flat_file);				    name = dirs.back();				}			    } else {				QString flat_file = fileFixify(name, oldpwd, Option::output_dir, TRUE);				if(QDir::isRelativePath(flat_file) && flat_file.find(Option::dir_sep) != -1) {				    QString last_grp("QMAKE_PBX_HEIR_GROUP");				    QStringList dirs = QStringList::split(Option::dir_sep, flat_file);				    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->variables()["QMAKE_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->variables()["QMAKE_PBX_GROUPS"] += project_key;			    t << "\t\t" << project_key << " = {" << "\n"			      << "\t\t\t" << "isa = PBXFileReference;" << "\n"			      << "\t\t\t" << "name = " << tmp_proj.first("TARGET") << ";" << "\n"			      << "\t\t\t" << "path = " << pbxproj << ";" << "\n"			      << "\t\t\t" << "refType = 0;" << "\n"			      << "\t\t\t" << "sourceTree = \"<absolute>\";" << "\n"			      << "\t\t" << "};" << "\n";			    //PRODUCTGROUP			    t << "\t\t" << keyFor(pbxproj + "_PRODUCTGROUP") << " = {" << "\n"			      << "\t\t\t" << "children = (" << "\n"			      << "\t\t\t" << ");" << "\n"			      << "\t\t\t" << "isa = PBXGroup;" << "\n"			      << "\t\t\t" << "name = Products;" << "\n"			      << "\t\t\t" << "refType = 4;" << "\n"			      << "\t\t\t" << "sourceTree = \"<group>\";" << "\n"			      << "\t\t" << "};" << "\n";			}		    }		}nextfile:		QDir::setCurrent(oldpwd);	    }	}    }    for(QMap<QString, QStringList>::Iterator grp_it = groups.begin(); grp_it != groups.end(); ++grp_it) {	t << "\t\t" << keyFor(grp_it.key()) << " = {" << "\n"	  << "\t\t\t" << "isa = PBXGroup;" << "\n"	  << "\t\t\t" << "children = (" << "\n"	  << valGlue(grp_it.data(), "\t\t\t\t", ",\n\t\t\t\t", "\n")	  << "\t\t\t" << ");" << "\n"	  << "\t\t\t" << "name = \"" << grp_it.key().section(Option::dir_sep, -1) << "\";" << "\n"	  << "\t\t\t" << "refType = 4;" << "\n"	  << "\t\t" << "};" << "\n";    }    //DUMP EVERYTHING THAT TIES THE ABOVE TOGETHER    //BUILDSTYLE    QString active_buildstyle;#if 0    for(int as_release = 0; as_release < 2; as_release++)#else	bool as_release = !project->isActiveConfig("debug");#endif    {        QMap<QString, QString> settings;        settings.insert("COPY_PHASE_STRIP", (as_release ? "YES" : "NO"));        if(as_release)            settings.insert("GCC_GENERATE_DEBUGGING_SYMBOLS", "NO");        QString name;        if(pbVersion >= 42)            name = (as_release ? "Release" : "Debug");        else            name = (as_release ? "Deployment" : "Development");        if(pbVersion >= 42) {            QString key = keyFor("QMAKE_SUBDIR_PBX_BUILDCONFIG_" + name);            project->variables()["QMAKE_SUBDIR_PBX_BUILDCONFIGS"].append(key);            t << "\t\t" << key << " = {" << "\n"              << "\t\t\t" << "isa = XCBuildConfiguration;" << "\n"              << "\t\t\t" << "buildSettings = {" << "\n";            for(QMap<QString, QString>::Iterator set_it = settings.begin(); set_it != settings.end(); ++set_it)                t << "\t\t\t\t" << set_it.key() << " = \"" << set_it.data() << "\";\n";            t << "\t\t\t" << "};" << "\n"              << "\t\t\t" << "name = " << name << ";" << "\n"              << "\t\t" << "};" << "\n";        }        QString key = keyFor("QMAKE_SUBDIR_PBX_BUILDSTYLE_" + name);        if(project->isActiveConfig("debug") != (bool)as_release) {            project->variables()["QMAKE_SUBDIR_PBX_BUILDSTYLES"].append(key);            active_buildstyle = name;        } else if(pbVersion >= 42) {            project->variables()["QMAKE_SUBDIR_PBX_BUILDSTYLES"].append(key);        }        t << "\t\t" << key << " = {" << "\n"          << "\t\t\t" << "buildRules = (" << "\n"          << "\t\t\t" << ");" << "\n"          << "\t\t\t" << "buildSettings = {" << "\n";        for(QMap<QString, QString>::Iterator set_it = settings.begin(); set_it != settings.end(); ++set_it)            t << "\t\t\t\t" << set_it.key() << " = \"" << set_it.data() << "\";\n";        t << "\t\t\t" << "};" << "\n"          << "\t\t\t" << "isa = PBXBuildStyle;" << "\n"          << "\t\t\t" << "name = " << name << ";" << "\n"          << "\t\t" << "};" << "\n";    }    if(pbVersion >= 42) {        t << "\t\t" << keyFor("QMAKE_SUBDIR_PBX_BUILDCONFIG_LIST") << " = {" << "\n"          << "\t\t\t" << "isa = XCConfigurationList;" << "\n"          << "\t\t\t" << "buildConfigurations = (" << "\n"          << varGlue("QMAKE_SUBDIR_PBX_BUILDCONFIGS", "\t\t\t\t", ",\n\t\t\t\t", "\n")          << "\t\t\t" << ");" << "\n"          << "\t\t\t" << "defaultConfigurationIsVisible = 0;" << "\n"          << "\t\t\t" << "defaultConfigurationIsName = " << active_buildstyle << ";" << "\n"          << "\t\t" << "};" << "\n";    }#ifdef GENERATE_AGGREGRATE_SUBDIR    //target    t << "\t\t" << keyFor("QMAKE_SUBDIR_PBX_AGGREGATE_TARGET") << " = {" << "\n"      << "\t\t\t" << "buidPhases = (" << "\n"      << "\t\t\t" << ");" << "\n"      << "\t\t\t" << "buildSettings = {" << "\n"      << "\t\t\t\t" << "PRODUCT_NAME = " << project->variables()["TARGET"].first() << ";" << "\n"      << "\t\t\t" << "};" << "\n"      << "\t\t\t" << "dependencies = (" << "\n";    {        const QStringList &qmake_subdirs = project->variables()["QMAKE_PBX_SUBDIRS"];        for(int i = 0; i < qmake_subdirs.count(); i++)            t << "\t\t\t\t" << keyFor(qmake_subdirs[i] + "_TARGETREF") << "," << "\n";    }    t << "\t\t\t" << ");" << "\n"      << "\t\t\t" << "isa = PBXAggregateTarget;" << "\n"      << "\t\t\t" << "name = " << project->variables()["TARGET"].first() << ";" << "\n"      << "\t\t\t" << "productName = " << project->variables()["TARGET"].first() << ";" << "\n"      << "\t\t" << "};" << "\n";#endif

⌨️ 快捷键说明

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