summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@nokia.com>2011-12-05 15:50:43 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-07 12:55:28 +0100
commit47df12225918ba82abe35921af19e547717da58b (patch)
tree425bd53e9094f66aa2d31a1159c14e5dacf657fb
parent7e66f6c207dca9f7402c4bfd27f43711c8befaac (diff)
qmake: Add object_parallel_to_source config option
This solves the problem of two source files in the same project having the same name, which ends up with colliding object files. It also solves issues with moving files around in the source tree when the GNUmake option is used together with gcc_MD_depends, where the dependency file would end up with a dependency to the old source location. We already have object_with_source option, but that does not play nicely with shadow-builds. The new option tries to keep the same hirarcy in the output dir (while still respecting OBJECTS_DIR), as the sources. Any source with a path outside of the root project directory (absolute or relative, ../../foo.cpp), will be put inside the objects directory with the full path appended. Change-Id: I0c96291974f4801f4c55a26485d512b15c144c00 Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
-rw-r--r--qmake/generators/makefile.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index 1d4e6cabf3..3ad240db01 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -1487,6 +1487,29 @@ MakefileGenerator::createObjectList(const QStringList &sources)
int dl = fName.lastIndexOf(Option::dir_sep);
if(dl != -1)
dir = fName.left(dl + 1);
+ } else if (project->isActiveConfig("object_parallel_to_source")) {
+ // The source paths are relative to the output dir, but we need source-relative paths
+ QString sourceRelativePath = fileFixify(*it, qmake_getpwd(), Option::output_dir);
+ sourceRelativePath = Option::fixPathToTargetOS(sourceRelativePath, false);
+
+ if (sourceRelativePath.startsWith(".." + Option::dir_sep))
+ sourceRelativePath = fileFixify(sourceRelativePath, FileFixifyAbsolute);
+
+ if (QDir::isAbsolutePath(sourceRelativePath))
+ sourceRelativePath.remove(0, sourceRelativePath.indexOf(Option::dir_sep) + 1);
+
+ dir = objdir; // We still respect OBJECTS_DIR
+
+ int lastDirSepPosition = sourceRelativePath.lastIndexOf(Option::dir_sep);
+ if (lastDirSepPosition != -1)
+ dir += sourceRelativePath.leftRef(lastDirSepPosition + 1);
+
+ if (!noIO()) {
+ // Ensure that the final output directory of each object exists
+ QString outRelativePath = fileFixify(dir, qmake_getpwd(), Option::output_dir);
+ if (!mkdir(outRelativePath))
+ warn_msg(WarnLogic, "Cannot create directory '%s'", outRelativePath.toLatin1().constData());
+ }
} else {
dir = objdir;
}