summaryrefslogtreecommitdiffstats
path: root/qmake
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2012-12-11 16:46:55 +0100
committerTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-02-26 13:13:24 +0100
commitdd5b437d6a9b509466021c9484cc396bbdf0f1a4 (patch)
treedd27f762321946028bb2c321c0bebfa5a4756d5b /qmake
parentf6d13a45c88d94a7b616450efe1adb0a231a92c7 (diff)
qmake: Fix file paths in Xcode projects when shadow-building
The Xcode generator seems to have been written with the assumption that writeMakeParts() would be called with the output directory as the current directory, but that's not the case when shadow-building. Perhaps this was changed in qmake at some point, and the Xcode generator was not updated to reflect that. Instead of replacing every occurance of fileFixify and other logic to deal with paths, we just chdir into the output_dir for the duration of the function (except when writing the 'make qmake' makefile, as the regular makefile generator works as expected with the current directory set to the input directory). Change-Id: I6ba492036d73f29f4adbd7cd554db9504050629e Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'qmake')
-rw-r--r--qmake/generators/mac/pbuilder_pbx.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp
index 4710f7e939..41af3d2a53 100644
--- a/qmake/generators/mac/pbuilder_pbx.cpp
+++ b/qmake/generators/mac/pbuilder_pbx.cpp
@@ -453,7 +453,6 @@ ProjectBuilderSources::files(QMakeProject *project) const
{
QStringList ret = project->values(ProKey(key)).toQStringList();
if(key == "QMAKE_INTERNAL_INCLUDED_FILES") {
- ret.prepend(project->projectFile());
for(int i = 0; i < ret.size(); ++i) {
QStringList newret;
if(!ret.at(i).endsWith(Option::prf_ext))
@@ -500,6 +499,14 @@ static QString xcodeFiletypeForFilename(const QString &filename)
bool
ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
{
+ // The code in this function assumes that the current directory matches
+ // the output directory, which is not actually the case when we are called
+ // from the generic generator code. Instead of changing every single
+ // assumption and fileFixify we cheat by moving into the output directory
+ // for the duration of this function.
+ QString input_dir = qmake_getpwd();
+ qmake_setpwd(Option::output_dir);
+
ProStringList tmp;
bool did_preprocess = false;
@@ -521,6 +528,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
QFile mkf(mkfile);
if(mkf.open(QIODevice::WriteOnly | QIODevice::Text)) {
writingUnixMakefileGenerator = true;
+ qmake_setpwd(input_dir); // Makefile generation assumes input_dir as pwd
debug_msg(1, "pbuilder: Creating file: %s", mkfile.toLatin1().constData());
QTextStream mkt(&mkf);
writeHeader(mkt);
@@ -529,6 +537,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
mkt.flush();
mkf.close();
writingUnixMakefileGenerator = false;
+ qmake_setpwd(Option::output_dir);
}
QString phase_key = keyFor("QMAKE_PBX_MAKEQMAKE_BUILDPHASE");
mkfile = fileFixify(mkfile, qmake_getpwd());
@@ -544,6 +553,10 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
<< "\t\t" << "};" << "\n";
}
+ // FIXME: Move all file resolving logic out of ProjectBuilderSources::files(), as it
+ // doesn't have access to any of the information it needs to resolve relative paths.
+ project->values("QMAKE_INTERNAL_INCLUDED_FILES").prepend(fileFixify(project->projectFile(), qmake_getpwd(), input_dir));
+
//DUMP SOURCES
QMap<QString, ProStringList> groups;
QList<ProjectBuilderSources> sources;
@@ -1463,6 +1476,9 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
writingUnixMakefileGenerator = false;
}
}
+
+ qmake_setpwd(input_dir);
+
return true;
}
@@ -1676,10 +1692,9 @@ ProjectBuilderMakefileGenerator::reftypeForFile(const QString &where)
QString ProjectBuilderMakefileGenerator::sourceTreeForFile(const QString &where)
{
- QString ret = "<absolute>";
- if (QDir::isRelativePath(unescapeFilePath(where)))
- ret = "SOURCE_ROOT"; //relative
- return ret;
+ // We always use absolute paths, instead of maintaining the SRCROOT
+ // build variable and making files relative to that.
+ return QLatin1String("<absolute>");
}
QString