- fix: can't build project that has source files in subfolders

- fix: can't build project that has custom object folder
  - fix: buttons in the project option dialog's output page don't work
This commit is contained in:
Roy Qu 2022-04-08 22:14:18 +08:00
parent 93d16ab9e4
commit 39a0f87b94
4 changed files with 48 additions and 19 deletions

View File

@ -13,6 +13,9 @@ Red Panda C++ Version 1.0.3
- enhancement: don't show folders that doesn't contain files in the project view - enhancement: don't show folders that doesn't contain files in the project view
- enhancement: redesigned new project unit dialog - enhancement: redesigned new project unit dialog
- fix: some dialog's icon not correctly set - fix: some dialog's icon not correctly set
- fix: can't build project that has source files in subfolders
- fix: can't build project that has custom object folder
- fix: buttons in the project option dialog's output page don't work
Red Panda C++ Version 1.0.2 Red Panda C++ Version 1.0.2
- enhancement: press tab in column mode won't exit column mode - enhancement: press tab in column mode won't exit column mode

View File

@ -157,14 +157,21 @@ void ProjectCompiler::writeMakeDefines(QFile &file)
QString relativeObjFile = extractRelativePath(mProject->directory(), changeFileExt(fullObjFile, OBJ_EXT)); QString relativeObjFile = extractRelativePath(mProject->directory(), changeFileExt(fullObjFile, OBJ_EXT));
QString ObjFile = genMakePath2(relativeObjFile); QString ObjFile = genMakePath2(relativeObjFile);
Objects += ' ' + ObjFile; Objects += ' ' + ObjFile;
#ifdef Q_OS_WIN
cleanObjects += ' ' + genMakePath1(relativeObjFile).replace("/",QDir::separator());
#else
cleanObjects += ' ' + genMakePath1(relativeObjFile); cleanObjects += ' ' + genMakePath1(relativeObjFile);
#endif
if (unit->link()) { if (unit->link()) {
LinkObjects += ' ' + genMakePath1(relativeObjFile); LinkObjects += ' ' + genMakePath1(relativeObjFile);
} }
} else { } else {
Objects += ' ' + genMakePath2(changeFileExt(RelativeName, OBJ_EXT)); Objects += ' ' + genMakePath2(changeFileExt(RelativeName, OBJ_EXT));
#ifdef Q_OS_WIN
cleanObjects += ' ' + genMakePath1(changeFileExt(RelativeName, OBJ_EXT)).replace("/",QDir::separator());
#else
cleanObjects += ' ' + genMakePath1(changeFileExt(RelativeName, OBJ_EXT)); cleanObjects += ' ' + genMakePath1(changeFileExt(RelativeName, OBJ_EXT));
#endif
if (unit->link()) if (unit->link())
LinkObjects = LinkObjects + ' ' + genMakePath1(changeFileExt(RelativeName, OBJ_EXT)); LinkObjects = LinkObjects + ' ' + genMakePath1(changeFileExt(RelativeName, OBJ_EXT));
} }
@ -213,11 +220,25 @@ void ProjectCompiler::writeMakeDefines(QFile &file)
writeln(file,"RES = " + genMakePath1(ObjResFile)); writeln(file,"RES = " + genMakePath1(ObjResFile));
writeln(file,"OBJ = " + Objects + " $(RES)"); writeln(file,"OBJ = " + Objects + " $(RES)");
writeln(file,"LINKOBJ = " + LinkObjects + " $(RES)"); writeln(file,"LINKOBJ = " + LinkObjects + " $(RES)");
writeln(file,"CLEANOBJ = " + cleanObjects + " $(RES)"); #ifdef Q_OS_WIN
writeln(file,"CLEANOBJ = " + cleanObjects +
" " + genMakePath1(ObjResFile).replace("/",QDir::separator())
+ " " + genMakePath1(extractRelativePath(mProject->makeFileName(), mProject->executable())).replace("/",QDir::separator()) );
#else
writeln(file,"CLEANOBJ = " + cleanObjects +
" " + genMakePath1(ObjResFile)
+ " " + genMakePath1(extractRelativePath(mProject->makeFileName(), mProject->executable())));
#endif
} else { } else {
writeln(file,"OBJ = " + Objects); writeln(file,"OBJ = " + Objects);
writeln(file,"LINKOBJ = " + LinkObjects); writeln(file,"LINKOBJ = " + LinkObjects);
writeln(file,"CLEANOBJ = " + cleanObjects); #ifdef Q_OS_WIN
writeln(file,"CLEANOBJ = " + cleanObjects +
+ " " + genMakePath1(extractRelativePath(mProject->makeFileName(), mProject->executable())).replace("/",QDir::separator()) );
#else
writeln(file,"CLEANOBJ = " + cleanObjects +
+ " " + genMakePath1(extractRelativePath(mProject->makeFileName(), mProject->executable())));
#endif
}; };
libraryArguments.replace('\\', '/'); libraryArguments.replace('\\', '/');
writeln(file,"LIBS = " + libraryArguments); writeln(file,"LIBS = " + libraryArguments);
@ -249,7 +270,13 @@ void ProjectCompiler::writeMakeDefines(QFile &file)
libOutputFile = extractRelativePath(mProject->makeFileName(), libOutputFile); libOutputFile = extractRelativePath(mProject->makeFileName(), libOutputFile);
writeln(file,"DEF = " + genMakePath1(changeFileExt(libOutputFile, DEF_EXT))); writeln(file,"DEF = " + genMakePath1(changeFileExt(libOutputFile, DEF_EXT)));
writeln(file,"STATIC = " + genMakePath1(changeFileExt(libOutputFile, LIB_EXT))); writeln(file,"STATIC = " + genMakePath1(changeFileExt(libOutputFile, LIB_EXT)));
#ifdef Q_OS_WIN
writeln(file,"CLEAN_DEF = " + genMakePath1(changeFileExt(libOutputFile, DEF_EXT)).replace("/",QDir::separator()));
writeln(file,"CLEAN_STATIC = " + genMakePath1(changeFileExt(libOutputFile, LIB_EXT)).replace("/",QDir::separator()));
#else
writeln(file,"CLEAN_DEF = " + genMakePath1(changeFileExt(libOutputFile, DEF_EXT)));
writeln(file,"CLEAN_STATIC = " + genMakePath1(changeFileExt(libOutputFile, LIB_EXT)));
#endif
} }
writeln(file); writeln(file);
} }
@ -284,9 +311,9 @@ void ProjectCompiler::writeMakeClean(QFile &file)
{ {
writeln(file, "clean: clean-custom"); writeln(file, "clean: clean-custom");
if (mProject->options().type == ProjectType::DynamicLib) if (mProject->options().type == ProjectType::DynamicLib)
writeln(file, QString("\t${RM} $(CLEANOBJ) $(BIN) $(DEF) $(STATIC) > %1 2>&1").arg(NULL_FILE)); writeln(file, QString("\t${RM} $(CLEANOBJ) $(CLEAN_DEF) $(CLEAN_STATIC) > %1 2>&1").arg(NULL_FILE));
else else
writeln(file, QString("\t${RM} $(CLEANOBJ) $(BIN) > %1 2>&1").arg(NULL_FILE)); writeln(file, QString("\t${RM} $(CLEANOBJ) > %1 2>&1").arg(NULL_FILE));
writeln(file); writeln(file);
} }
@ -333,9 +360,9 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file)
extractFileName(unit->fileName()); extractFileName(unit->fileName());
ObjFileName = genMakePath2(extractRelativePath(mProject->makeFileName(), changeFileExt(ObjFileName, OBJ_EXT))); ObjFileName = genMakePath2(extractRelativePath(mProject->makeFileName(), changeFileExt(ObjFileName, OBJ_EXT)));
ObjFileName2 = genMakePath1(extractRelativePath(mProject->makeFileName(), changeFileExt(ObjFileName, OBJ_EXT))); ObjFileName2 = genMakePath1(extractRelativePath(mProject->makeFileName(), changeFileExt(ObjFileName, OBJ_EXT)));
if (!extractFileDir(ObjFileName).isEmpty()) { // if (!extractFileDir(ObjFileName).isEmpty()) {
objStr = genMakePath2(includeTrailingPathDelimiter(extractFileDir(ObjFileName))) + objStr; // objStr = genMakePath2(includeTrailingPathDelimiter(extractFileDir(ObjFileName))) + objStr;
} // }
} else { } else {
ObjFileName = genMakePath2(changeFileExt(shortFileName, OBJ_EXT)); ObjFileName = genMakePath2(changeFileExt(shortFileName, OBJ_EXT));
ObjFileName2 = genMakePath1(changeFileExt(shortFileName, OBJ_EXT)); ObjFileName2 = genMakePath1(changeFileExt(shortFileName, OBJ_EXT));

View File

@ -57,29 +57,29 @@ void ProjectOutputWidget::doSave()
pMainWindow->project()->saveOptions(); pMainWindow->project()->saveOptions();
} }
void ProjectOutputWidget::on_btnOutputDir_triggered(QAction *) void ProjectOutputWidget::on_btnOutputDir_clicked()
{ {
QString dirName = QFileDialog::getExistingDirectory( QString dirName = QFileDialog::getExistingDirectory(
this, this,
tr("Executable output directory"), tr("Executable output directory"),
pMainWindow->project()->directory()); pMainWindow->project()->directory());
if (!dirName.isEmpty()) if (!dirName.isEmpty())
ui->txtOutputDir->setText(dirName); ui->txtOutputDir->setText(extractRelativePath(pMainWindow->project()->folder(),dirName));
} }
void ProjectOutputWidget::on_btnObjOutputDir_triggered(QAction *) void ProjectOutputWidget::on_btnObjOutputDir_clicked()
{ {
QString dirName = QFileDialog::getExistingDirectory( QString dirName = QFileDialog::getExistingDirectory(
this, this,
tr("Object files output directory"), tr("Object files output directory"),
pMainWindow->project()->directory()); pMainWindow->project()->directory());
if (!dirName.isEmpty()) if (!dirName.isEmpty())
ui->txtObjOutputDir->setText(dirName); ui->txtObjOutputDir->setText(extractRelativePath(pMainWindow->project()->folder(),dirName));
} }
void ProjectOutputWidget::on_btnCompileLog_triggered(QAction *) void ProjectOutputWidget::on_btnCompileLog_clicked()
{ {
QString fileName = QFileDialog::getOpenFileName( QString fileName = QFileDialog::getOpenFileName(
this, this,
@ -87,7 +87,7 @@ void ProjectOutputWidget::on_btnCompileLog_triggered(QAction *)
pMainWindow->project()->directory(), pMainWindow->project()->directory(),
tr("All files (%1)").arg(ALL_FILE_WILDCARD)); tr("All files (%1)").arg(ALL_FILE_WILDCARD));
if (!fileName.isEmpty() ) { if (!fileName.isEmpty() ) {
ui->txtCompileLog->setText(fileName); ui->txtCompileLog->setText(extractRelativePath(pMainWindow->project()->folder(),fileName));
} }
} }

View File

@ -40,11 +40,10 @@ protected:
void doLoad() override; void doLoad() override;
void doSave() override; void doSave() override;
private slots: private slots:
void on_btnOutputDir_triggered(QAction *arg1); void on_btnOutputDir_clicked();
void on_btnObjOutputDir_triggered(QAction *arg1); void on_btnObjOutputDir_clicked();
void on_btnCompileLog_triggered(QAction *arg1); void on_btnCompileLog_clicked();
// SettingsWidget interface
protected: protected:
void updateIcons(const QSize &size) override; void updateIcons(const QSize &size) override;
}; };