- enhancement: "Run" / "Generate Assembly" for project source files

This commit is contained in:
Roy Qu 2022-12-28 16:39:18 +08:00
parent bcb6069fe3
commit dd92cfa6da
2 changed files with 19 additions and 7 deletions

View File

@ -3,6 +3,7 @@ Red Panda C++ Version 2.8
- fix: Crash when editing makefile - fix: Crash when editing makefile
- enhancement: Add "Resources" in project option's dialog's custom compiler parameter page - enhancement: Add "Resources" in project option's dialog's custom compiler parameter page
- fix: Crash while input using input method in makefile - fix: Crash while input using input method in makefile
- enhancement: "Run" / "Generate Assembly" for project source files
Red Panda C++ Version 2.7 Red Panda C++ Version 2.7

View File

@ -669,11 +669,13 @@ void MainWindow::updateCompileActions(const Editor *e)
bool forProject=false; bool forProject=false;
bool canRun = false; bool canRun = false;
bool canCompile = false; bool canCompile = false;
bool canGenerateAssembly=false;
if (e) { if (e) {
if (!e->inProject()) { if (!e->inProject()) {
FileType fileType = getFileType(e->filename()); FileType fileType = getFileType(e->filename());
if (fileType == FileType::CSource if (fileType == FileType::CSource
|| fileType == FileType::CppSource || e->isNew()) { || fileType == FileType::CppSource || e->isNew()) {
canGenerateAssembly = true;
canCompile = true; canCompile = true;
canRun = true; canRun = true;
} }
@ -687,12 +689,19 @@ void MainWindow::updateCompileActions(const Editor *e)
canCompile = true; canCompile = true;
canRun = (mProject->options().type !=ProjectType::DynamicLib) canRun = (mProject->options().type !=ProjectType::DynamicLib)
&& (mProject->options().type !=ProjectType::StaticLib); && (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->setEnabled(canCompile);
ui->actionCompile_Run->setEnabled(canRun && canCompile); ui->actionCompile_Run->setEnabled(canRun && canCompile);
ui->actionRun->setEnabled(canRun); ui->actionRun->setEnabled(canRun);
ui->actionRebuild->setEnabled(canCompile); ui->actionRebuild->setEnabled(canCompile);
ui->actionGenerate_Assembly->setEnabled(canCompile && !forProject); ui->actionGenerate_Assembly->setEnabled(canGenerateAssembly);
ui->actionDebug->setEnabled(canRun); ui->actionDebug->setEnabled(canRun);
ui->btnRunAllProblemCases->setEnabled(canRun); ui->btnRunAllProblemCases->setEnabled(canRun);
} }
@ -1843,7 +1852,7 @@ bool MainWindow::compile(bool rebuild, CppCompileType compileType)
{ {
mCompilerManager->stopPausing(); mCompilerManager->stopPausing();
CompileTarget target =getCompileTarget(); CompileTarget target =getCompileTarget();
if (target == CompileTarget::Project) { if (target == CompileTarget::Project && compileType == CppCompileType::Normal) {
if (mProject->modified()) { if (mProject->modified()) {
mProject->saveAll(); mProject->saveAll();
} }
@ -1873,7 +1882,9 @@ bool MainWindow::compile(bool rebuild, CppCompileType compileType)
return false; return false;
} }
if (mCompileSuccessionTask) { 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) { if (compilerSet) {
Settings::CompilerSet::CompilationStage stage; Settings::CompilerSet::CompilationStage stage;
switch(compileType) { switch(compileType) {
@ -7586,13 +7597,13 @@ void MainWindow::doCompileRun(RunType runType)
void MainWindow::doGenerateAssembly() void MainWindow::doGenerateAssembly()
{ {
CompileTarget target =getCompileTarget(); CompileTarget target =getCompileTarget();
QStringList binDirs;
QString execName; QString execName;
if (target == CompileTarget::File) { if (target!= CompileTarget::File
binDirs = getDefaultCompilerSetBinDirs(); && target != CompileTarget::Project) {
return;
} }
mCompileSuccessionTask = std::make_shared<CompileSuccessionTask>(); mCompileSuccessionTask = std::make_shared<CompileSuccessionTask>();
mCompileSuccessionTask->binDirs=binDirs; //mCompileSuccessionTask->binDirs="";
mCompileSuccessionTask->type = CompileSuccessionTaskType::RunNormal; mCompileSuccessionTask->type = CompileSuccessionTaskType::RunNormal;
compile(false,CppCompileType::GenerateAssemblyOnly); compile(false,CppCompileType::GenerateAssemblyOnly);
} }