summaryrefslogtreecommitdiff
path: root/qmake/generators/projectgenerator.cpp
Side-by-side diff
Diffstat (limited to 'qmake/generators/projectgenerator.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/generators/projectgenerator.cpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/qmake/generators/projectgenerator.cpp b/qmake/generators/projectgenerator.cpp
index 1515216..1c17379 100644
--- a/qmake/generators/projectgenerator.cpp
+++ b/qmake/generators/projectgenerator.cpp
@@ -1,22 +1,20 @@
/****************************************************************************
-** $Id$
+**
**
-** Definition of ________ class.
+** Implementation of ProjectGenerator class.
**
-** Created : 970521
+** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
**
-** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
-**
-** This file is part of the network module of the Qt GUI Toolkit.
+** 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
@@ -148,44 +146,48 @@ ProjectGenerator::init()
}
if(add_depend && !dir.isEmpty() && !v["DEPENDPATH"].contains(dir)) {
QFileInfo fi(dir);
if(fi.absFilePath() != QDir::currentDirPath())
v["DEPENDPATH"] += fileFixify(dir);
}
}
}
if(!file_count) { //shall we try a subdir?
QStringList dirs = Option::projfile::project_dirs;
if(Option::projfile::do_pwd)
dirs.prepend(".");
+ const QString out_file = fileFixify(Option::output.name());
for(QStringList::Iterator pd = dirs.begin(); pd != dirs.end(); pd++) {
if(QFile::exists((*pd))) {
QString newdir = (*pd);
QFileInfo fi(newdir);
if(fi.isDir()) {
newdir = fileFixify(newdir);
QStringList &subdirs = v["SUBDIRS"];
if(QFile::exists(fi.filePath() + QDir::separator() + fi.fileName() + ".pro") &&
!subdirs.contains(newdir)) {
subdirs.append(newdir);
} else {
QDir d(newdir, "*.pro");
d.setFilter(QDir::Files);
for(int i = 0; i < (int)d.count(); i++) {
- QString nd = newdir + QDir::separator() + d[i];
+ QString nd = newdir;
+ if(nd == ".")
+ nd = "";
+ else if(!nd.isEmpty() && !nd.endsWith(QString(QChar(QDir::separator()))))
+ nd += QDir::separator();
+ nd += d[i];
fileFixify(nd);
- if(d[i] != "." && d[i] != ".." && !subdirs.contains(nd)) {
- if(newdir + d[i] != Option::output_dir + Option::output.name())
- subdirs.append(nd);
- }
+ if(d[i] != "." && d[i] != ".." && !subdirs.contains(nd) && !out_file.endsWith(nd))
+ subdirs.append(nd);
}
}
if(Option::projfile::do_recursive) {
QDir d(newdir);
d.setFilter(QDir::Dirs);
for(int i = 0; i < (int)d.count(); i++) {
QString nd = fileFixify(newdir + QDir::separator() + d[i]);
if(d[i] != "." && d[i] != ".." && !dirs.contains(nd))
dirs.append(nd);
}
}
}
@@ -315,25 +317,25 @@ ProjectGenerator::init()
for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ) {
bool found = FALSE;
for(QStringList::Iterator ui_it = u.begin(); ui_it != u.end(); ++ui_it) {
QString s1 = (*val_it).right((*val_it).length() - ((*val_it).findRev(Option::dir_sep) + 1));
if(s1.findRev('.') != -1)
s1 = s1.left(s1.findRev('.')) + Option::ui_ext;
QString u1 = (*ui_it).right((*ui_it).length() - ((*ui_it).findRev(Option::dir_sep) + 1));
if(s1 == u1) {
found = TRUE;
break;
}
}
- if(!found && (*val_it).endsWith(Option::moc_ext))
+ if(!found && (*val_it).endsWith(Option::cpp_moc_ext))
found = TRUE;
if(found)
val_it = l.remove(val_it);
else
++val_it;
}
}
}
}
bool
@@ -382,25 +384,25 @@ ProjectGenerator::addConfig(const QString &cfg, bool add)
return FALSE;
}
bool
ProjectGenerator::addFile(QString file)
{
file = fileFixify(file, QDir::currentDirPath());
QString dir;
int s = file.findRev(Option::dir_sep);
if(s != -1)
dir = file.left(s+1);
- if(file.mid(dir.length(), Option::moc_mod.length()) == Option::moc_mod)
+ if(file.mid(dir.length(), Option::h_moc_mod.length()) == Option::h_moc_mod)
return FALSE;
QString where;
for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) {
if(file.endsWith((*cppit))) {
if(QFile::exists(file.left(file.length() - (*cppit).length()) + Option::ui_ext))
return FALSE;
else
where = "SOURCES";
break;
}
}
@@ -426,48 +428,52 @@ ProjectGenerator::addFile(QString file)
}
QString newfile = fileFixify(file);
if(!where.isEmpty() && !project->variables()[where].contains(file)) {
project->variables()[where] += newfile;
return TRUE;
}
return FALSE;
}
QString
-ProjectGenerator::getWritableVar(const QString &v, bool /*fixPath*/)
+ProjectGenerator::getWritableVar(const QString &v, bool fixPath)
{
QStringList &vals = project->variables()[v];
if(vals.isEmpty())
return "";
QString ret;
if(v.endsWith("_REMOVE"))
ret = v.left(v.length() - 7) + " -= ";
else if(v.endsWith("_ASSIGN"))
ret = v.left(v.length() - 7) + " = ";
else
ret = v + " += ";
QString join = vals.join(" ");
if(ret.length() + join.length() > 80) {
QString spaces;
for(unsigned int i = 0; i < ret.length(); i++)
spaces += " ";
join = vals.join(" \\\n" + spaces);
}
+#if 0
// ### Commented out for now so that project generation works.
- // Sam: can you look at why this was needed?
- /* if(fixPath)
- join = join.replace("\\", "/");*/
+ // Sam: it had to do with trailing \'s (ie considered continuation lines)
+ if(fixPath)
+ join = join.replace("\\", "/");
+#else
+ Q_UNUSED(fixPath);
+#endif
return ret + join + "\n";
}
bool
ProjectGenerator::openOutput(QFile &file) const
{
QString outdir;
if(!file.name().isEmpty()) {
QFileInfo fi(file);
if(fi.isDir())
outdir = fi.dirPath() + QDir::separator();
}