diff --git a/projectmanagers/custommake/makefileresolver/makefileresolver.cpp b/projectmanagers/custommake/makefileresolver/makefileresolver.cpp --- a/projectmanagers/custommake/makefileresolver/makefileresolver.cpp +++ b/projectmanagers/custommake/makefileresolver/makefileresolver.cpp @@ -79,174 +79,46 @@ static QMutex s_cacheMutex; } - ///Helper-class used to fake file-modification times - class FileModificationTimeWrapper - { - public: - ///@param files list of files that should be fake-modified(modtime will be set to current time) - explicit FileModificationTimeWrapper(const QStringList& files = QStringList(), const QString& workingDirectory = QString()) - : m_newTime(QDateTime::currentDateTime()) - { - for (QStringList::const_iterator it = files.constBegin(); it != files.constEnd(); ++it) { - ifTest(cout << "touching " << it->toUtf8().constData() << endl); - - QFileInfo fileinfo(QDir(workingDirectory), *it); - if (!fileinfo.exists()) { - cout << "File does not exist: " << it->toUtf8().constData() - << "in working dir " << QDir::currentPath().toUtf8().constData() << "\n"; - continue; - } - - const QString filename = fileinfo.canonicalFilePath(); - if (m_stat.contains(filename)) { - cout << "Duplicate file: " << filename.toUtf8().constData() << endl; - continue; - } - - QFileInfo info(filename); - if (info.exists()) { - ///Success - m_stat[filename] = info.lastModified(); - - ///change the modification-time to m_newTime - if (Helper::changeAccessAndModificationTime(filename, m_newTime, m_newTime) != 0) { - ifTest(cout << "failed to touch " << it->toUtf8().constData() << endl); - } - } - } - } - - ///Undo changed modification-times - void unModify() - { - for (auto it = m_stat.constBegin(); it != m_stat.constEnd(); ++it) { - ifTest(cout << "untouching " << it.key().toUtf8().constData() << endl); - - QFileInfo info(it.key()); - if (info.exists()) { - if (info.lastModified() == m_newTime) { - ///Still the modtime that we've set, change it back - if (Helper::changeAccessAndModificationTime(it.key(), info.lastRead(), *it) != 0) { - perror("Resetting modification time"); - ifTest(cout << "failed to untouch " << it.key().toUtf8().constData() << endl); - } - } else { - ///The file was modified since we changed the modtime - ifTest(cout << "will not untouch " << it.key().toUtf8().constData() << " because the modification-time has changed" << endl); - } - } else { - perror("File status"); - } - } - } - - ~FileModificationTimeWrapper() - { - unModify(); - } - - private: - QHash m_stat; - QDateTime m_newTime; - }; - /** * Compatibility: * make/automake: Should work perfectly * cmake: Thanks to the path-recursion, this works with cmake(tested with version "2.4-patch 6" * with kdelibs out-of-source and with kdevelop4 in-source) - * - * unsermake: - * unsermake is detected by reading the first line of the makefile. If it contains - * "generated by unsermake" the following things are respected: - * 1. Since unsermake does not have the -W command (which should tell it to recompile - * the given file no matter whether it has been changed or not), the file-modification-time of - * the file is changed temporarily and the --no-real-compare option is used to force recompilation. - * 2. The targets seem to be called *.lo instead of *.o when using unsermake, so *.lo names are used. - * example-(test)command: unsermake --no-real-compare -n myfile.lo **/ class SourcePathInformation { public: explicit SourcePathInformation(const QString& path) : m_path(path) - , m_isUnsermake(false) - , m_shouldTouchFiles(false) - { - m_isUnsermake = isUnsermakePrivate(path); - - ifTest(if (m_isUnsermake) cout << "unsermake detected" << endl); - } - - bool isUnsermake() const { - return m_isUnsermake; - } - - ///When this is set, the file-modification times are changed no matter whether it is unsermake or make - void setShouldTouchFiles(bool b) - { - m_shouldTouchFiles = b; } QString getCommand(const QString& absoluteFile, const QString& workingDirectory, const QString& makeParameters) const { - if (isUnsermake()) { - return "unsermake -k --no-real-compare -n " + makeParameters; - } else { - QString relativeFile = Path(workingDirectory).relativePath(Path(absoluteFile)); - return "make -k --no-print-directory -W \'" + absoluteFile + "\' -W \'" + relativeFile + "\' -n " + makeParameters; - } + QString relativeFile = Path(workingDirectory).relativePath(Path(absoluteFile)); + return "make -k --no-print-directory -W \'" + absoluteFile + "\' -W \'" + relativeFile + "\' -n " + makeParameters; } bool hasMakefile() const { QFileInfo makeFile(m_path, "Makefile"); return makeFile.exists(); } - bool shouldTouchFiles() const - { - return isUnsermake() || m_shouldTouchFiles; - } - QStringList possibleTargets(const QString& targetBaseName) const { QStringList ret; ///@todo open the make-file, and read the target-names from there. - if (isUnsermake()) { - //unsermake breaks if the first given target does not exist, so in worst-case 2 calls are necessary - ret << targetBaseName + ".lo"; - ret << targetBaseName + ".o"; - } else { - //It would be nice if both targets could be processed in one call, the problem is the exit-status of make, so for now make has to be called twice. - ret << targetBaseName + ".o"; - ret << targetBaseName + ".lo"; - //ret << targetBaseName + ".lo " + targetBaseName + ".o"; - } + //It would be nice if all targets could be processed in one call, the problem is the exit-status of make, so for now make has to be called multiple times. + ret << targetBaseName + ".o"; + ret << targetBaseName + ".lo"; + //ret << targetBaseName + ".lo " + targetBaseName + ".o"; ret << targetBaseName + ".ko"; return ret; } private: - bool isUnsermakePrivate(const QString& path) - { - bool ret = false; - QFileInfo makeFile(path, "Makefile"); - QFile f(makeFile.absoluteFilePath()); - if (f.open(QIODevice::ReadOnly)) { - QString firstLine = f.readLine(128); - if (firstLine.indexOf("generated by unsermake") != -1) { - ret = true; - } - f.close(); - } - return ret; - } - QString m_path; - bool m_isUnsermake; - bool m_shouldTouchFiles; }; static void mergePaths(KDevelop::Path::List& destList, const KDevelop::Path::List& srcList) @@ -483,8 +355,6 @@ SourcePathInformation source(wd); QStringList possibleTargets = source.possibleTargets(targetName); - source.setShouldTouchFiles(true); //Think about whether this should be always enabled. I've enabled it for now so there's an even bigger chance that everything works. - ///STEP 3: Try resolving the paths, by using once the absolute and once the relative file-path. Which kind is required differs from setup to setup. ///STEP 3.1: Try resolution using the absolute path @@ -559,13 +429,6 @@ QString processStdout; - QStringList touchFiles; - if (source.shouldTouchFiles()) { - touchFiles << file; - } - - FileModificationTimeWrapper touch(touchFiles, workingDirectory); - QString fullOutput; executeCommand(source.getCommand(file, workingDirectory, makeParameters), workingDirectory, fullOutput);