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

📄 msvc_nmake.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_nmake.h"#include "option.h"#include <qregexp.h>#include <qdict.h>#include <qdir.h>#include <stdlib.h>#include <time.h>NmakeMakefileGenerator::NmakeMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE){}boolNmakeMakefileGenerator::writeMakefile(QTextStream &t){    writeHeader(t);    if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {	t << "all clean:" << "\n\t"	  << "@echo \"Some of the required modules ("	  << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"	  << "@echo \"Skipped.\"" << endl << endl;	writeMakeQmake(t);	return TRUE;    }    if(project->first("TEMPLATE") == "app" ||       project->first("TEMPLATE") == "lib") {	writeNmakeParts(t);	return MakefileGenerator::writeMakefile(t);    }    else if(project->first("TEMPLATE") == "subdirs") {	writeSubDirs(t);	return TRUE;    }    return FALSE;}voidNmakeMakefileGenerator::writeNmakeParts(QTextStream &t){    t << "####### Compiler, tools and options" << endl << endl;    t << "CC		=	" << var("QMAKE_CC") << endl;    t << "CXX		=	" << var("QMAKE_CXX") << endl;    t << "LEX		= " << var("QMAKE_LEX") << endl;    t << "YACC		= " << var("QMAKE_YACC") << endl;    t << "CFLAGS	=	" << var("QMAKE_CFLAGS") << " "      << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "      <<  varGlue("DEFINES","-D"," -D","") << endl;    t << "CXXFLAGS	=	" << var("QMAKE_CXXFLAGS") << " "      << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "      << varGlue("DEFINES","-D"," -D","") << endl;    t << "LEXFLAGS	=" << var("QMAKE_LEXFLAGS") << endl;    t << "YACCFLAGS	=" << var("QMAKE_YACCFLAGS") << endl;    t << "INCPATH	=	";    QStringList &incs = project->variables()["INCLUDEPATH"];    for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {	QString inc = (*incit);	inc.replace(QRegExp("\\\\$"), "\\\\");	inc.replace("\"", "");	t << " -I\"" << inc << "\"";    }    t << " -I\"" << specdir() << "\""      << endl;    if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {	t << "LINK	=	" << var("QMAKE_LINK") << endl;	t << "LFLAGS	=	" << var("QMAKE_LFLAGS");	if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )	  t << " " << varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\"");	t << endl;	t << "LIBS	=	";	QStringList &libs = project->variables()["QMAKE_LIBS"];	for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) {	    QString lib = (*libit);	    lib.replace(QRegExp("\\\\$"), "\\\\");	    lib.replace(QRegExp("\""), "");	    t << " \"" << lib << "\"";	}	t << endl;    }    else {	t << "LIB	=	" << var("QMAKE_LIB") << endl;    }    t << "MOC		=	" << (project->isEmpty("QMAKE_MOC") ? QString("moc") :			      Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl;    t << "UIC		=	" << (project->isEmpty("QMAKE_UIC") ? QString("uic") :			      Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl;    t << "QMAKE		=	" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") :			      Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl;    t << "IDC		=	" << (project->isEmpty("QMAKE_IDC") ? QString("idc") :			      Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl;    t << "IDL		=	" << (project->isEmpty("QMAKE_IDL") ? QString("midl") :			      Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl;    t << "ZIP		=	" << var("QMAKE_ZIP") << endl;    t << "COPY		=       " << var("QMAKE_COPY") << endl;    t << "COPY_FILE	=       " << var("QMAKE_COPY_FILE") << endl;    t << "COPY_DIR	=       " << var("QMAKE_COPY_DIR") << endl;    t << "DEL_FILE	=       " << var("QMAKE_DEL_FILE") << endl;    t << "DEL_DIR	=       " << var("QMAKE_DEL_DIR") << endl;    t << "MOVE		=       " << var("QMAKE_MOVE") << endl;    t << "CHK_DIR_EXISTS =	" << var("QMAKE_CHK_DIR_EXISTS") << endl;    t << "MKDIR		=	" << var("QMAKE_MKDIR") << endl;    t << endl;    t << "####### Files" << endl << endl;    t << "TRANSLATABLES = " << varList("TRANSLATABLES") << endl;    t << "HEADERS =	" << varList("HEADERS") << endl;    t << "SOURCES =	" << varList("SOURCES") << endl;    t << "OBJECTS =	" << varList("OBJECTS") << endl;    t << "FORMS =	" << varList("FORMS") << endl;    t << "UICDECLS =	" << varList("UICDECLS") << endl;    t << "UICIMPLS =	" << varList("UICIMPLS") << endl;    t << "SRCMOC	=	" << varList("SRCMOC") << endl;    t << "OBJMOC	=	" << varList("OBJMOC") << endl;    t << "DIST	=	" << varList("DISTFILES") << endl;    t << "TARGET	=	";    if( !project->variables()[ "DESTDIR" ].isEmpty() )	t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT"));    else	t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first();    t << endl;    t << "INSTALL_TARGET	= ";    t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first();    t << endl;    t << "####### Implicit rules" << endl << endl;    t << ".SUFFIXES: .c";    QStringList::Iterator cppit;    for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)	t << " " << (*cppit);    t << endl << endl;    if(!project->isActiveConfig("no_batch")) {	// Batchmode doesn't use the non implicit rules QMAKE_RUN_CXX & QMAKE_RUN_CC	project->variables().remove("QMAKE_RUN_CXX");	project->variables().remove("QMAKE_RUN_CC");	QDict<void> source_directories_cache;	QStringList source_directories;	if(!project->isEmpty("MOC_DIR")) {	    source_directories << project->first("MOC_DIR");	    source_directories_cache.insert(project->first("MOC_DIR"), (void*)1);        }	if(!project->isEmpty("UI_SOURCES_DIR")) {	    source_directories << project->first("UI_SOURCES_DIR");	    source_directories_cache.insert(project->first("UI_SOURCES_DIR"), (void*)1);	} else if(!project->isEmpty("UI_DIR")) {	    source_directories << project->first("UI_DIR");	    source_directories_cache.insert(project->first("UI_DIR"), (void*)1);        }	QString srcs[] = { QString("SOURCES"), QString("UICIMPLS"), QString("SRCMOC"), QString::null };	for(int x = 0; !srcs[x].isNull(); x++) {	    QStringList &l = project->variables()[srcs[x]];	    for(QStringList::Iterator sit = l.begin(); sit != l.end(); ++sit) {		QString sep = "\\";		if((*sit).find(sep) == -1)		    sep = "/";		QString dir = (*sit).section(sep, 0, -2);		if(dir != "." && !dir.isEmpty() && !source_directories_cache[dir]){		    source_directories << dir;		    source_directories_cache.insert(dir, (void*)1);		}	    }	}	source_directories << "."; // put dot rules last	for(QStringList::Iterator it = source_directories.begin();            it != source_directories.end(); ++it) {	    if((*it).isEmpty())		continue;	    for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)		t << "{" << (*it) << "}" << (*cppit) << "{" << var("OBJECTS_DIR") << "}" << Option::obj_ext << "::\n\t"		  << var("QMAKE_RUN_CXX_IMP_BATCH").replace( QRegExp( "\\$@" ), var("OBJECTS_DIR") ) << endl << "\t$<" << endl << "<<" << endl << endl;	    t << "{" << (*it) << "}" << ".c{" << var("OBJECTS_DIR") << "}" << Option::obj_ext << "::\n\t"	      << var("QMAKE_RUN_CC_IMP_BATCH").replace( QRegExp( "\\$@" ), var("OBJECTS_DIR") ) << endl << "\t$<" << endl << "<<" << endl << endl;	}    } else {	for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)	    t << (*cppit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;	t << ".c" << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;    }    t << "####### Build rules" << endl << endl;    t << "all: " << fileFixify(Option::output.name()) << " " << varGlue("ALL_DEPS"," "," "," ") << "$(TARGET)" << endl << endl;    t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "      << var("POST_TARGETDEPS");    if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {	t << "\n\t" << "$(LINK) $(LFLAGS) /OUT:$(TARGET) @<< " << "\n\t  "	  << "$(OBJECTS) $(OBJMOC) $(LIBS)";    } else {	t << "\n\t" << "$(LIB) /OUT:$(TARGET) @<<" << "\n\t  "	  << "$(OBJECTS) $(OBJMOC)";    }    t << endl << "<<" << endl;    if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() )	t << "\t" << var( "QMAKE_POST_LINK" ) << endl;    if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {	QStringList dlldirs = project->variables()["DLLDESTDIR"];	for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {	    t << "\n\t" << "-$(COPY_FILE) $(TARGET) " << *dlldir;	}    }    QString targetfilename = project->variables()["TARGET"].first();    if(project->isActiveConfig("activeqt")) {	QString version = project->variables()["VERSION"].first();	if ( version.isEmpty() )	    version = "1.0";	if ( project->isActiveConfig("dll")) {	    t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version);	    t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl");	    t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");	    t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );	} else {	    t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version);	    t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl");	    t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");	    t << "\n\t" << "-$(TARGET) -regserver";	}    }

⌨️ 快捷键说明

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