summaryrefslogtreecommitdiffstats
path: root/tools/configure/environment.cpp
diff options
context:
space:
mode:
authorDavid Boddie <david.boddie@nokia.com>2011-02-23 17:38:46 (GMT)
committerDavid Boddie <david.boddie@nokia.com>2011-02-23 17:38:46 (GMT)
commit4501731349406110ecde2d260a8ab1e1bcedf179 (patch)
tree5ec176e26bbd207741ca40a1704e654c30fb8571 /tools/configure/environment.cpp
parent3c982b5d214cc7a37ace1d956ac8fb0b9a281722 (diff)
parent0442b383dced6b5cc31e4fc2bf939e3125354f82 (diff)
downloadQt-4501731349406110ecde2d260a8ab1e1bcedf179.zip
Qt-4501731349406110ecde2d260a8ab1e1bcedf179.tar.gz
Qt-4501731349406110ecde2d260a8ab1e1bcedf179.tar.bz2
Merge commit 'refs/merge-requests/1108' of git://gitorious.org/qt/qt into merge-requests/1108
Conflicts: doc/src/declarative/basictypes.qdoc
Diffstat (limited to 'tools/configure/environment.cpp')
-rw-r--r--tools/configure/environment.cpp61
1 files changed, 57 insertions, 4 deletions
diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp
index 05fd567..9d1c23a 100644
--- a/tools/configure/environment.cpp
+++ b/tools/configure/environment.cpp
@@ -407,10 +407,25 @@ int Environment::execute(QStringList arguments, const QStringList &additionalEnv
return exitCode;
}
-bool Environment::cpdir(const QString &srcDir, const QString &destDir)
+/*!
+ Copies the \a srcDir contents into \a destDir.
+
+ If \a includeSrcDir is not empty, any files with 'h', 'prf', or 'conf' suffixes
+ will not be copied over from \a srcDir. Instead a new file will be created
+ in \a destDir with the same name and that file will include a file with the
+ same name from the \a includeSrcDir using relative path and appropriate
+ syntax for the file type.
+
+ Returns true if copying was successful.
+*/
+bool Environment::cpdir(const QString &srcDir,
+ const QString &destDir,
+ const QString &includeSrcDir)
{
QString cleanSrcName = QDir::cleanPath(srcDir);
QString cleanDstName = QDir::cleanPath(destDir);
+ QString cleanIncludeName = QDir::cleanPath(includeSrcDir);
+
#ifdef CONFIGURE_DEBUG_CP_DIR
qDebug() << "Attempt to cpdir " << cleanSrcName << "->" << cleanDstName;
#endif
@@ -421,21 +436,59 @@ bool Environment::cpdir(const QString &srcDir, const QString &destDir)
bool result = true;
QDir dir = QDir(cleanSrcName);
+ QDir destinationDir = QDir(cleanDstName);
QFileInfoList allEntries = dir.entryInfoList(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
for (int i = 0; result && (i < allEntries.count()); ++i) {
QFileInfo entry = allEntries.at(i);
bool intermediate = true;
if (entry.isDir()) {
+ QString newIncSrcDir;
+ if (!includeSrcDir.isEmpty())
+ newIncSrcDir = QString("%1/%2").arg(cleanIncludeName).arg(entry.fileName());
+
intermediate = cpdir(QString("%1/%2").arg(cleanSrcName).arg(entry.fileName()),
- QString("%1/%2").arg(cleanDstName).arg(entry.fileName()));
+ QString("%1/%2").arg(cleanDstName).arg(entry.fileName()),
+ newIncSrcDir);
} else {
QString destFile = QString("%1/%2").arg(cleanDstName).arg(entry.fileName());
#ifdef CONFIGURE_DEBUG_CP_DIR
qDebug() << "About to cp (file)" << entry.absoluteFilePath() << "->" << destFile;
#endif
QFile::remove(destFile);
- intermediate = QFile::copy(entry.absoluteFilePath(), destFile);
- SetFileAttributes((wchar_t*)destFile.utf16(), FILE_ATTRIBUTE_NORMAL);
+ QString suffix = entry.suffix();
+ if (!includeSrcDir.isEmpty() && (suffix == "prf" || suffix == "conf" || suffix == "h")) {
+ QString relativeIncludeFilePath = QString("%1/%2").arg(cleanIncludeName).arg(entry.fileName());
+ relativeIncludeFilePath = destinationDir.relativeFilePath(relativeIncludeFilePath);
+#ifdef CONFIGURE_DEBUG_CP_DIR
+ qDebug() << "...instead generate relative include to" << relativeIncludeFilePath;
+#endif
+ QFile currentFile(destFile);
+ if (currentFile.open(QFile::WriteOnly | QFile::Text)) {
+ QTextStream fileStream;
+ fileStream.setDevice(&currentFile);
+
+ if (suffix == "prf" || suffix == "conf") {
+ if (entry.fileName() == "qmake.conf") {
+ // While QMAKESPEC_ORIGINAL being relative or absolute doesn't matter for the
+ // primary use of this variable by qmake to identify the original mkspec, the
+ // variable is also used for few special cases where the absolute path is required.
+ // Conversely, the include of the original qmake.conf must be done using relative path,
+ // as some Qt binary deployments are done in a manner that doesn't allow for patching
+ // the paths at the installation time.
+ fileStream << "QMAKESPEC_ORIGINAL=" << cleanSrcName << endl << endl;
+ }
+ fileStream << "include(" << relativeIncludeFilePath << ")" << endl << endl;
+ } else if (suffix == "h") {
+ fileStream << "#include \"" << relativeIncludeFilePath << "\"" << endl << endl;
+ }
+
+ fileStream.flush();
+ currentFile.close();
+ }
+ } else {
+ intermediate = QFile::copy(entry.absoluteFilePath(), destFile);
+ SetFileAttributes((wchar_t*)destFile.utf16(), FILE_ATTRIBUTE_NORMAL);
+ }
}
if(!intermediate) {
qDebug() << "cpdir: Failure for " << entry.fileName() << entry.isDir();