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

📄 borland_bmake.cpp

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.10平台上编译为嵌入式图形界面操作系统。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/************************************************************************ 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 "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 << 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;    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) "      << 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 << 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");	}    }    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) tmp\\" + targetfilename + ".*");	t << "\n\t-$(DEL_FILE) tmp\\dump.*";    }    if(!project->isEmpty("IMAGES"))	t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-$(DEL_FILE) ", "\n\t-$(DEL_FILE) ", "");    t << endl;    // user defined targets    QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];    for(QStringList::Iterator 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;    t << "distclean: clean"

⌨️ 快捷键说明

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