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

📄 msvc_dsp.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 "msvc_dsp.h"#include "option.h"#include <qdir.h>#include <qregexp.h>#include <stdlib.h>#include <time.h>DspMakefileGenerator::DspMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE){}boolDspMakefileGenerator::writeMakefile(QTextStream &t){    if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {	/* for now just dump, I need to generated an empty dsp or something.. */	fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n",		var("QMAKE_FAILED_REQUIREMENTS").latin1());	return TRUE;    }    if(project->first("TEMPLATE") == "vcapp" ||       project->first("TEMPLATE") == "vclib") {	return writeDspParts(t);    }    else if(project->first("TEMPLATE") == "subdirs") {	writeHeader(t);	writeSubDirs(t);	return TRUE;    }    return FALSE;}boolDspMakefileGenerator::writeDspParts(QTextStream &t){    QString dspfile;    if ( !project->variables()["DSP_TEMPLATE"].isEmpty() ) {	dspfile = project->first("DSP_TEMPLATE");    } else {	dspfile = project->first("MSVCDSP_TEMPLATE");    }    QString dspfile_loc = findTemplate(dspfile);    QFile file(dspfile_loc);    if(!file.open(IO_ReadOnly)) {	fprintf(stderr, "Cannot open dsp file: %s\n", dspfile.latin1());	return FALSE;    }    QTextStream dsp(&file);    int rep;    QString line;    while ( !dsp.eof() ) {	line = dsp.readLine();	while((rep = line.find(QRegExp("\\$\\$[a-zA-Z0-9_-]*"))) != -1) {	    QString torep = line.mid(rep, line.find(QRegExp("[^\\$a-zA-Z0-9_-]"), rep) - rep);	    QString variable = torep.right(torep.length()-2);	    t << line.left(rep); //output the left side	    line = line.right(line.length() - (rep + torep.length())); //now past the variable	    if(variable == "MSVCDSP_SOURCES") {		if(project->variables()["SOURCES"].isEmpty())		    continue;		QString mocpath = var( "QMAKE_MOC" );		mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " ";		QStringList list = project->variables()["SOURCES"] + project->variables()["DEF_FILE"];		if(!project->isActiveConfig("flat"))		    list.sort();		QStringList::Iterator it;		for( it = list.begin(); it != list.end(); ++it) {		    beginGroupForFile((*it), t);		    t << "# Begin Source File\n\nSOURCE=" << (*it) << endl;		    if ( project->isActiveConfig("moc") && (*it).endsWith(Option::cpp_moc_ext)) {			QString base = (*it);			base.replace(QRegExp("\\..*$"), "").upper();			base.replace(QRegExp("[^a-zA-Z]"), "_");			QString build = "\n\n# Begin Custom Build - Moc'ing " + findMocSource((*it)) +					"...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + (*it) + "\""					" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n"					"\t" + mocpath + findMocSource((*it)) + " -o " +					(*it) + "\n\n" "# End Custom Build\n\n";			t << "USERDEP_" << base << "=\".\\" << findMocSource((*it)) << "\" \"$(QTDIR)\\bin\\moc.exe\"" << endl << endl;			t << "!IF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build			  << "!ELSEIF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\""			  << build << "!ENDIF " << endl << endl;		    }		    t << "# End Source File" << endl;		}		endGroups(t);	    } else if(variable == "MSVCDSP_IMAGES") {		if(project->variables()["IMAGES"].isEmpty())		    continue;		t << "# Begin Source File\n\nSOURCE=" << project->first("QMAKE_IMAGE_COLLECTION") << endl;		t << "# End Source File" << endl;	    } else if(variable == "MSVCDSP_HEADERS") {		if(project->variables()["HEADERS"].isEmpty())		    continue;		QStringList list = project->variables()["HEADERS"];		if(!project->isActiveConfig("flat"))		    list.sort();		for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {//		    beginGroupForFile((*it), t);		    t << "# Begin Source File\n\nSOURCE=" << (*it) << endl << endl;		    if ( project->isActiveConfig("moc") && !findMocDestination((*it)).isEmpty()) {			QString base = (*it);			base.replace(QRegExp("\\..*$"), "").upper();			base.replace(QRegExp("[^a-zA-Z]"), "_");			QString mocpath = var( "QMAKE_MOC" );			mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " ";			QString build = "\n\n# Begin Custom Build - Moc'ing " + (*it) +					"...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + findMocDestination((*it)) +					"\"" " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n"					"\t" + mocpath + (*it)  + " -o " +					findMocDestination((*it)) + "\n\n" "# End Custom Build\n\n";			t << "USERDEP_" << base << "=\"$(QTDIR)\\bin\\moc.exe\"" << endl << endl;			t << "!IF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build			  << "!ELSEIF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\""			  << build << "!ENDIF " << endl << endl;		    }		    t << "# End Source File" << endl;		}//		endGroups(t);	    } else if(variable == "MSVCDSP_FORMSOURCES" || variable == "MSVCDSP_FORMHEADERS") {		if(project->variables()["FORMS"].isEmpty())		    continue;		QString uiSourcesDir;		QString uiHeadersDir;		if(!project->variables()["UI_DIR"].isEmpty()) {		    uiSourcesDir = project->first("UI_DIR");		    uiHeadersDir = project->first("UI_DIR");		} else {		    if ( !project->variables()["UI_SOURCES_DIR"].isEmpty() )			uiSourcesDir = project->first("UI_SOURCES_DIR");		    else			uiSourcesDir = "";		    if ( !project->variables()["UI_HEADERS_DIR"].isEmpty() )			uiHeadersDir = project->first("UI_HEADERS_DIR");		    else			uiHeadersDir = "";		}		QStringList list = project->variables()["FORMS"];		if(!project->isActiveConfig("flat"))		    list.sort();		QString ext = variable == "MSVCDSP_FORMSOURCES" ? ".cpp" : ".h";		for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {		    QString base = (*it);		    int dot = base.findRev(".");  		    base.replace( dot, base.length() - dot, ext );		    QString fname = base;		    int lbs = fname.findRev( "\\" );		    QString fpath;		    if ( lbs != -1 )			fpath = fname.left( lbs + 1 );		    fname = fname.right( fname.length() - lbs - 1 );		    if ( ext == ".cpp" && !uiSourcesDir.isEmpty() )			fname.prepend(uiSourcesDir);		    else if ( ext == ".h" && !uiHeadersDir.isEmpty() )			fname.prepend(uiHeadersDir);		    else			fname = base;//		    beginGroupForFile(fname, t);		    t << "# Begin Source File\n\nSOURCE=" << fname		      << "\n# End Source File" << endl;		}//		endGroups(t);	    } else if(variable == "MSVCDSP_TRANSLATIONS" ) {		if(project->variables()["TRANSLATIONS"].isEmpty())		    continue;		t << "# Begin Group \"Translations\"\n";		t << "# Prop Default_Filter \"ts\"\n";		QStringList list = project->variables()["TRANSLATIONS"];		if(!project->isActiveConfig("flat"))		    list.sort();		for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {		    QString sify = *it;		    sify.replace('/', '\\' );		    QString base = (*it);		    base.replace(QRegExp("\\..*$"), "").upper();		    base.replace(QRegExp("[^a-zA-Z]"), "_");//		    beginGroupForFile(sify, t);		    t << "# Begin Source File\n\nSOURCE=" << sify << endl;		    t << "\n# End Source File" << endl;		}//		endGroups(t);		t << "\n# End Group\n";	    } else if (variable == "MSVCDSP_MOCSOURCES" && project->isActiveConfig("moc")) {		if ( project->variables()["SRCMOC"].isEmpty())		    continue;		QString mocpath = var( "QMAKE_MOC" );		mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " ";		QStringList list = project->variables()["SRCMOC"];		if(!project->isActiveConfig("flat"))		    list.sort();		for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {//		    beginGroupForFile((*it), t);		    t << "# Begin Source File\n\nSOURCE=" << (*it) << endl;		    if ( project->isActiveConfig("moc") && (*it).endsWith(Option::cpp_moc_ext)) {			QString base = (*it);			base.replace(QRegExp("\\..*$"), "").upper();			base.replace(QRegExp("[^a-zA-Z]"), "_");			QString build = "\n\n# Begin Custom Build - Moc'ing " + findMocSource((*it)) +					"...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + (*it) + "\""					" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n"					"\t" + mocpath + findMocSource((*it)) + " -o " +					(*it) + "\n\n" "# End Custom Build\n\n";			t << "USERDEP_" << base << "=\".\\" << findMocSource((*it)) << "\" \"$(QTDIR)\\bin\\moc.exe\"" << endl << endl;			t << "!IF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build			  << "!ELSEIF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\""			  << build << "!ENDIF " << endl << endl;		    }		    t << "# End Source File" << endl;		}//		endGroups(t);	    } else if(variable == "MSVCDSP_PICTURES") {		if(project->variables()["IMAGES"].isEmpty())		    continue;		t << "# Begin Group \"Images\"\n"		  << "# Prop Default_Filter \"png jpeg bmp xpm\"\n";		QStringList list = project->variables()["IMAGES"];		if(!project->isActiveConfig("flat"))		    list.sort();		QStringList::Iterator it;		// dump the image list to a file UIC can read.		QFile f( "images.tmp" );		f.open( IO_WriteOnly );		QTextStream ts( &f );		for( it = list.begin(); it != list.end(); ++it )		    ts << " " << *it;		f.close();		// create an output step for images not more than once		bool imagesBuildDone = FALSE;		for( it = list.begin(); it != list.end(); ++it ) {//		    beginGroupForFile((*it), t);		    t << "# Begin Source File\n\nSOURCE=" << (*it) << endl;		    QString base = (*it);		    QString uicpath = var("QMAKE_UIC");		    uicpath = uicpath.replace(QRegExp("\\..*$"), "") + " ";		    if ( !imagesBuildDone ) {			imagesBuildDone = TRUE;			QString build = "\n\n# Begin Custom Build - Creating image collection...\n"			    "InputPath=.\\" + base + "\n\n";			build += "\"" + project->first("QMAKE_IMAGE_COLLECTION") + "\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n";			build += "\t" + uicpath + "-embed " + project->first("QMAKE_ORIG_TARGET") + " -f images.tmp -o "				      + project->first("QMAKE_IMAGE_COLLECTION") + "\n\n";			build.append("# End Custom Build\n\n");			t << "USERDEP_" << base << "=";			QStringList::Iterator it2 = list.begin();			while ( it2 != list.end() ) {			    t << "\"" << (*it2) << "\"";			    it2++;			    if ( it2 != list.end() )				t << "\\\n";			}			t << endl << endl;			t << "!IF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build			  << "!ELSEIF  \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build			  << "!ENDIF \n\n" << endl;		    }		    t << "# End Source File" << endl;		}//		endGroups(t);		t << "\n# End Group\n";	    } else if(variable == "MSVCDSP_FORMS") {		if(project->variables()["FORMS"].isEmpty())		    continue;		t << "# Begin Group \"Forms\"\n"		  << "# Prop Default_Filter \"ui\"\n";		QString uicpath = var("QMAKE_UIC");		uicpath = uicpath.replace(QRegExp("\\..*$"), "") + " ";		QString mocpath = var( "QMAKE_MOC" );		mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " ";		QStringList list = project->variables()["FORMS"];		if(!project->isActiveConfig("flat"))		    list.sort();		for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {		    QString base = (*it);//		    beginGroupForFile(base, t);		    t <<  "# Begin Source File\n\nSOURCE=" << base << endl;		    QString fname = base;

⌨️ 快捷键说明

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