Commit e236c5de authored by Christian Kamm's avatar Christian Kamm
Browse files

Compiled helpers: Use only ones that are newer than all source files.

Reviewed-by: Kai Koehne
parent 3593fe08
......@@ -322,11 +322,19 @@ bool BuildableHelperLibrary::getHelperFileInfoFor(const QStringList &validBinary
return false;
}
QString BuildableHelperLibrary::byInstallDataHelper(const QString &mainFilename,
QString BuildableHelperLibrary::byInstallDataHelper(const QString &sourcePath,
const QStringList &sourceFileNames,
const QStringList &installDirectories,
const QStringList &validBinaryFilenames)
{
QDateTime sourcesModified = QFileInfo(mainFilename).lastModified();
// find the latest change to the sources
QDateTime sourcesModified;
foreach (const QString &sourceFileName, sourceFileNames) {
const QDateTime fileModified = QFileInfo(sourcePath + sourceFileName).lastModified();
if (fileModified.isValid() && (!sourcesModified.isValid() || fileModified > sourcesModified))
sourcesModified = fileModified;
}
// We pretend that the lastmodified of gdbmacros.cpp is 5 minutes before what the file system says
// Because afer a installation from the package the modified dates of gdbmacros.cpp
// and the actual library are close to each other, but not deterministic in one direction
......
......@@ -59,7 +59,8 @@ public:
static QString qtInstallHeadersDir(const QString &qmakePath);
static QString qtInstallDataDir(const QString &qmakePath);
static QString byInstallDataHelper(const QString &mainFilename,
static QString byInstallDataHelper(const QString &sourcePath,
const QStringList &sourceFileNames,
const QStringList &installDirectories,
const QStringList &validBinaryFilenames);
......
......@@ -81,17 +81,28 @@ QStringList DebuggingHelperLibrary::locationsByInstallData(const QString &qtInst
return result;
}
static QString sourcePath()
{
return Core::ICore::instance()->resourcePath() + QLatin1String("/gdbmacros/");
}
static QStringList sourceFileNames()
{
return QStringList()
<< QLatin1String("gdbmacros.cpp") << QLatin1String("gdbmacros_p.h")
<< QLatin1String("gdbmacros.h") << QLatin1String("gdbmacros.pro")
<< QLatin1String("LICENSE.LGPL") << QLatin1String("LGPL_EXCEPTION.TXT");
}
QString DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(const QString &qtInstallData)
{
if (!Core::ICore::instance())
return QString();
const QString mainFilename = Core::ICore::instance()->resourcePath()
+ QLatin1String("/gdbmacros/gdbmacros.cpp");
const QStringList directories = DebuggingHelperLibrary::debuggingHelperLibraryDirectories(qtInstallData);
const QStringList binFilenames = validBinaryFilenames();
return byInstallDataHelper(mainFilename, directories, binFilenames);
return byInstallDataHelper(sourcePath(), sourceFileNames(), directories, binFilenames);
}
QString DebuggingHelperLibrary::copy(const QString &qtInstallData,
......@@ -103,16 +114,9 @@ QString DebuggingHelperLibrary::copy(const QString &qtInstallData,
// $USERDIR/qtc-debugging-helper/$hash
const QStringList directories = DebuggingHelperLibrary::debuggingHelperLibraryDirectories(qtInstallData);
QStringList files;
files << QLatin1String("gdbmacros.cpp") << QLatin1String("gdbmacros_p.h")
<< QLatin1String("gdbmacros.h") << QLatin1String("gdbmacros.pro")
<< QLatin1String("LICENSE.LGPL") << QLatin1String("LGPL_EXCEPTION.TXT");
QString sourcePath = Core::ICore::instance()->resourcePath() + QLatin1String("/gdbmacros/");
// Try to find a writeable directory.
foreach(const QString &directory, directories)
if (copyFiles(sourcePath, files, directory, errorMessage)) {
if (copyFiles(sourcePath(), sourceFileNames(), directory, errorMessage)) {
errorMessage->clear();
return directory;
}
......
......@@ -52,8 +52,6 @@ QString QmlDebuggingLibrary::libraryByInstallData(const QString &qtInstallData,
if (!Core::ICore::instance())
return QString();
const QString mainFilename = Core::ICore::instance()->resourcePath()
+ QLatin1String("/qml/qmljsdebugger/qmljsdebugger.pro");
const QStringList directories = installDirectories(qtInstallData);
QStringList binFilenames;
......@@ -65,7 +63,7 @@ QString QmlDebuggingLibrary::libraryByInstallData(const QString &qtInstallData,
}
binFilenames << QLatin1String("libqmljsdebugger.a");
return byInstallDataHelper(mainFilename, directories, binFilenames);
return byInstallDataHelper(sourcePath(), sourceFileNames(), directories, binFilenames);
}
bool QmlDebuggingLibrary::canBuild(const QtVersion *qtVersion)
......@@ -97,10 +95,6 @@ QString QmlDebuggingLibrary::copy(const QString &qtInstallData, QString *errorMe
{
const QStringList directories = QmlDebuggingLibrary::installDirectories(qtInstallData);
QString sourcePath = Core::ICore::instance()->resourcePath() + QLatin1String("/qml/qmljsdebugger/");
QStringList qmljsDebuggerFiles = recursiveFileList(QDir(sourcePath));
// Try to find a writeable directory.
foreach (const QString &directory, directories) {
if (!mkpath(directory, errorMessage)) {
......@@ -109,7 +103,7 @@ QString QmlDebuggingLibrary::copy(const QString &qtInstallData, QString *errorMe
errorMessage->clear();
}
if (copyFiles(sourcePath, qmljsDebuggerFiles,
if (copyFiles(sourcePath(), sourceFileNames(),
directory, errorMessage))
{
errorMessage->clear();
......@@ -152,5 +146,14 @@ QStringList QmlDebuggingLibrary::installDirectories(const QString &qtInstallData
return directories;
}
QString QmlDebuggingLibrary::sourcePath()
{
return Core::ICore::instance()->resourcePath() + QLatin1String("/qml/qmljsdebugger/");
}
QStringList QmlDebuggingLibrary::sourceFileNames()
{
return recursiveFileList(QDir(sourcePath()));
}
} // namespace
......@@ -66,7 +66,8 @@ public:
private:
static QStringList recursiveFileList(const QDir &dir, const QString &prefix = QString());
static QStringList installDirectories(const QString &qtInstallData);
static QString sourcePath();
static QStringList sourceFileNames();
};
} // namespace
......
......@@ -228,6 +228,21 @@ QString QmlDumpTool::toolForProject(ProjectExplorer::Project *project, bool debu
return QString();
}
static QString sourcePath()
{
return Core::ICore::instance()->resourcePath() + QLatin1String("/qml/qmldump/");
}
static QStringList sourceFileNames()
{
QStringList files;
files << QLatin1String("main.cpp") << QLatin1String("qmldump.pro")
<< QLatin1String("qmlstreamwriter.cpp") << QLatin1String("qmlstreamwriter.h")
<< QLatin1String("LICENSE.LGPL") << QLatin1String("LGPL_EXCEPTION.TXT")
<< QLatin1String("Info.plist");
return files;
}
QString QmlDumpTool::toolByInstallData(const QString &qtInstallData, bool debugDump)
{
if (!Core::ICore::instance())
......@@ -238,7 +253,7 @@ QString QmlDumpTool::toolByInstallData(const QString &qtInstallData, bool debugD
const QStringList directories = installDirectories(qtInstallData);
const QStringList binFilenames = validBinaryFilenames(debugDump);
return byInstallDataHelper(mainFilename, directories, binFilenames);
return byInstallDataHelper(sourcePath(), sourceFileNames(), directories, binFilenames);
}
QStringList QmlDumpTool::locationsByInstallData(const QString &qtInstallData, bool debugDump)
......@@ -267,17 +282,9 @@ QString QmlDumpTool::copy(const QString &qtInstallData, QString *errorMessage)
{
const QStringList directories = QmlDumpTool::installDirectories(qtInstallData);
QStringList files;
files << QLatin1String("main.cpp") << QLatin1String("qmldump.pro")
<< QLatin1String("qmlstreamwriter.cpp") << QLatin1String("qmlstreamwriter.h")
<< QLatin1String("LICENSE.LGPL") << QLatin1String("LGPL_EXCEPTION.TXT")
<< QLatin1String("Info.plist");
QString sourcePath = Core::ICore::instance()->resourcePath() + QLatin1String("/qml/qmldump/");
// Try to find a writeable directory.
foreach(const QString &directory, directories) {
if (copyFiles(sourcePath, files, directory, errorMessage)) {
if (copyFiles(sourcePath(), sourceFileNames(), directory, errorMessage)) {
return directory;
}
}
......
......@@ -84,12 +84,10 @@ QString QmlObserverTool::toolByInstallData(const QString &qtInstallData)
if (!Core::ICore::instance())
return QString();
const QString mainFilename = Core::ICore::instance()->resourcePath()
+ QLatin1String("/qml/qmlobserver/main.cpp");
const QStringList directories = installDirectories(qtInstallData);
const QStringList binFilenames = validBinaryFilenames();
return byInstallDataHelper(mainFilename, directories, binFilenames);
return byInstallDataHelper(sourcePath(), sourceFileNames(), directories, binFilenames);
}
QStringList QmlObserverTool::locationsByInstallData(const QString &qtInstallData)
......@@ -129,10 +127,6 @@ QString QmlObserverTool::copy(const QString &qtInstallData, QString *errorMessag
{
const QStringList directories = QmlObserverTool::installDirectories(qtInstallData);
QString sourcePath = Core::ICore::instance()->resourcePath() + QLatin1String("/qml/qmlobserver/");
QStringList observerFiles = recursiveFileList(QDir(sourcePath));
// Try to find a writeable directory.
foreach(const QString &directory, directories) {
if (!mkpath(directory, errorMessage)) {
......@@ -141,7 +135,7 @@ QString QmlObserverTool::copy(const QString &qtInstallData, QString *errorMessag
errorMessage->clear();
}
if (copyFiles(sourcePath, observerFiles, directory, errorMessage)) {
if (copyFiles(sourcePath(), sourceFileNames(), directory, errorMessage)) {
errorMessage->clear();
return directory;
}
......@@ -182,4 +176,14 @@ QStringList QmlObserverTool::installDirectories(const QString &qtInstallData)
return directories;
}
QString QmlObserverTool::sourcePath()
{
return Core::ICore::instance()->resourcePath() + QLatin1String("/qml/qmlobserver/");
}
QStringList QmlObserverTool::sourceFileNames()
{
return recursiveFileList(QDir(sourcePath()));
}
} // namespace
......@@ -71,7 +71,8 @@ public:
private:
static QStringList recursiveFileList(const QDir &dir, const QString &prefix = QString());
static QStringList installDirectories(const QString &qtInstallData);
static QString sourcePath();
static QStringList sourceFileNames();
};
} // namespace
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment