mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
ccmake: Display output during configure and generate
This commit is contained in:
@@ -136,7 +136,6 @@ void cmCursesLongMessageForm::Render(int /*left*/, int /*top*/, int /*width*/,
|
||||
form_driver(this->Form, REQ_BEG_FIELD);
|
||||
|
||||
this->UpdateStatusBar();
|
||||
this->PrintKeys();
|
||||
touchwin(stdscr);
|
||||
refresh();
|
||||
}
|
||||
@@ -150,6 +149,7 @@ void cmCursesLongMessageForm::HandleInput()
|
||||
char debugMessage[128];
|
||||
|
||||
for (;;) {
|
||||
this->PrintKeys();
|
||||
int key = getch();
|
||||
|
||||
sprintf(debugMessage, "Message widget handling input, key: %d", key);
|
||||
@@ -170,7 +170,16 @@ void cmCursesLongMessageForm::HandleInput()
|
||||
}
|
||||
|
||||
this->UpdateStatusBar();
|
||||
this->PrintKeys();
|
||||
touchwin(stdscr);
|
||||
wrefresh(stdscr);
|
||||
}
|
||||
}
|
||||
|
||||
void cmCursesLongMessageForm::ScrollDown()
|
||||
{
|
||||
if (this->Form) {
|
||||
form_driver(this->Form, REQ_END_FIELD);
|
||||
this->UpdateStatusBar();
|
||||
touchwin(stdscr);
|
||||
wrefresh(stdscr);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,10 @@ public:
|
||||
// Handle user input.
|
||||
void HandleInput() override;
|
||||
|
||||
// Description:
|
||||
// Scroll down to the end of the content
|
||||
void ScrollDown();
|
||||
|
||||
// Description:
|
||||
// Display form. Use a window of size width x height, starting
|
||||
// at top, left.
|
||||
|
||||
@@ -474,20 +474,17 @@ void cmCursesMainForm::UpdateProgress(const std::string& msg, float prog)
|
||||
constexpr int progressBarWidth = 40;
|
||||
int progressBarCompleted = static_cast<int>(progressBarWidth * prog);
|
||||
int percentCompleted = static_cast<int>(100 * prog);
|
||||
std::string status = (percentCompleted < 100 ? " " : "");
|
||||
status += (percentCompleted < 10 ? " " : "");
|
||||
status += std::to_string(percentCompleted) + "% [";
|
||||
status.append(progressBarCompleted, '#');
|
||||
status.append(progressBarWidth - progressBarCompleted, ' ');
|
||||
status += "] " + msg + "...";
|
||||
this->UpdateStatusBar(status.c_str());
|
||||
this->LastProgress = (percentCompleted < 100 ? " " : "");
|
||||
this->LastProgress += (percentCompleted < 10 ? " " : "");
|
||||
this->LastProgress += std::to_string(percentCompleted) + "% [";
|
||||
this->LastProgress.append(progressBarCompleted, '#');
|
||||
this->LastProgress.append(progressBarWidth - progressBarCompleted, ' ');
|
||||
this->LastProgress += "] " + msg + "...";
|
||||
} else {
|
||||
this->Outputs.emplace_back(msg);
|
||||
}
|
||||
this->PrintKeys(1);
|
||||
curses_move(1, 1);
|
||||
touchwin(stdscr);
|
||||
refresh();
|
||||
|
||||
this->DisplayOutputs();
|
||||
}
|
||||
|
||||
int cmCursesMainForm::Configure(int noconfigure)
|
||||
@@ -496,11 +493,15 @@ int cmCursesMainForm::Configure(int noconfigure)
|
||||
int yi;
|
||||
getmaxyx(stdscr, yi, xi);
|
||||
|
||||
this->UpdateProgress("Configuring", 0);
|
||||
this->CMakeInstance->SetProgressCallback(
|
||||
[this](const std::string& msg, float prog) {
|
||||
this->UpdateProgress(msg, prog);
|
||||
});
|
||||
this->ResetOutputs();
|
||||
|
||||
if (noconfigure == 0) {
|
||||
this->UpdateProgress("Configuring", 0);
|
||||
this->CMakeInstance->SetProgressCallback(
|
||||
[this](const std::string& msg, float prog) {
|
||||
this->UpdateProgress(msg, prog);
|
||||
});
|
||||
}
|
||||
|
||||
// always save the current gui values to disk
|
||||
this->FillCacheManagerFromUI();
|
||||
@@ -508,8 +509,6 @@ int cmCursesMainForm::Configure(int noconfigure)
|
||||
this->CMakeInstance->GetHomeOutputDirectory());
|
||||
this->LoadCache(nullptr);
|
||||
|
||||
this->ResetOutputs();
|
||||
|
||||
// run the generate process
|
||||
this->OkToGenerate = true;
|
||||
int retVal;
|
||||
@@ -544,6 +543,7 @@ int cmCursesMainForm::Configure(int noconfigure)
|
||||
cmSystemTools::ResetErrorOccuredFlag();
|
||||
CurrentForm = msgs;
|
||||
msgs->Render(1, 1, xx, yy);
|
||||
msgs->ScrollDown();
|
||||
msgs->HandleInput();
|
||||
// If they typed the wrong source directory, we report
|
||||
// an error and exit
|
||||
@@ -566,14 +566,14 @@ int cmCursesMainForm::Generate()
|
||||
int yi;
|
||||
getmaxyx(stdscr, yi, xi);
|
||||
|
||||
this->ResetOutputs();
|
||||
|
||||
this->UpdateProgress("Generating", 0);
|
||||
this->CMakeInstance->SetProgressCallback(
|
||||
[this](const std::string& msg, float prog) {
|
||||
this->UpdateProgress(msg, prog);
|
||||
});
|
||||
|
||||
this->ResetOutputs();
|
||||
|
||||
// run the generate process
|
||||
int retVal = this->CMakeInstance->Generate();
|
||||
|
||||
@@ -598,6 +598,7 @@ int cmCursesMainForm::Generate()
|
||||
new cmCursesLongMessageForm(this->Outputs, title);
|
||||
CurrentForm = msgs;
|
||||
msgs->Render(1, 1, xx, yy);
|
||||
msgs->ScrollDown();
|
||||
msgs->HandleInput();
|
||||
// If they typed the wrong source directory, we report
|
||||
// an error and exit
|
||||
@@ -619,6 +620,7 @@ void cmCursesMainForm::AddError(const std::string& message,
|
||||
{
|
||||
this->Outputs.emplace_back(message);
|
||||
this->HasNonStatusOutputs = true;
|
||||
this->DisplayOutputs();
|
||||
}
|
||||
|
||||
void cmCursesMainForm::RemoveEntry(const char* value)
|
||||
@@ -1025,8 +1027,24 @@ void cmCursesMainForm::JumpToCacheEntry(const char* astr)
|
||||
|
||||
void cmCursesMainForm::ResetOutputs()
|
||||
{
|
||||
this->LogForm.reset();
|
||||
this->Outputs.clear();
|
||||
this->HasNonStatusOutputs = false;
|
||||
this->LastProgress.clear();
|
||||
}
|
||||
|
||||
void cmCursesMainForm::DisplayOutputs()
|
||||
{
|
||||
int xi;
|
||||
int yi;
|
||||
getmaxyx(stdscr, yi, xi);
|
||||
|
||||
auto newLogForm =
|
||||
new cmCursesLongMessageForm(this->Outputs, this->LastProgress.c_str());
|
||||
CurrentForm = newLogForm;
|
||||
this->LogForm.reset(newLogForm);
|
||||
this->LogForm->Render(1, 1, xi, yi);
|
||||
this->LogForm->ScrollDown();
|
||||
}
|
||||
|
||||
const char* cmCursesMainForm::s_ConstHelpMessage =
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "cmStateTypes.h"
|
||||
|
||||
class cmake;
|
||||
class cmCursesLongMessageForm;
|
||||
|
||||
/** \class cmCursesMainForm
|
||||
* \brief The main page of ccmake
|
||||
@@ -125,13 +126,20 @@ protected:
|
||||
// Clear and reset the output log and state
|
||||
void ResetOutputs();
|
||||
|
||||
// Display the current progress and output
|
||||
void DisplayOutputs();
|
||||
|
||||
// Copies of cache entries stored in the user interface
|
||||
std::vector<cmCursesCacheEntryComposite> Entries;
|
||||
|
||||
// The form used to display logs during processing
|
||||
std::unique_ptr<cmCursesLongMessageForm> LogForm;
|
||||
// Output produced by the last pass
|
||||
std::vector<std::string> Outputs;
|
||||
// Did the last pass produced outputs of interest (errors, warnings, ...)
|
||||
bool HasNonStatusOutputs;
|
||||
// Last progress bar
|
||||
std::string LastProgress;
|
||||
|
||||
// Command line arguments to be passed to cmake each time
|
||||
// it is run
|
||||
|
||||
Reference in New Issue
Block a user