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

📄 mingw_make.cpp

📁 Trolltech公司发布的基于C++图形开发环境
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/****************************************************************************** $Id: qt/mingw_make.cpp   3.3.4   edited Aug 24 10:04 $**** Implementation of MingwMakefileGenerator 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 "mingw_make.h"#include "option.h"#include <qregexp.h>#include <qdir.h>#include <stdlib.h>#include <time.h>MingwMakefileGenerator::MingwMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE){    Option::obj_ext = ".o";}boolMingwMakefileGenerator::findLibraries() // todo - pascal{    return TRUE;}boolMingwMakefileGenerator::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") {	writeMingwParts(t);	return MakefileGenerator::writeMakefile(t);    }    else if(project->first("TEMPLATE") == "subdirs") {	writeSubDirs(t);	return TRUE;    }    return FALSE; }void createLdObjectScriptFile(const QString & fileName, QStringList & objList){    QString filePath = Option::output_dir + QDir::separator() + fileName;    QFile file(filePath);    if (file.open(IO_WriteOnly | IO_Translate )) {	QTextStream t(&file);	t << "INPUT(" << endl;	for (QStringList::Iterator it = objList.begin(); it != objList.end(); ++it ) {	    if (QDir::isRelativePath(*it))		t << "./" << *it << endl;	    else		t << *it << endl;	}	t << ");" << endl;	file.close();    }}voidMingwMakefileGenerator::writeMingwParts(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(QRegExp("\""), "");	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") << endl;	t << "LIBS	=	";	if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )	    t << varGlue("QMAKE_LIBDIR","-L\"","\" -L\"","\"") << " ";	t << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << 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 << "DEF_FILE      =	" << varList("DEF_FILE") << 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 << "####### Output directory" << endl << endl;    if (! project->variables()["OBJECTS_DIR"].isEmpty())	t << "OBJECTS_DIR = " << var("OBJECTS_DIR").replace(QRegExp("\\\\$"),"") << endl;    else	t << "OBJECTS_DIR = . " << endl;    if (! project->variables()["MOC_DIR"].isEmpty())	t << "MOC_DIR = " << var("MOC_DIR").replace(QRegExp("\\\\$"),"") << endl;    else	t << "MOC_DIR = . " << endl;    t << endl;    t << "####### Files" << endl << endl;    t << "HEADERS =	" << varList("HEADERS") << endl;    t << "SOURCES =	" << varList("SOURCES") << endl;    QString objectsLinkLine;    if (!project->variables()["QMAKE_APP_OR_DLL"].isEmpty() &&	project->variables()["OBJECTS"].count() > var("QMAKE_LINK_OBJECT_MAX").toUInt()) {	createLdObjectScriptFile(var("QMAKE_LINK_OBJECT_SCRIPT"), project->variables()["OBJECTS"]);	objectsLinkLine = var("QMAKE_LINK_OBJECT_SCRIPT");    } else {	objectsLinkLine = "$(OBJECTS)";    }    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;    QString objmocLinkLine;    if (!project->variables()["QMAKE_APP_OR_DLL"].isEmpty() &&	project->variables()["OBJMOC"].count() > var("QMAKE_LINK_OBJECT_MAX").toUInt()) {	createLdObjectScriptFile(var("QMAKE_LINK_OBJMOC_SCRIPT"), project->variables()["OBJMOC"]);	objmocLinkLine = var("QMAKE_LINK_OBJMOC_SCRIPT");    } else {	objmocLinkLine = "$(OBJMOC)";    }    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: .cpp .cxx .cc .C .c" << endl << endl;    t << ".cpp.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;    t << ".cxx.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;    t << ".cc.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;    t << ".c.o:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;    t << "####### Build rules" << endl << endl;    t << "all: " << "$(OBJECTS_DIR) " << "$(MOC_DIR) " << 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) -o $(TARGET) " << objectsLinkLine << " " << objmocLinkLine << " $(LIBS)";    } else {	t << "\n\t" << "$(LIB) $(TARGET) " << objectsLinkLine << " " << objmocLinkLine;    }    t << extraCompilerDeps;    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;

⌨️ 快捷键说明

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