From dd92cfa6dadfacd86b7922b047aa88c7c515dc62 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 28 Dec 2022 16:39:18 +0800 Subject: [PATCH] - enhancement: "Run" / "Generate Assembly" for project source files --- NEWS.md | 1 + RedPandaIDE/mainwindow.cpp | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/NEWS.md b/NEWS.md index 1e8ce5f9..fb06224d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,7 @@ Red Panda C++ Version 2.8 - fix: Crash when editing makefile - enhancement: Add "Resources" in project option's dialog's custom compiler parameter page - fix: Crash while input using input method in makefile + - enhancement: "Run" / "Generate Assembly" for project source files Red Panda C++ Version 2.7 diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index fdbcb31f..8ad38c54 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -669,11 +669,13 @@ void MainWindow::updateCompileActions(const Editor *e) bool forProject=false; bool canRun = false; bool canCompile = false; + bool canGenerateAssembly=false; if (e) { if (!e->inProject()) { FileType fileType = getFileType(e->filename()); if (fileType == FileType::CSource || fileType == FileType::CppSource || e->isNew()) { + canGenerateAssembly = true; canCompile = true; canRun = true; } @@ -687,12 +689,19 @@ void MainWindow::updateCompileActions(const Editor *e) canCompile = true; canRun = (mProject->options().type !=ProjectType::DynamicLib) && (mProject->options().type !=ProjectType::StaticLib); + if (e) { + FileType fileType = getFileType(e->filename()); + if (fileType == FileType::CSource + || fileType == FileType::CppSource) { + canGenerateAssembly = true; + } + } } ui->actionCompile->setEnabled(canCompile); ui->actionCompile_Run->setEnabled(canRun && canCompile); ui->actionRun->setEnabled(canRun); ui->actionRebuild->setEnabled(canCompile); - ui->actionGenerate_Assembly->setEnabled(canCompile && !forProject); + ui->actionGenerate_Assembly->setEnabled(canGenerateAssembly); ui->actionDebug->setEnabled(canRun); ui->btnRunAllProblemCases->setEnabled(canRun); } @@ -1843,7 +1852,7 @@ bool MainWindow::compile(bool rebuild, CppCompileType compileType) { mCompilerManager->stopPausing(); CompileTarget target =getCompileTarget(); - if (target == CompileTarget::Project) { + if (target == CompileTarget::Project && compileType == CppCompileType::Normal) { if (mProject->modified()) { mProject->saveAll(); } @@ -1873,7 +1882,9 @@ bool MainWindow::compile(bool rebuild, CppCompileType compileType) return false; } if (mCompileSuccessionTask) { - Settings::PCompilerSet compilerSet =pSettings->compilerSets().defaultSet(); + Settings::PCompilerSet compilerSet=pSettings->compilerSets().defaultSet(); + if (editor->inProject()) + compilerSet = pSettings->compilerSets().getSet(mProject->options().compilerSet); if (compilerSet) { Settings::CompilerSet::CompilationStage stage; switch(compileType) { @@ -7586,13 +7597,13 @@ void MainWindow::doCompileRun(RunType runType) void MainWindow::doGenerateAssembly() { CompileTarget target =getCompileTarget(); - QStringList binDirs; QString execName; - if (target == CompileTarget::File) { - binDirs = getDefaultCompilerSetBinDirs(); + if (target!= CompileTarget::File + && target != CompileTarget::Project) { + return; } mCompileSuccessionTask = std::make_shared(); - mCompileSuccessionTask->binDirs=binDirs; + //mCompileSuccessionTask->binDirs=""; mCompileSuccessionTask->type = CompileSuccessionTaskType::RunNormal; compile(false,CppCompileType::GenerateAssemblyOnly); }