Eneboo - Documentación para desarrolladores
src/qt/qmake/generators/makefile.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/makefile.h   3.3.8   edited Jan 11 14:37 $
00003 **
00004 ** Definition of MakefileGenerator class.
00005 **
00006 ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
00007 **
00008 ** This file is part of qmake.
00009 **
00010 ** This file may be distributed under the terms of the Q Public License
00011 ** as defined by Trolltech ASA of Norway and appearing in the file
00012 ** LICENSE.QPL included in the packaging of this file.
00013 **
00014 ** This file may be distributed and/or modified under the terms of the
00015 ** GNU General Public License version 2 as published by the Free Software
00016 ** Foundation and appearing in the file LICENSE.GPL included in the
00017 ** packaging of this file.
00018 **
00019 ** Licensees holding valid Qt Enterprise Edition licenses may use this
00020 ** file in accordance with the Qt Commercial License Agreement provided
00021 ** with the Software.
00022 **
00023 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00024 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00025 **
00026 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00027 **   information about Qt Commercial License Agreements.
00028 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00029 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00030 **
00031 ** Contact info@trolltech.com if any conditions of this licensing are
00032 ** not clear to you.
00033 **
00034 **********************************************************************/
00035 #ifndef __MAKEFILE_H__
00036 #define __MAKEFILE_H__
00037 
00038 #include "option.h"
00039 #include "project.h"
00040 #include <qtextstream.h>
00041 
00042 #ifdef Q_OS_WIN32
00043 #define QT_POPEN _popen
00044 #else
00045 #define QT_POPEN popen
00046 #endif
00047 
00048 class MakefileGenerator
00049 {
00050     QString spec;
00051     bool init_opath_already, init_already, moc_aware, no_io;
00052     QStringList createObjectList(const QString &var);
00053     QString build_args();
00054     QString dependencyKey(const QString &file) const;
00055     QMap<QString, bool> depProcessed;
00056     QMap<QString, QString> depHeuristics, fileFixed;
00057     QMap<QString, QString> mocablesToMOC, mocablesFromMOC;
00058     QMap<QString, QStringList> depends;
00059 
00060 protected:
00061     void writeObj(QTextStream &, const QString &obj, const QString &src);
00062     void writeUicSrc(QTextStream &, const QString &ui);
00063     void writeMocObj(QTextStream &, const QString &obj, const QString &src);
00064     void writeMocSrc(QTextStream &, const QString &src);
00065     void writeLexSrc(QTextStream &, const QString &lex);
00066     void writeYaccSrc(QTextStream &, const QString &yac);
00067     void writeInstalls(QTextStream &t, const QString &installs);
00068     void writeImageObj(QTextStream &t, const QString &obj);
00069     void writeImageSrc(QTextStream &t, const QString &images);
00070 
00071 protected:
00072 
00073     QMakeProject *project;
00074 
00075     class MakefileDependDir {
00076     public:
00077         MakefileDependDir(const QString &r, const QString &l) : real_dir(r), local_dir(l) { }
00078         QString real_dir, local_dir;
00079     };
00080     bool generateDependencies(QPtrList<MakefileDependDir> &dirs, const QString &x, bool recurse);
00081 
00082     QString buildArgs();
00083 
00084     QString specdir();
00085     QString cleanFilePath(const QString &file) const;
00086     bool generateMocList(const QString &fn);
00087 
00088     QString findMocSource(const QString &moc_file) const;
00089     QString findMocDestination(const QString &src_file) const;
00090     virtual QStringList &findDependencies(const QString &file);
00091 
00092     void setNoIO(bool o);
00093     bool noIO() const;
00094 
00095     void setMocAware(bool o);
00096     bool mocAware() const;
00097     void logicWarn(const QString &, const QString &);
00098 
00099     virtual bool doDepends() const { return Option::mkfile::do_deps; }
00100     bool writeHeader(QTextStream &);
00101     virtual bool writeMakefile(QTextStream &);
00102     virtual bool writeMakeQmake(QTextStream &);
00103     void initOutPaths();
00104     virtual void init();
00105 
00106     //for cross-platform dependent directories
00107     virtual void usePlatformDir();
00108 
00109     //for installs
00110     virtual QString defaultInstall(const QString &);
00111 
00112     //for prl
00113     bool processPrlFile(QString &);
00114     virtual void processPrlVariable(const QString &, const QStringList &);
00115     virtual void processPrlFiles();
00116     virtual void writePrlFile(QTextStream &);
00117 
00118     //make sure libraries are found
00119     virtual bool findLibraries();
00120     virtual QString findDependency(const QString &);
00121 
00122     void setProcessedDependencies(const QString &file, bool b);
00123     bool processedDependencies(const QString &file);
00124 
00125     virtual QString var(const QString &var);
00126     QString varGlue(const QString &var, const QString &before, const QString &glue, const QString &after);
00127     QString varList(const QString &var);
00128     QString val(const QStringList &varList);
00129     QString valGlue(const QStringList &varList, const QString &before, const QString &glue, const QString &after);
00130     QString valList(const QStringList &varList);
00131 
00132 
00133     QString fileFixify(const QString& file, const QString &out_dir=QString::null, 
00134                        const QString &in_dir=QString::null, bool force_fix=FALSE, bool canon=TRUE) const;
00135     QStringList fileFixify(const QStringList& files, const QString &out_dir=QString::null, 
00136                            const QString &in_dir=QString::null, bool force_fix=FALSE, bool canon=TRUE) const;
00137 public:
00138     MakefileGenerator(QMakeProject *p);
00139     virtual ~MakefileGenerator();
00140 
00141     static MakefileGenerator *create(QMakeProject *);
00142     virtual bool write();
00143     virtual bool openOutput(QFile &) const;
00144 };
00145 
00146 inline QString MakefileGenerator::findMocSource(const QString &moc_file) const
00147 {
00148     QString tmp = cleanFilePath(moc_file);
00149     if (mocablesFromMOC.contains(tmp))
00150         return mocablesFromMOC[tmp];
00151     else
00152         return QString("");
00153 }
00154 
00155 inline QString MakefileGenerator::findMocDestination(const QString &src_file) const
00156 {
00157     QString tmp = cleanFilePath(src_file);
00158     if (mocablesToMOC.contains(tmp))
00159         return mocablesToMOC[tmp];
00160     else
00161         return QString("");
00162 }
00163 
00164 inline void MakefileGenerator::setMocAware(bool o)
00165 { moc_aware = o; }
00166 
00167 inline bool MakefileGenerator::mocAware() const
00168 { return moc_aware; }
00169 
00170 inline void MakefileGenerator::setNoIO(bool o)
00171 { no_io = o; }
00172 
00173 inline bool MakefileGenerator::noIO() const
00174 { return no_io; }
00175 
00176 inline QString MakefileGenerator::defaultInstall(const QString &)
00177 { return QString(""); }
00178 
00179 inline bool MakefileGenerator::findLibraries()
00180 { return TRUE; }
00181 
00182 inline QString MakefileGenerator::findDependency(const QString &)
00183 { return QString(""); }
00184 
00185 inline MakefileGenerator::~MakefileGenerator()
00186 { }
00187 
00188 QString mkdir_p_asstring(const QString &dir);
00189 
00190 #endif /* __MAKEFILE_H__ */
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'