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

📄 borland_bmake.cpp

📁 Trolltech公司发布的基于C++图形开发环境
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** $Id: qt/borland_bmake.cpp   3.3.4   edited Jul 21 2004 $**** NmakeMakefileGenerator of BorlandMakefileGenerator 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 "borland_bmake.h"#include "option.h"#include <qdir.h>#include <qregexp.h>#include <time.h>#include <stdlib.h>BorlandMakefileGenerator::BorlandMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE){}boolBorlandMakefileGenerator::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;	return TRUE;    }    if(project->first("TEMPLATE") == "app" ||       project->first("TEMPLATE") == "lib") {	writeBorlandParts(t);	return MakefileGenerator::writeMakefile(t);    }    else if(project->first("TEMPLATE") == "subdirs") {	writeSubDirs(t);	return TRUE;    }    return FALSE;}voidBorlandMakefileGenerator::writeBorlandParts(QTextStream &t){    t << "!if !$d(BCB)" << endl;    t << "BCB = $(MAKEDIR)\\.." << endl;    t << "!endif" << endl << endl;    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	=	";	if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )	    t << varGlue("QMAKE_LIBDIR","-L",";","") << " ";	t << var("QMAKE_LFLAGS") << endl;	t << "LIBS	=	" << var("QMAKE_LIBS") << 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 << "RES_FILE =	" << varList("RES_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 << "####### 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	=	"      << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT"))      << 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;    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) @&&|" << "\n\t"	  << "$(LFLAGS) $(OBJECTS) $(OBJMOC),$(TARGET),,$(LIBS),$(DEF_FILE),$(RES_FILE)";    } else {	t << "\n\t-$(DEL_FILE) $(TARGET)"	  << "\n\t" << "$(LIB) $(TARGET) @&&|" << " \n+"	  << project->variables()["OBJECTS"].join(" \\\n+") << " \\\n+"	  << project->variables()["OBJMOC"].join(" \\\n+");    }    t << extraCompilerDeps;    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 " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version);	    t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");	    t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");	    t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );	} else {	    t << "\n\t" << ("-$(TARGET) -dumpidl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version);	    t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");	    t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb");	    t << "\n\t" << ("-$(TARGET) -regserver");	}    }    t << endl << endl;    if(!project->variables()["RC_FILE"].isEmpty()) {	t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t"	  << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl;    }    t << "mocables: $(SRCMOC)" << endl      << "uicables: $(UICIMPLS) $(UICDECLS)" << endl << endl;    writeMakeQmake(t);    QStringList dist_files = Option::mkfile::project_files;    if(!project->isEmpty("QMAKE_INTERNAL_INCLUDED_FILES"))	dist_files += project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"];    if(!project->isEmpty("TRANSLATIONS"))	dist_files << var("TRANSLATIONS");    if(!project->isEmpty("FORMS")) {	QStringList &forms = project->variables()["FORMS"];	for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) {	    QString ui_h = fileFixify((*formit) + Option::h_ext.first());	    if(QFile::exists(ui_h) )		dist_files << ui_h;	}    }    t << "dist:" << "\n\t"      << "$(ZIP) " << var("QMAKE_ORIG_TARGET") << ".zip " << "$(SOURCES) $(HEADERS) $(DIST) $(FORMS) "      << dist_files.join(" ") << " " << var("TRANSLATIONS") << " " << var("IMAGES") << endl << endl;    t << "uiclean:";    QString uiclean = varGlue("UICDECLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") + varGlue("UICIMPLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","");    if ( uiclean.isEmpty() ) {	// Borland make does not like an empty command section	uiclean = "\n\t@cd .";    }    t << uiclean << endl;    t << "mocclean:";    QString mocclean = varGlue("SRCMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") + varGlue("OBJMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","");    if ( mocclean.isEmpty() ) {	// Borland make does not like an empty command section	mocclean = "\n\t@cd .";    }    t << mocclean << endl;    t << "clean: uiclean mocclean"      << varGlue("OBJECTS","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")      << varGlue("QMAKE_CLEAN","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","")      << varGlue("CLEAN_FILES","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","");    if ( project->isActiveConfig("activeqt")) {	t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".idl");	t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".tlb");    }    if(!project->isEmpty("IMAGES"))	t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-$(DEL_FILE) ", "\n\t-$(DEL_FILE) ", "");    t << endl;    // user defined targets    QStringList::Iterator it;    QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];    for(it = qut.begin(); it != qut.end(); ++it) {	QString targ = var((*it) + ".target"),		 cmd = var((*it) + ".commands"), deps;	if(targ.isEmpty())	    targ = (*it);	QStringList &deplist = project->variables()[(*it) + ".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()[(*it) + ".CONFIG"].findIndex("phony") != -1)	    deps += QString(" ") + "FORCE";	t << "\n\n" << targ << ":" << deps << "\n\t"	  << cmd;    }    t << endl << endl;    QStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"];    for(it = quc.begin(); it != quc.end(); ++it) {	QString tmp_out = project->variables()[(*it) + ".output"].first();	QString tmp_cmd = project->variables()[(*it) + ".commands"].join(" ");	QString tmp_dep = project->variables()[(*it) + ".depends"].join(" ");	QStringList &vars = project->variables()[(*it) + ".variables"];	if(tmp_out.isEmpty() || tmp_cmd.isEmpty())	    continue;	QStringList &tmp = project->variables()[(*it) + ".input"];	for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {	    QStringList &inputs = project->variables()[(*it2)];	    for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {		QFileInfo fi(Option::fixPathToLocalOS((*input)));		QString in = Option::fixPathToTargetOS((*input), FALSE),		       out = tmp_out, cmd = tmp_cmd, deps;		out.replace("${QMAKE_FILE_BASE}", fi.baseName());		out.replace("${QMAKE_FILE_NAME}", fi.filePath());		cmd.replace("${QMAKE_FILE_BASE}", fi.baseName());		cmd.replace("${QMAKE_FILE_OUT}", out);		cmd.replace("${QMAKE_FILE_NAME}", fi.filePath());		for(QStringList::Iterator it3 = vars.begin(); it3 != vars.end(); ++it3)		    cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")");		if(!tmp_dep.isEmpty()) {		    char buff[256];		    QString dep_cmd = tmp_dep;		    dep_cmd.replace("${QMAKE_FILE_NAME}", fi.filePath());		    if(FILE *proc = QT_POPEN(dep_cmd.latin1(), "r")) {			while(!feof(proc)) {

⌨️ 快捷键说明

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