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

📄 winmakefile.cpp

📁 Trolltech公司发布的基于C++图形开发环境
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** $Id: qt/winmakefile.cpp   3.3.4   edited Aug 3 11:22 $**** Implementation of Win32MakefileGenerator 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 "winmakefile.h"#include "option.h"#include "project.h"#include "meta.h"#include <qtextstream.h>#include <qstring.h>#include <qdict.h>#include <qregexp.h>#include <qstringlist.h>#include <qdir.h>Win32MakefileGenerator::Win32MakefileGenerator(QMakeProject *p) : MakefileGenerator(p){}struct SubDir{    QString directory, profile, target, makefile;};voidWin32MakefileGenerator::writeSubDirs(QTextStream &t){    QPtrList<SubDir> subdirs;    {	QStringList subdirs_in = project->variables()["SUBDIRS"];	for(QStringList::Iterator it = subdirs_in.begin(); it != subdirs_in.end(); ++it) {	    QString file = (*it);	    file = fileFixify(file);	    SubDir *sd = new SubDir;	    subdirs.append(sd);	    sd->makefile = "$(MAKEFILE)";	    if((*it).right(4) == ".pro") {		int slsh = file.findRev(Option::dir_sep);		if(slsh != -1) {		    sd->directory = file.left(slsh+1);		    sd->profile = file.mid(slsh+1);		} else {		    sd->profile = file;		}	    } else {		sd->directory = file;	    }	    while(sd->directory.right(1) == Option::dir_sep)		sd->directory = sd->directory.left(sd->directory.length() - 1);	    if(!sd->profile.isEmpty()) {		QString basename = sd->directory;		int new_slsh = basename.findRev(Option::dir_sep);		if(new_slsh != -1)		    basename = basename.mid(new_slsh+1);		if(sd->profile != basename + ".pro")		    sd->makefile += "." + sd->profile.left(sd->profile.length() - 4); //no need for the .pro	    }	    sd->target = "sub-" + (*it);	    sd->target.replace('/', '-');	    sd->target.replace('.', '_');	}    }    QPtrListIterator<SubDir> it(subdirs);    t << "MAKEFILE = " << (project->isEmpty("MAKEFILE") ? QString("Makefile") : var("MAKEFILE")) << endl;    t << "QMAKE =	" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl;    t << "SUBTARGETS	= ";    for( it.toFirst(); it.current(); ++it)	t << " \\\n\t\t" << it.current()->target;    t << endl << endl;    t << "all: $(MAKEFILE) $(SUBTARGETS)" << endl << endl;    for( it.toFirst(); it.current(); ++it) {	bool have_dir = !(*it)->directory.isEmpty();	//make the makefile	QString mkfile = (*it)->makefile;	if(have_dir)	    mkfile.prepend((*it)->directory + Option::dir_sep);	t << mkfile << ":";	if(have_dir)	    t << "\n\t" << "cd " << (*it)->directory;	t << "\n\t" << "$(QMAKE) " << (*it)->profile << " " << buildArgs();	t << " -o " << (*it)->makefile;	if(have_dir) {	    int subLevels = it.current()->directory.contains(Option::dir_sep) + 1;	    t << "\n\t" << "@cd ..";	    for(int i = 1; i < subLevels; i++ )		t << Option::dir_sep << "..";	}	t << endl;	//now actually build	t << (*it)->target << ": " << mkfile;	if(project->variables()["QMAKE_NOFORCE"].isEmpty())	    t << " FORCE";	if(have_dir)	    t << "\n\t" << "cd " << (*it)->directory;	t << "\n\t" << "$(MAKE)";        t << " -f " << (*it)->makefile;	if(have_dir) {	    int subLevels = it.current()->directory.contains(Option::dir_sep) + 1;	    t << "\n\t" << "@cd ..";	    for(int i = 1; i < subLevels; i++ )		t << Option::dir_sep << "..";	}	t << endl << endl;    }    if (project->isActiveConfig("ordered")) {   // generate dependencies        for( it.toFirst(); it.current(); ) {            QString tar = it.current()->target;            ++it;            if (it.current())                t << it.current()->target << ": " << tar << endl;        }        t << endl;    }    if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1)	project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all");    writeMakeQmake(t);    t << "qmake_all:";    if ( !subdirs.isEmpty() ) {	for( it.toFirst(); it.current(); ++it) {	    QString subdir = (*it)->directory;	    QString profile = (*it)->profile;	    int subLevels = subdir.contains(Option::dir_sep) + 1;	    t << "\n\t"	      << "cd " << subdir << "\n\t";	    int lastSlash = subdir.findRev(Option::dir_sep);	    if(lastSlash != -1)		subdir = subdir.mid( lastSlash + 1 );	    t << "$(QMAKE) "	      << ( !profile.isEmpty() ? profile : subdir + ".pro" )	      << " -o " << (*it)->makefile	      << " " << buildArgs() << "\n\t"	      << "@cd ..";	    for(int i = 1; i < subLevels; i++ )		t << Option::dir_sep << "..";	}    } else {	// Borland make does not like empty an empty command section, so insert	// a dummy command.	t << "\n\t" << "@cd .";    }    t << endl << endl;    QStringList targs;    targs << "clean" << "install_subdirs" << "mocables" << "uicables" << "uiclean" << "mocclean";    targs += project->values("SUBDIR_TARGETS");    for(QStringList::Iterator targ_it = targs.begin(); targ_it != targs.end(); ++targ_it) {        t << (*targ_it) << ": qmake_all";	QString targ = (*targ_it);	if(targ == "install_subdirs")	    targ = "install";	else if(targ == "uninstall_subdirs")	    targ = "uninstall";	if(targ == "clean")	    t << varGlue("QMAKE_CLEAN","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ", "");	if (!subdirs.isEmpty()) {	    for( it.toFirst(); it.current(); ++it) {		int subLevels = (*it)->directory.contains(Option::dir_sep) + 1;		bool have_dir = !(*it)->directory.isEmpty();		if(have_dir)		    t << "\n\t" << "cd " << (*it)->directory;		QString in_file = " -f " + (*it)->makefile;		t << "\n\t" << "$(MAKE) " << in_file << " " << targ;		if(have_dir) {		    t << "\n\t" << "@cd ..";		    for(int i = 1; i < subLevels; i++ )			t << Option::dir_sep << "..";		}	    }	} else {	    // Borland make does not like empty an empty command section, so	    // insert a dummy command.	    t << "\n\t" << "@cd .";	}	t << endl << endl;    }    //installations    project->variables()["INSTALLDEPS"]   += "install_subdirs";    project->variables()["UNINSTALLDEPS"] += "uninstall_subdirs";    writeInstalls(t, "INSTALLS");    // user defined targets    QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];    for(QStringList::Iterator sit = qut.begin(); sit != qut.end(); ++sit) {	QString targ = var((*sit) + ".target"),		 cmd = var((*sit) + ".commands"), deps;	if(targ.isEmpty())	    targ = (*sit);	QStringList &deplist = project->variables()[(*sit) + ".depends"];	for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {	    QString dep = var((*dep_it) + ".target");	    if(dep.isEmpty())		dep = (*dep_it);	    deps += " " + dep;	}	if(!project->variables()["QMAKE_NOFORCE"].isEmpty() && 	   project->variables()[(*sit) + ".CONFIG"].findIndex("phony") != -1)	    deps += QString(" ") + "FORCE";

⌨️ 快捷键说明

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