- enhancement: before run a project'executable, check if there's project file newer than the executable

This commit is contained in:
Roy Qu 2022-10-25 19:09:46 +08:00
parent 3f74a5fd10
commit 5edcad104e
5 changed files with 19 additions and 3 deletions

View File

@ -24,7 +24,8 @@ Red Panda C++ Version 2.0
- enhancement: when closing project, prevent all editors that belongs to the project check syntax and parse todos.
- enhancement: add "auto reformat when saving codes" in "Options" / "Editor" / "Misc" (off by default)
- enhancement: use "todo" and "fixme" as the keyword for TODO comments
- fix: rules for obj missed in makefile generated for project
- fix: rules for obj missing in the makefile generated for project
- enhancement: before run a project'executable, check if there's project file newer than the executable
Red Panda C++ Version 1.5

View File

@ -323,7 +323,7 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file)
if (mProject->options().usePrecompiledHeader)
precompileStr = " $(PCH) ";
QList<PProjectUnit> projectUnits;
QList<PProjectUnit> projectUnits=mProject->unitList();
foreach(const PProjectUnit &unit, projectUnits) {
FileType fileType = getFileType(unit->fileName());
// Only process source files

View File

@ -1880,7 +1880,9 @@ void MainWindow::runExecutable(RunType runType)
CompileTarget target =getCompileTarget();
if (target == CompileTarget::Project) {
QStringList binDirs = mProject->binDirs();
if (mProject->modified() &&
QFileInfo execInfo(mProject->executable());
QDateTime execModTime = execInfo.lastModified();
if (execInfo.exists() && mProject->unitsModifiedSince(execModTime) &&
QMessageBox::question(
this,
tr("Rebuild Project"),

View File

@ -156,6 +156,18 @@ QString Project::makeFileName()
return QDir(directory()).filePath(MAKEFILE_NAME);
}
bool Project::unitsModifiedSince(const QDateTime& time)
{
foreach(const PProjectUnit& unit, mUnits) {
QFileInfo info(unit->fileName());
if (info.lastModified()>time) {
qDebug()<<info.lastModified()<<time;
return true;
}
}
return false;
}
bool Project::modified() const
{
return mModified;

View File

@ -210,6 +210,7 @@ public:
QString directory() const;
QString executable() const;
QString makeFileName();
bool unitsModifiedSince(const QDateTime& time);
bool modified() const;
void setFileName(QString value);
void setModified(bool value);