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

📄 msvc_nmake.cpp

📁 Trolltech公司发布的基于C++图形开发环境
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/****************************************************************************** $Id: qt/msvc_nmake.cpp   3.3.4   edited Aug 17 11:24 $**** Implementation of NmakeMakefileGenerator class.**** Copyright (C) 1992-2003 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 "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()) {	{ //write the extra unix targets..	    QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];	    for(QStringList::ConstIterator it = qut.begin(); it != qut.end(); ++it)		t << *it << " ";	}	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;}QStringList&NmakeMakefileGenerator::findDependencies(const QString &file){    QStringList &aList = MakefileGenerator::findDependencies(file);    // Note: The QMAKE_IMAGE_COLLECTION file have all images    // as dependency, so don't add precompiled header then    if (file == project->first("QMAKE_IMAGE_COLLECTION"))	return aList;    for(QStringList::Iterator it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) {	if(file.endsWith(*it)) {	    if(!aList.contains(precompH))		aList += precompH;	    break;	}    }    return aList;}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);	if (inc.endsWith("\\"))	    inc.truncate(inc.length()-1);	if (inc.startsWith("\"") && inc.endsWith("\""))	    inc = inc.mid(1, inc.length() - 2);	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);	    if (lib.endsWith("\\"))		lib.truncate(lib.length()-1);	    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_FILE	=       " << var("QMAKE_COPY") << endl;    t << "COPY_DIR	=       " << var("QMAKE_COPY") << 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 << "INSTALL_FILE= " << var("QMAKE_INSTALL_FILE") << endl;    t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl;    t << endl;    t << "####### Files" << endl << 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;    QString extraCompilerDeps;    if(!project->isEmpty("QMAKE_EXTRA_WIN_COMPILERS")) {	t << "OBJCOMP = " << varList("OBJCOMP") << endl;	extraCompilerDeps += " $(OBJCOMP) ";	QStringList &comps = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];	for(QStringList::Iterator compit = comps.begin(); compit != comps.end(); ++compit) {	    QStringList &vars = project->variables()[(*compit) + ".variables"];	    for(QStringList::Iterator varit = vars.begin(); varit != vars.end(); ++varit) {		QStringList vals = project->variables()[(*varit)];		if(!vals.isEmpty())		    t << "QMAKE_COMP_" << (*varit) << " = " << valList(vals) << 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 << 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;	source_directories.insert(".", (void*)1);	QString directories[] = { QString("MOC_DIR"), QString("UI_SOURCES_DIR"), QString("UI_DIR"), QString::null };	for(int y = 0; !directories[y].isNull(); y++) {	    QString dirTemp = project->first(directories[y]);	    if (dirTemp.endsWith("\\"))		dirTemp.truncate(dirTemp.length()-1);	    if(!dirTemp.isEmpty())		source_directories.insert(dirTemp, (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.isEmpty() && !source_directories[dir])		    source_directories.insert(dir, (void*)1);	    }	}	for(QDictIterator<void> it(source_directories); it.current(); ++it) {	    if(it.currentKey().isEmpty())		continue;	    for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)		t << "{" << it.currentKey() << "}" << (*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.currentKey() << "}" << ".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) "      << extraCompilerDeps << 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 << extraCompilerDeps;    t << endl << "<<" << endl;

⌨️ 快捷键说明

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