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

📄 pbuilder_pbx.cpp

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.10平台上编译为嵌入式图形界面操作系统。
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/************************************************************************ Copyright (C) 2000-2005 Trolltech AS.  All rights reserved.**** This file is part of the Qtopia Environment.** ** This program is free software; you can redistribute it and/or modify it** under the terms of the GNU General Public License as published by the** Free Software Foundation; either version 2 of the License, or (at your** option) any later version.** ** A copy of the GNU GPL license version 2 is included in this package as ** LICENSE.GPL.**** This program is distributed in the hope that it will be useful, but** WITHOUT ANY WARRANTY; without even the implied warranty of** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ** See the GNU General Public License for more details.**** In addition, as a special exception Trolltech gives permission to link** the code of this program with Qtopia applications copyrighted, developed** and distributed by Trolltech under the terms of the Qtopia Personal Use** License Agreement. You must comply with the GNU General Public License** in all respects for all of the code used other than the applications** licensed under the Qtopia Personal Use License Agreement. If you modify** this file, you may extend this exception to your version of the file,** but you are not obligated to do so. If you do not wish to do so, delete** this exception statement from your version.** ** 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>#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") { 	writeSubdirs(t, FALSE);	return TRUE;    }    return FALSE;}boolProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t){    int i;    QStringList tmp;    bool did_preprocess = FALSE;    //HEADER    t << "// !$*UTF8*$!" << "\n"      << "{" << "\n"      << "\t" << "archiveVersion = 1;" << "\n"      << "\t" << "classes = {" << "\n" << "\t" << "};" << "\n"      << "\t" << "objectVersion = " << pbuilderVersion() << ";" << "\n"      << "\t" << "objects = {" << endl;    //MAKE QMAKE equivlant    if(!project->isActiveConfig("no_autoqmake") && project->projectFile() != "(stdin)") {	QString mkfile = pbx_dir + Option::dir_sep + "qt_makeqmake.mak";	QFile mkf(mkfile);	if(mkf.open(IO_WriteOnly | IO_Translate)) {	    debug_msg(1, "pbuilder: Creating file: %s", mkfile.latin1());	    QTextStream mkt(&mkf);	    writeHeader(mkt);	    mkt << "QMAKE    = "	<<		(project->isEmpty("QMAKE_QMAKE") ? QString("$(QTDIR)/bin/qmake") :		 var("QMAKE_QMAKE")) << endl;	    writeMakeQmake(mkt);	    mkf.close();	}	QString phase_key = keyFor("QMAKE_PBX_MAKEQMAKE_BUILDPHASE");	mkfile = fileFixify(mkfile, QDir::currentDirPath());	project->variables()["QMAKE_PBX_BUILDPHASES"].append(phase_key);	t << "\t\t" << phase_key << " = {" << "\n"	  << "\t\t\t" << "buildActionMask = 2147483647;" << "\n"	  << "\t\t\t" << "files = (" << "\n"	  << "\t\t\t" << ");" << "\n"	  << "\t\t\t" << "generatedFileNames = (" << "\n"	  << "\t\t\t" << ");" << "\n"	  << "\t\t\t" << "isa = PBXShellScriptBuildPhase;" << "\n"	  << "\t\t\t" << "name = \"Qt Qmake\";" << "\n"	  << "\t\t\t" << "neededFileNames = (" << "\n"	  << "\t\t\t" << ");" << "\n"	  << "\t\t\t" << "shellPath = /bin/sh;" << "\n"	  << "\t\t\t" << "shellScript = \"make -C " << QDir::currentDirPath() <<	    " -f " << mkfile << "\";" << "\n"	  << "\t\t" << "};" << "\n";    }    //DUMP SOURCES    QMap<QString, QStringList> groups;    QString srcs[] = { "HEADERS", "SOURCES", "SRCMOC", "UICIMPLS", "QMAKE_IMAGE_COLLECTION", QString::null };    for(i = 0; !srcs[i].isNull(); i++) {	tmp = project->variables()[srcs[i]];	QStringList &src_list = project->variables()["QMAKE_PBX_" + srcs[i]];	for(QStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it) {	    QString file = fileFixify((*it));	    if(file.endsWith(Option::cpp_moc_ext)) 		continue;	    bool in_root = TRUE;	    QString src_key = keyFor(file), name = file;	    if(!project->isActiveConfig("flat")) {		QString flat_file = fileFixify(file, QDir::currentDirPath(), Option::output_dir, TRUE);		if(QDir::isRelativePath(flat_file) && flat_file.find(Option::dir_sep) != -1) {		    QString last_grp("QMAKE_PBX_" + srcs[i] + "_HEIR_GROUP");		    QStringList dirs = QStringList::split(Option::dir_sep, flat_file);		    name = dirs.back();		    dirs.pop_back(); //remove the file portion as it will be added via src_key		    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)), last_grp_key(keyFor(last_grp));			if(dir_it == dirs.begin()) {			    if(!groups.contains(new_grp)) 				project->variables()["QMAKE_PBX_" + srcs[i]].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] += src_key;		    in_root = FALSE;		}	    }	    if(in_root)		src_list.append(src_key);	    //source reference	    t << "\t\t" << src_key << " = {" << "\n"	      << "\t\t\t" << "isa = PBXFileReference;" << "\n"	      << "\t\t\t" << "name = \"" << name << "\";" << "\n"	      << "\t\t\t" << "path = \"" << file << "\";" << "\n"	      << "\t\t\t" << "refType = " << reftypeForFile(file) << ";" << "\n"	      << "\t\t" << "};" << "\n";	    //build reference	    QString obj_key = file + ".o";	    obj_key = keyFor(obj_key);	    t << "\t\t" << obj_key << " = {" << "\n"	      << "\t\t\t" << "fileRef = " << src_key << ";" << "\n"	      << "\t\t\t" << "isa = PBXBuildFile;" << "\n"	      << "\t\t\t" << "settings = {" << "\n"	      << "\t\t\t\t" << "ATTRIBUTES = (" << "\n"	      << "\t\t\t\t" << ");" << "\n"	      << "\t\t\t" << "};" << "\n"	      << "\t\t" << "};" << "\n";	    project->variables()["QMAKE_PBX_OBJ"].append(obj_key);	}	if(!src_list.isEmpty()) {	    QString grp;	    if(srcs[i] == "SOURCES") {		if(project->first("TEMPLATE") == "app" && !project->isEmpty("RC_FILE")) { //Icon		    QString icns_file = keyFor("ICNS_FILE");		    src_list.append(icns_file);		    t << "\t\t" << icns_file << " = {" << "\n"		      << "\t\t\t" << "isa = PBXFileReference;" << "\n"		      << "\t\t\t" << "path = \"" << project->first("RC_FILE") << "\";" << "\n"		      << "\t\t\t" << "refType = " << reftypeForFile(project->first("RC_FILE")) << ";" << "\n"		      << "\t\t" << "};" << "\n";		    t << "\t\t" << keyFor("ICNS_FILE_REFERENCE") << " = {" << "\n"		      << "\t\t\t" << "fileRef = " << icns_file << ";" << "\n"		      << "\t\t\t" << "isa = PBXBuildFile;" << "\n"		      << "\t\t\t" << "settings = {" << "\n"		      << "\t\t\t" << "};" << "\n"		      << "\t\t" << "};" << "\n";		}		grp = "Sources";	    } else if(srcs[i] == "HEADERS") {		grp = "Headers";	    } else if(srcs[i] == "SRCMOC") {		grp = "Sources [moc]";	    } else if(srcs[i] == "UICIMPLS") {		grp = "Sources [uic]";	    } else if(srcs[i] == "QMAKE_IMAGE_COLLECTION") {		grp = "Sources [images]";	    }	    QString grp_key = keyFor(grp);	    project->variables()["QMAKE_PBX_GROUPS"].append(grp_key);	    t << "\t\t" << grp_key << " = {" << "\n"	      << "\t\t\t" << "children = (" << "\n"	      << varGlue("QMAKE_PBX_" + srcs[i], "\t\t\t\t", ",\n\t\t\t\t", "\n")	      << "\t\t\t" << ");" << "\n"	      << "\t\t\t" << "isa = PBXGroup;" << "\n"	      << "\t\t\t" << "name = \"" << grp << "\";" << "\n"	      << "\t\t\t" << "refType = 4;" << "\n"	      << "\t\t" << "};" << "\n";	}    }    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";    }    //PREPROCESS BUILDPHASE (just a makefile)    if(!project->isEmpty("UICIMPLS") || !project->isEmpty("SRCMOC") ||	!project->isEmpty("YACCSOURCES") || !project->isEmpty("LEXSOURCES")) {	QString mkfile = pbx_dir + Option::dir_sep + "qt_preprocess.mak";	QFile mkf(mkfile);	if(mkf.open(IO_WriteOnly | IO_Translate)) {	    did_preprocess = TRUE;	    debug_msg(1, "pbuilder: Creating file: %s", mkfile.latin1());	    QTextStream mkt(&mkf);	    writeHeader(mkt);	    mkt << "MOC       = " << Option::fixPathToTargetOS(var("QMAKE_MOC")) << endl;	    mkt << "UIC       = " << Option::fixPathToTargetOS(var("QMAKE_UIC")) << endl;	    mkt << "LEX       = " << var("QMAKE_LEX") << endl;	    mkt << "LEXFLAGS  = " << var("QMAKE_LEXFLAGS") << endl;	    mkt << "YACC      = " << var("QMAKE_YACC") << endl;	    mkt << "YACCFLAGS = " << var("QMAKE_YACCFLAGS") << endl;	    mkt << "DEL_FILE  = " << var("QMAKE_DEL_FILE") << endl;	    mkt << "MOVE      = " << var("QMAKE_MOVE") << endl << endl;	    mkt << "FORMS = " << varList("UICIMPLS") << endl;	    mkt << "IMAGES = " << varList("QMAKE_IMAGE_COLLECTION") << endl;	    mkt << "MOCS = " << varList("SRCMOC") << endl;	    mkt << "PARSERS =";	    if(!project->isEmpty("YACCSOURCES")) {		QStringList &yaccs = project->variables()["YACCSOURCES"];		for(QStringList::Iterator yit = yaccs.begin(); yit != yaccs.end(); ++yit) {		    QFileInfo fi((*yit));		    mkt << " " << fi.dirPath() << Option::dir_sep << fi.baseName(TRUE)			<< Option::yacc_mod << Option::cpp_ext.first();		}	    }	    if(!project->isEmpty("LEXSOURCES")) {		QStringList &lexs = project->variables()["LEXSOURCES"];		for(QStringList::Iterator lit = lexs.begin(); lit != lexs.end(); ++lit) {		    QFileInfo fi((*lit));		    mkt << " " << fi.dirPath() << Option::dir_sep << fi.baseName(TRUE)			<< Option::lex_mod << Option::cpp_ext.first();		}	    }	    mkt << "\n";	    mkt << "preprocess: $(FORMS) $(MOCS) $(PARSERS) $(IMAGES)" << endl;	    mkt << "preprocess_clean: mocclean uiclean parser_clean" << endl << endl;	    mkt << "mocclean:" << "\n";	    if(!project->isEmpty("SRCMOC"))		mkt << "\t-rm -f $(MOCS)" << "\n";	    mkt << "uiclean:" << "\n";	    if(!project->isEmpty("UICIMPLS"))		mkt << "\t-rm -f $(FORMS)" << "\n";	    if(!project->isEmpty("QMAKE_IMAGE_COLLECTION"))		mkt << "\t-rm -f $(IMAGES)" << "\n";	    mkt << "parser_clean:" << "\n";	    if(!project->isEmpty("YACCSOURCES") || !project->isEmpty("LEXSOURCES"))		mkt << "\t-rm -f $(PARSERS)" << "\n";	    writeUicSrc(mkt, "FORMS");	    writeMocSrc(mkt, "HEADERS");	    writeMocSrc(mkt, "SOURCES");	    writeMocSrc(mkt, "UICDECLS");	    writeYaccSrc(mkt, "YACCSOURCES");	    writeLexSrc(mkt, "LEXSOURCES");	    writeImageSrc(mkt, "QMAKE_IMAGE_COLLECTION");	    mkf.close();	}	QString target_key = keyFor("QMAKE_PBX_PREPROCESS_TARGET");	mkfile = fileFixify(mkfile, QDir::currentDirPath());	t << "\t\t" << target_key << " = {" << "\n"	  << "\t\t\t" << "buildArgumentsString = \"-f " << mkfile << "\";" << "\n"	  << "\t\t\t" << "buildPhases = (" << "\n"	  << "\t\t\t" << ");" << "\n"	  << "\t\t\t" << "buildSettings = {" << "\n"	  << "\t\t\t" << "};" << "\n"	  << "\t\t\t" << "buildToolPath = \"/usr/bin/gnumake\";"<< "\n"	  << "\t\t\t" << "buildWorkingDirectory = \"" << QDir::currentDirPath() << "\";" << "\n"	  << "\t\t\t" << "dependencies = (" << "\n"	  << "\t\t\t" << ");" << "\n"	  << "\t\t\t" << "isa = PBXLegacyTarget;" << "\n"	  << "\t\t\t" << "name = QtPreprocessors;" << "\n"	  << "\t\t\t" << "productName = QtPreprocessors;" << "\n"	  << "\t\t\t" << "settingsToExpand = 6;" << "\n"	  << "\t\t\t" << "settingsToPassInEnvironment = 287;" << "\n"	  << "\t\t\t" << "settingsToPassOnCommandLine = 280;" << "\n"	  << "\t\t\t" << "shouldsUseHeadermap = 0;" << "\n"	  << "\t\t" << "};" << "\n";	QString target_depend_key = keyFor("QMAKE_PBX_PREPROCESS_TARGET_DEPEND");	project->variables()["QMAKE_PBX_TARGETDEPENDS"].append(target_depend_key);	t << "\t\t" << target_depend_key << " = {" << "\n"	  << "\t\t\t" << "isa = PBXTargetDependency;" << "\n"	  << "\t\t\t" << "target = " << target_key << ";" << "\n"	  << "\t\t" << "};" << "\n";    }    //SOURCE BUILDPHASE    if(!project->isEmpty("QMAKE_PBX_OBJ")) {	QString grp = "Build Sources", key = keyFor(grp);	project->variables()["QMAKE_PBX_BUILDPHASES"].append(key);	t << "\t\t" << key << " = {" << "\n"	  << "\t\t\t" << "buildActionMask = 2147483647;" << "\n"	  << "\t\t\t" << "files = (" << "\n"	  << varGlue("QMAKE_PBX_OBJ", "\t\t\t\t", ",\n\t\t\t\t", "\n")	  << "\t\t\t" << ");" << "\n"	  << "\t\t\t" << "isa = PBXSourcesBuildPhase;" << "\n"	  << "\t\t\t" << "name = \"" << grp << "\";" << "\n"	  << "\t\t" << "};" << "\n";    }    if(!project->isActiveConfig("staticlib")) { //DUMP LIBRARIES	QStringList &libdirs = project->variables()["QMAKE_PBX_LIBPATHS"];	QString libs[] = { "QMAKE_LFLAGS", "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null };	for(i = 0; !libs[i].isNull(); i++) {	    tmp = project->variables()[libs[i]];	    for(QStringList::Iterator it = tmp.begin(); it != tmp.end();) {		bool remove = FALSE;		QString library, name, opt = (*it).stripWhiteSpace();		if(opt.startsWith("-L")) {

⌨️ 快捷键说明

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