2012-10-02 09:12:39 +02:00
/****************************************************************************
2010-09-27 15:51:49 +02:00
* *
2016-01-15 14:58:39 +01:00
* * Copyright ( C ) 2016 The Qt Company Ltd .
* * Contact : https : //www.qt.io/licensing/
2010-09-27 15:51:49 +02:00
* *
2012-10-02 09:12:39 +02:00
* * This file is part of Qt Creator .
2010-09-27 15:51:49 +02:00
* *
2012-10-02 09:12:39 +02:00
* * Commercial License Usage
* * Licensees holding valid commercial Qt licenses may use this file in
* * accordance with the commercial license agreement provided with the
* * Software or , alternatively , in accordance with the terms contained in
2016-01-15 14:58:39 +01:00
* * a written agreement between you and The Qt Company . For licensing terms
* * and conditions see https : //www.qt.io/terms-conditions. For further
* * information use the contact form at https : //www.qt.io/contact-us.
2010-09-27 15:51:49 +02:00
* *
2016-01-15 14:58:39 +01:00
* * GNU General Public License Usage
* * Alternatively , this file may be used under the terms of the GNU
* * General Public License version 3 as published by the Free Software
* * Foundation with exceptions as appearing in the file LICENSE . GPL3 - EXCEPT
* * included in the packaging of this file . Please review the following
* * information to ensure the GNU General Public License requirements will
* * be met : https : //www.gnu.org/licenses/gpl-3.0.html.
2010-12-17 16:01:08 +01:00
* *
2012-10-02 09:12:39 +02:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-09-27 15:51:49 +02:00
# include "buildablehelperlibrary.h"
2013-03-18 14:47:33 +01:00
# include "hostosinfo.h"
# include "synchronousprocess.h"
2010-09-27 15:51:49 +02:00
2012-02-15 10:42:41 +01:00
# include <QDateTime>
# include <QDebug>
2019-03-15 10:43:35 +01:00
# include <QDir>
2017-03-09 23:02:32 +01:00
# include <QRegExp>
2010-09-27 15:51:49 +02:00
2019-03-15 10:43:35 +01:00
# include <set>
2010-09-27 15:51:49 +02:00
namespace Utils {
2013-08-05 13:03:43 +02:00
bool BuildableHelperLibrary : : isQtChooser ( const QFileInfo & info )
{
return info . isSymLink ( ) & & info . symLinkTarget ( ) . endsWith ( QLatin1String ( " /qtchooser " ) ) ;
}
QString BuildableHelperLibrary : : qtChooserToQmakePath ( const QString & path )
{
2016-04-29 16:52:58 +02:00
const QString toolDir = QLatin1String ( " QTTOOLDIR= \" " ) ;
SynchronousProcess proc ;
proc . setTimeoutS ( 1 ) ;
2019-07-23 10:17:57 +02:00
SynchronousProcessResponse response = proc . runBlocking ( { path , { " -print-env " } } ) ;
2016-04-29 16:52:58 +02:00
if ( response . result ! = SynchronousProcessResponse : : Finished )
2013-08-05 13:03:43 +02:00
return QString ( ) ;
2016-07-05 12:00:59 +02:00
const QString output = response . stdOut ( ) ;
2013-10-10 10:39:36 +02:00
int pos = output . indexOf ( toolDir ) ;
2013-08-05 13:03:43 +02:00
if ( pos = = - 1 )
return QString ( ) ;
2016-12-31 20:34:38 -05:00
pos + = toolDir . count ( ) ;
2013-08-05 13:03:43 +02:00
int end = output . indexOf ( ' \" ' , pos ) ;
if ( end = = - 1 )
return QString ( ) ;
2016-04-29 16:52:58 +02:00
return output . mid ( pos , end - pos ) + QLatin1String ( " /qmake " ) ;
2013-08-05 13:03:43 +02:00
}
2014-10-30 15:54:25 +01:00
static bool isQmake ( const QString & path )
{
if ( path . isEmpty ( ) )
return false ;
QFileInfo fi ( path ) ;
if ( BuildableHelperLibrary : : isQtChooser ( fi ) )
fi . setFile ( BuildableHelperLibrary : : qtChooserToQmakePath ( fi . symLinkTarget ( ) ) ) ;
2018-02-05 13:21:04 +01:00
if ( ! fi . exists ( ) | | fi . isDir ( ) )
return false ;
2014-10-30 15:54:25 +01:00
return ! BuildableHelperLibrary : : qtVersionForQMake ( fi . absoluteFilePath ( ) ) . isEmpty ( ) ;
}
2019-05-28 13:49:26 +02:00
static FilePath findQmakeInDir ( const FilePath & path )
2010-09-27 15:51:49 +02:00
{
2019-03-15 10:43:35 +01:00
if ( path . isEmpty ( ) )
2019-05-28 13:49:26 +02:00
return FilePath ( ) ;
2014-10-30 15:54:25 +01:00
2019-10-21 22:56:09 +03:00
const QString qmake = HostOsInfo : : withExecutableSuffix ( " qmake " ) ;
2019-03-15 10:43:35 +01:00
QDir dir ( path . toString ( ) ) ;
if ( dir . exists ( qmake ) ) {
const QString qmakePath = dir . absoluteFilePath ( qmake ) ;
if ( isQmake ( qmakePath ) )
2019-05-28 13:49:26 +02:00
return FilePath : : fromString ( qmakePath ) ;
2019-03-15 10:43:35 +01:00
}
2014-10-30 15:54:25 +01:00
2019-03-15 10:43:35 +01:00
// Prefer qmake-qt5 to qmake-qt4 by sorting the filenames in reverse order.
const QFileInfoList candidates = dir . entryInfoList (
BuildableHelperLibrary : : possibleQMakeCommands ( ) ,
QDir : : Files , QDir : : Name | QDir : : Reversed ) ;
for ( const QFileInfo & fi : candidates ) {
if ( fi . fileName ( ) = = qmake )
continue ;
if ( isQmake ( fi . absoluteFilePath ( ) ) )
2019-05-28 13:49:26 +02:00
return FilePath : : fromFileInfo ( fi ) ;
2019-03-15 10:43:35 +01:00
}
2019-05-28 13:49:26 +02:00
return FilePath ( ) ;
2019-03-15 10:43:35 +01:00
}
2014-10-30 15:54:25 +01:00
2019-05-28 13:49:26 +02:00
FilePath BuildableHelperLibrary : : findSystemQt ( const Environment & env )
2019-03-15 10:43:35 +01:00
{
2019-05-28 13:49:26 +02:00
const FilePathList list = findQtsInEnvironment ( env , 1 ) ;
return list . size ( ) = = 1 ? list . first ( ) : FilePath ( ) ;
2019-03-15 10:43:35 +01:00
}
2013-08-05 13:03:43 +02:00
2019-05-28 13:49:26 +02:00
FilePathList BuildableHelperLibrary : : findQtsInEnvironment ( const Environment & env , int maxCount )
2019-03-15 10:43:35 +01:00
{
2019-05-28 13:49:26 +02:00
FilePathList qmakeList ;
2019-03-15 10:43:35 +01:00
std : : set < QString > canonicalEnvPaths ;
2019-05-28 13:49:26 +02:00
const FilePathList paths = env . path ( ) ;
for ( const FilePath & path : paths ) {
2019-03-15 10:43:35 +01:00
if ( ! canonicalEnvPaths . insert ( path . toFileInfo ( ) . canonicalFilePath ( ) ) . second )
continue ;
2019-05-28 13:49:26 +02:00
const FilePath qmake = findQmakeInDir ( path ) ;
2019-03-15 10:43:35 +01:00
if ( qmake . isEmpty ( ) )
continue ;
qmakeList < < qmake ;
if ( maxCount ! = - 1 & & qmakeList . size ( ) = = maxCount )
break ;
2010-09-27 15:51:49 +02:00
}
2019-03-15 10:43:35 +01:00
return qmakeList ;
2010-09-27 15:51:49 +02:00
}
QString BuildableHelperLibrary : : qtVersionForQMake ( const QString & qmakePath )
{
2014-10-30 15:56:01 +01:00
if ( qmakePath . isEmpty ( ) )
2010-09-27 15:51:49 +02:00
return QString ( ) ;
2016-04-29 16:52:58 +02:00
SynchronousProcess qmake ;
qmake . setTimeoutS ( 5 ) ;
2019-07-23 10:17:57 +02:00
SynchronousProcessResponse response = qmake . runBlocking ( { qmakePath , { " --version " } } ) ;
2016-04-29 16:52:58 +02:00
if ( response . result ! = SynchronousProcessResponse : : Finished ) {
qWarning ( ) < < response . exitMessage ( qmakePath , 5 ) ;
2010-09-27 15:51:49 +02:00
return QString ( ) ;
}
2011-07-14 13:35:40 +02:00
2016-04-29 16:52:58 +02:00
const QString output = response . allOutput ( ) ;
2010-11-08 09:41:40 +01:00
static QRegExp regexp ( QLatin1String ( " (QMake version|QMake version:)[ \\ s]*([ \\ d.]*) " ) ,
Qt : : CaseInsensitive ) ;
2010-09-27 15:51:49 +02:00
regexp . indexIn ( output ) ;
2012-09-25 15:07:36 +02:00
const QString qmakeVersion = regexp . cap ( 2 ) ;
if ( qmakeVersion . startsWith ( QLatin1String ( " 2. " ) )
| | qmakeVersion . startsWith ( QLatin1String ( " 3. " ) ) ) {
2010-11-08 09:41:40 +01:00
static QRegExp regexp2 ( QLatin1String ( " Using Qt version[ \\ s]*([ \\ d \\ .]*) " ) ,
Qt : : CaseInsensitive ) ;
2010-09-27 15:51:49 +02:00
regexp2 . indexIn ( output ) ;
const QString version = regexp2 . cap ( 1 ) ;
return version ;
}
return QString ( ) ;
}
2015-03-31 18:53:42 +02:00
QString BuildableHelperLibrary : : filterForQmakeFileDialog ( )
{
QString filter = QLatin1String ( " qmake ( " ) ;
const QStringList commands = possibleQMakeCommands ( ) ;
for ( int i = 0 ; i < commands . size ( ) ; + + i ) {
if ( i )
filter + = QLatin1Char ( ' ' ) ;
if ( HostOsInfo : : isMacHost ( ) )
// work around QTBUG-7739 that prohibits filters that don't start with *
filter + = QLatin1Char ( ' * ' ) ;
filter + = commands . at ( i ) ;
if ( HostOsInfo : : isAnyUnixHost ( ) & & ! HostOsInfo : : isMacHost ( ) )
// kde bug, we need at least one wildcard character
// see QTCREATORBUG-7771
filter + = QLatin1Char ( ' * ' ) ;
}
filter + = QLatin1Char ( ' ) ' ) ;
return filter ;
}
2010-09-27 15:51:49 +02:00
QStringList BuildableHelperLibrary : : possibleQMakeCommands ( )
{
2014-10-17 13:53:46 +02:00
// On Windows it is always "qmake.exe"
// On Unix some distributions renamed qmake with a postfix to avoid clashes
// On OS X, Qt 4 binary packages also has renamed qmake. There are also symbolic links that are
// named "qmake", but the file dialog always checks against resolved links (native Cocoa issue)
2018-02-06 15:37:53 +01:00
return QStringList ( HostOsInfo : : withExecutableSuffix ( " qmake* " ) ) ;
2010-09-27 15:51:49 +02:00
}
// Copy helper source files to a target directory, replacing older files.
bool BuildableHelperLibrary : : copyFiles ( const QString & sourcePath ,
const QStringList & files ,
const QString & targetDirectory ,
QString * errorMessage )
{
2011-07-20 13:47:04 +02:00
// try remove the directory
2019-05-28 13:49:26 +02:00
if ( ! FileUtils : : removeRecursively ( FilePath : : fromString ( targetDirectory ) , errorMessage ) )
2011-07-20 13:47:04 +02:00
return false ;
2010-09-27 15:51:49 +02:00
if ( ! QDir ( ) . mkpath ( targetDirectory ) ) {
* errorMessage = QCoreApplication : : translate ( " ProjectExplorer::DebuggingHelperLibrary " , " The target directory %1 could not be created. " ) . arg ( targetDirectory ) ;
return false ;
}
foreach ( const QString & file , files ) {
const QString source = sourcePath + file ;
const QString dest = targetDirectory + file ;
const QFileInfo destInfo ( dest ) ;
if ( destInfo . exists ( ) ) {
if ( destInfo . lastModified ( ) > = QFileInfo ( source ) . lastModified ( ) )
continue ;
if ( ! QFile : : remove ( dest ) ) {
* errorMessage = QCoreApplication : : translate ( " ProjectExplorer::DebuggingHelperLibrary " , " The existing file %1 could not be removed. " ) . arg ( destInfo . absoluteFilePath ( ) ) ;
return false ;
}
}
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
if ( ! destInfo . dir ( ) . exists ( ) )
2010-12-10 13:09:28 +01:00
QDir ( ) . mkpath ( destInfo . dir ( ) . absolutePath ( ) ) ;
2010-09-27 15:51:49 +02:00
if ( ! QFile : : copy ( source , dest ) ) {
* errorMessage = QCoreApplication : : translate ( " ProjectExplorer::DebuggingHelperLibrary " , " The file %1 could not be copied to %2. " ) . arg ( source , dest ) ;
return false ;
}
}
return true ;
}
2010-10-08 15:13:02 +02:00
// Helper: Run a build process with merged stdout/stderr
static inline bool runBuildProcessI ( QProcess & proc ,
2019-05-28 13:49:26 +02:00
const FilePath & binary ,
2010-10-08 15:13:02 +02:00
const QStringList & args ,
2015-04-14 22:30:46 +03:00
int timeoutS ,
2010-10-08 15:13:02 +02:00
bool ignoreNonNullExitCode ,
QString * output , QString * errorMessage )
{
2014-07-15 23:32:11 +03:00
proc . start ( binary . toString ( ) , args ) ;
2010-10-08 15:13:02 +02:00
if ( ! proc . waitForStarted ( ) ) {
* errorMessage = QCoreApplication : : translate ( " ProjectExplorer::BuildableHelperLibrary " ,
" Cannot start process: %1 " ) .
arg ( proc . errorString ( ) ) ;
return false ;
}
// Read stdout/err and check for timeouts
QByteArray stdOut ;
QByteArray stdErr ;
2015-04-14 22:30:46 +03:00
if ( ! SynchronousProcess : : readDataFromProcess ( proc , timeoutS , & stdOut , & stdErr , false ) ) {
2010-10-08 15:13:02 +02:00
* errorMessage = QCoreApplication : : translate ( " ProjectExplorer::BuildableHelperLibrary " ,
2015-04-14 22:30:46 +03:00
" Timeout after %1 s. " ) .
arg ( timeoutS ) ;
2010-10-08 15:13:02 +02:00
SynchronousProcess : : stopProcess ( proc ) ;
return false ;
}
if ( proc . exitStatus ( ) ! = QProcess : : NormalExit ) {
* errorMessage = QCoreApplication : : translate ( " ProjectExplorer::BuildableHelperLibrary " ,
" The process crashed. " ) ;
return false ;
}
const QString stdOutS = QString : : fromLocal8Bit ( stdOut ) ;
if ( ! ignoreNonNullExitCode & & proc . exitCode ( ) ! = 0 ) {
* errorMessage = QCoreApplication : : translate ( " ProjectExplorer::BuildableHelperLibrary " ,
" The process returned exit code %1: \n %2 " ) .
arg ( proc . exitCode ( ) ) . arg ( stdOutS ) ;
return false ;
}
output - > append ( stdOutS ) ;
return true ;
}
// Run a build process with merged stdout/stderr and qWarn about errors.
static bool runBuildProcess ( QProcess & proc ,
2019-05-28 13:49:26 +02:00
const FilePath & binary ,
2010-10-08 15:13:02 +02:00
const QStringList & args ,
2015-04-14 22:30:46 +03:00
int timeoutS ,
2010-10-08 15:13:02 +02:00
bool ignoreNonNullExitCode ,
QString * output , QString * errorMessage )
{
2015-04-14 22:30:46 +03:00
const bool rc = runBuildProcessI ( proc , binary , args , timeoutS , ignoreNonNullExitCode , output , errorMessage ) ;
2010-10-08 15:13:02 +02:00
if ( ! rc ) {
// Fail - reformat error.
2014-07-15 23:32:11 +03:00
QString cmd = binary . toString ( ) ;
2010-10-08 15:13:02 +02:00
if ( ! args . isEmpty ( ) ) {
cmd + = QLatin1Char ( ' ' ) ;
2014-08-23 01:19:53 +02:00
cmd + = args . join ( QLatin1Char ( ' ' ) ) ;
2010-10-08 15:13:02 +02:00
}
* errorMessage =
QCoreApplication : : translate ( " ProjectExplorer::BuildableHelperLibrary " ,
2014-04-17 14:09:47 +02:00
" Error running \" %1 \" in %2: %3 " ) .
2010-10-08 15:13:02 +02:00
arg ( cmd , proc . workingDirectory ( ) , * errorMessage ) ;
qWarning ( " %s " , qPrintable ( * errorMessage ) ) ;
}
return rc ;
}
2011-04-29 13:35:19 +02:00
bool BuildableHelperLibrary : : buildHelper ( const BuildHelperArguments & arguments ,
QString * log , QString * errorMessage )
2010-09-27 15:51:49 +02:00
{
const QChar newline = QLatin1Char ( ' \n ' ) ;
// Setup process
QProcess proc ;
2011-04-29 13:35:19 +02:00
proc . setEnvironment ( arguments . environment . toStringList ( ) ) ;
proc . setWorkingDirectory ( arguments . directory ) ;
2010-09-27 15:51:49 +02:00
proc . setProcessChannelMode ( QProcess : : MergedChannels ) ;
2011-04-29 13:35:19 +02:00
log - > append ( QCoreApplication : : translate ( " ProjectExplorer::BuildableHelperLibrary " ,
2014-04-17 14:09:47 +02:00
" Building helper \" %1 \" in %2 \n " ) . arg ( arguments . helperName ,
2011-04-29 13:35:19 +02:00
arguments . directory ) ) ;
log - > append ( newline ) ;
2010-09-27 15:51:49 +02:00
2019-05-28 13:49:26 +02:00
const FilePath makeFullPath = arguments . environment . searchInPath ( arguments . makeCommand ) ;
2014-10-24 10:28:28 +02:00
if ( QFileInfo : : exists ( arguments . directory + QLatin1String ( " /Makefile " ) ) ) {
2010-10-08 15:13:02 +02:00
if ( makeFullPath . isEmpty ( ) ) {
* errorMessage = QCoreApplication : : translate ( " ProjectExplorer::DebuggingHelperLibrary " ,
2011-04-29 13:35:19 +02:00
" %1 not found in PATH \n " ) . arg ( arguments . makeCommand ) ;
2010-10-08 15:13:02 +02:00
return false ;
2010-09-27 15:51:49 +02:00
}
2010-10-08 15:13:02 +02:00
const QString cleanTarget = QLatin1String ( " distclean " ) ;
2011-04-29 13:35:19 +02:00
log - > append ( QCoreApplication : : translate ( " ProjectExplorer::BuildableHelperLibrary " ,
2014-07-15 23:32:11 +03:00
" Running %1 %2... \n " )
. arg ( makeFullPath . toUserOutput ( ) , cleanTarget ) ) ;
2015-04-14 22:30:46 +03:00
if ( ! runBuildProcess ( proc , makeFullPath , QStringList ( cleanTarget ) , 30 , true , log , errorMessage ) )
2010-10-08 15:13:02 +02:00
return false ;
2010-09-27 15:51:49 +02:00
}
2011-01-12 16:24:00 +01:00
QStringList qmakeArgs ;
2011-04-29 13:35:19 +02:00
if ( ! arguments . targetMode . isEmpty ( ) )
qmakeArgs < < arguments . targetMode ;
if ( ! arguments . mkspec . isEmpty ( ) )
2011-11-25 13:19:58 +01:00
qmakeArgs < < QLatin1String ( " -spec " ) < < arguments . mkspec . toUserOutput ( ) ;
2011-04-29 13:35:19 +02:00
qmakeArgs < < arguments . proFilename ;
qmakeArgs < < arguments . qmakeArguments ;
2011-02-10 15:24:49 +01:00
2011-04-29 13:35:19 +02:00
log - > append ( newline ) ;
log - > append ( QCoreApplication : : translate ( " ProjectExplorer::BuildableHelperLibrary " ,
2011-11-25 13:19:58 +01:00
" Running %1 %2 ... \n " ) . arg ( arguments . qmakeCommand . toUserOutput ( ) ,
2014-08-23 01:19:53 +02:00
qmakeArgs . join ( QLatin1Char ( ' ' ) ) ) ) ;
2011-02-10 15:24:49 +01:00
2015-04-14 22:30:46 +03:00
if ( ! runBuildProcess ( proc , arguments . qmakeCommand , qmakeArgs , 30 , false , log , errorMessage ) )
2010-10-08 15:13:02 +02:00
return false ;
2011-04-29 13:35:19 +02:00
log - > append ( newline ) ;
2010-10-08 15:13:02 +02:00
if ( makeFullPath . isEmpty ( ) ) {
2011-04-29 13:35:19 +02:00
* errorMessage = QCoreApplication : : translate ( " ProjectExplorer::BuildableHelperLibrary " ,
" %1 not found in PATH \n " ) . arg ( arguments . makeCommand ) ;
2010-10-08 15:13:02 +02:00
return false ;
2010-09-27 15:51:49 +02:00
}
2011-04-29 13:35:19 +02:00
log - > append ( QCoreApplication : : translate ( " ProjectExplorer::BuildableHelperLibrary " ,
2014-07-15 23:32:11 +03:00
" Running %1 %2 ... \n " )
2014-08-23 01:19:53 +02:00
. arg ( makeFullPath . toUserOutput ( ) , arguments . makeArguments . join ( QLatin1Char ( ' ' ) ) ) ) ;
2019-10-31 15:56:20 +01:00
return runBuildProcess ( proc , makeFullPath , arguments . makeArguments , 120 , false , log , errorMessage ) ;
2010-09-27 15:51:49 +02:00
}
bool BuildableHelperLibrary : : getHelperFileInfoFor ( const QStringList & validBinaryFilenames ,
const QString & directory , QFileInfo * info )
{
if ( ! info )
return false ;
2012-11-28 20:44:03 +02:00
foreach ( const QString & binaryFilename , validBinaryFilenames ) {
2010-09-27 15:51:49 +02:00
info - > setFile ( directory + binaryFilename ) ;
if ( info - > exists ( ) )
return true ;
}
return false ;
}
2011-02-18 14:43:33 +01:00
QString BuildableHelperLibrary : : byInstallDataHelper ( const QString & sourcePath ,
const QStringList & sourceFileNames ,
2010-09-27 15:51:49 +02:00
const QStringList & installDirectories ,
2011-04-18 14:13:18 +02:00
const QStringList & validBinaryFilenames ,
bool acceptOutdatedHelper )
2010-09-27 15:51:49 +02:00
{
2011-02-18 14:43:33 +01:00
// find the latest change to the sources
QDateTime sourcesModified ;
2011-04-18 14:13:18 +02:00
if ( ! acceptOutdatedHelper ) {
foreach ( const QString & sourceFileName , sourceFileNames ) {
const QDateTime fileModified = QFileInfo ( sourcePath + sourceFileName ) . lastModified ( ) ;
if ( fileModified . isValid ( ) & & ( ! sourcesModified . isValid ( ) | | fileModified > sourcesModified ) )
sourcesModified = fileModified ;
}
2011-02-18 14:43:33 +01:00
}
2011-06-28 18:00:38 +02:00
// We pretend that the lastmodified of dumper.cpp is 5 minutes before what
// the file system says because afer a installation from the package the
// modified dates of dumper.cpp and the actual library are close to each
// other, but not deterministic in one direction.
2011-04-18 14:13:18 +02:00
if ( sourcesModified . isValid ( ) )
sourcesModified = sourcesModified . addSecs ( - 300 ) ;
2010-09-27 15:51:49 +02:00
// look for the newest helper library in the different locations
QString newestHelper ;
QDateTime newestHelperModified = sourcesModified ; // prevent using one that's older than the sources
QFileInfo fileInfo ;
2012-11-28 20:44:03 +02:00
foreach ( const QString & installDirectory , installDirectories ) {
2010-09-27 15:51:49 +02:00
if ( getHelperFileInfoFor ( validBinaryFilenames , installDirectory , & fileInfo ) ) {
2011-04-18 14:13:18 +02:00
if ( ! newestHelperModified . isValid ( )
| | ( fileInfo . lastModified ( ) > newestHelperModified ) ) {
2010-09-27 15:51:49 +02:00
newestHelper = fileInfo . filePath ( ) ;
newestHelperModified = fileInfo . lastModified ( ) ;
}
}
}
return newestHelper ;
}
} // namespace Utils