CMake/Source/CursesDialog/ccmake.cxx

180 lines
4.9 KiB
C++
Raw Normal View History

Simplify CMake per-source license notices Per-source copyright/license notice headers that spell out copyright holder names and years are hard to maintain and often out-of-date or plain wrong. Precise contributor information is already maintained automatically by the version control tool. Ultimately it is the receiver of a file who is responsible for determining its licensing status, and per-source notices are merely a convenience. Therefore it is simpler and more accurate for each source to have a generic notice of the license name and references to more detailed information on copyright holders and full license terms. Our `Copyright.txt` file now contains a list of Contributors whose names appeared source-level copyright notices. It also references version control history for more precise information. Therefore we no longer need to spell out the list of Contributors in each source file notice. Replace CMake per-source copyright/license notice headers with a short description of the license and links to `Copyright.txt` and online information available from "https://cmake.org/licensing". The online URL also handles cases of modules being copied out of our source into other projects, so we can drop our notices about replacing links with full license text. Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority of the replacements mechanically. Manually fix up shebang lines and trailing newlines in a few files. Manually update the notices in a few files that the script does not handle.
2016-09-27 22:01:08 +03:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2016-09-01 22:55:09 +03:00
#include <cmConfigure.h>
2001-11-05 02:05:21 +03:00
2016-09-01 22:55:09 +03:00
#include "cmCursesForm.h"
#include "cmCursesMainForm.h"
2016-09-01 22:55:09 +03:00
#include "cmCursesStandardIncludes.h"
#include "cmDocumentation.h"
#include "cmDocumentationEntry.h"
#include "cmSystemTools.h"
#include "cmake.h"
2016-09-01 22:55:09 +03:00
#include <cmsys/Encoding.hxx>
#include <iostream>
#include <signal.h>
#include <string.h>
#include <string>
#include <vector>
static const char* cmDocumentationName[][2] = {
2016-06-27 23:44:16 +03:00
{ CM_NULLPTR, " ccmake - Curses Interface for CMake." },
{ CM_NULLPTR, CM_NULLPTR }
};
static const char* cmDocumentationUsage[][2] = {
2016-06-27 23:44:16 +03:00
{ CM_NULLPTR, " ccmake <path-to-source>\n"
" ccmake <path-to-existing-build>" },
{ CM_NULLPTR,
"Specify a source directory to (re-)generate a build system for "
"it in the current working directory. Specify an existing build "
"directory to re-generate its build system." },
{ CM_NULLPTR, CM_NULLPTR }
};
static const char* cmDocumentationUsageNote[][2] = {
2016-06-27 23:44:16 +03:00
{ CM_NULLPTR, "Run 'ccmake --help' for more information." },
{ CM_NULLPTR, CM_NULLPTR }
};
static const char* cmDocumentationOptions[]
[2] = { CMAKE_STANDARD_OPTIONS_TABLE,
2016-06-27 23:44:16 +03:00
{ CM_NULLPTR, CM_NULLPTR } };
2016-06-27 23:44:16 +03:00
cmCursesForm* cmCursesForm::CurrentForm = CM_NULLPTR;
2001-11-05 02:05:21 +03:00
extern "C" {
2002-06-11 17:14:19 +04:00
void onsig(int /*unused*/)
2001-11-05 02:05:21 +03:00
{
if (cmCursesForm::CurrentForm) {
2001-11-05 02:05:21 +03:00
endwin();
initscr(); /* Initialization */
noecho(); /* Echo off */
cbreak(); /* nl- or cr not needed */
keypad(stdscr, TRUE); /* Use key symbols as
KEY_DOWN*/
2001-11-05 02:05:21 +03:00
refresh();
int x, y;
2001-11-30 00:44:22 +03:00
getmaxyx(stdscr, y, x);
cmCursesForm::CurrentForm->Render(1, 1, x, y);
2001-11-30 00:44:22 +03:00
cmCursesForm::CurrentForm->UpdateStatusBar();
}
2001-11-05 02:05:21 +03:00
signal(SIGWINCH, onsig);
}
2002-06-11 17:14:19 +04:00
}
2001-11-05 02:05:21 +03:00
void CMakeMessageHandler(const char* message, const char* title,
bool& /*unused*/, void* clientData)
2001-11-30 00:44:22 +03:00
{
cmCursesForm* self = static_cast<cmCursesForm*>(clientData);
self->AddError(message, title);
2001-11-30 00:44:22 +03:00
}
int main(int argc, char const* const* argv)
2001-11-05 02:05:21 +03:00
{
cmsys::Encoding::CommandLineArguments encoding_args =
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
argc = encoding_args.argc();
argv = encoding_args.argv();
cmSystemTools::FindCMakeResources(argv[0]);
cmDocumentation doc;
doc.addCMakeStandardDocSections();
if (doc.CheckOptions(argc, argv)) {
cmake hcm;
hcm.SetHomeDirectory("");
hcm.SetHomeOutputDirectory("");
hcm.AddCMakePaths();
std::vector<cmDocumentationEntry> generators;
hcm.GetGeneratorDocumentation(generators);
doc.SetName("ccmake");
doc.SetSection("Name", cmDocumentationName);
doc.SetSection("Usage", cmDocumentationUsage);
if (argc == 1) {
doc.AppendSection("Usage", cmDocumentationUsageNote);
2011-10-13 21:51:18 +04:00
}
doc.SetSection("Generators", generators);
doc.PrependSection("Options", cmDocumentationOptions);
return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1;
}
2011-10-13 21:51:18 +04:00
2001-12-04 19:16:04 +03:00
bool debug = false;
2001-11-30 00:44:22 +03:00
unsigned int i;
2001-11-30 18:58:23 +03:00
int j;
2001-11-30 00:44:22 +03:00
std::vector<std::string> args;
for (j = 0; j < argc; ++j) {
if (strcmp(argv[j], "-debug") == 0) {
2001-12-04 19:16:04 +03:00
debug = true;
} else {
2001-12-04 19:16:04 +03:00
args.push_back(argv[j]);
2001-11-30 00:44:22 +03:00
}
}
2001-11-05 02:05:21 +03:00
std::string cacheDir = cmSystemTools::GetCurrentWorkingDirectory();
for (i = 1; i < args.size(); ++i) {
2001-11-30 00:44:22 +03:00
std::string arg = args[i];
if (arg.find("-B", 0) == 0) {
cacheDir = arg.substr(2);
2001-11-05 02:05:21 +03:00
}
}
2001-11-05 02:05:21 +03:00
2001-11-30 00:44:22 +03:00
cmSystemTools::DisableRunCommandOutput();
2001-11-05 02:05:21 +03:00
if (debug) {
2001-12-04 19:16:04 +03:00
cmCursesForm::DebugStart();
}
2001-12-04 19:16:04 +03:00
initscr(); /* Initialization */
noecho(); /* Echo off */
cbreak(); /* nl- or cr not needed */
keypad(stdscr, TRUE); /* Use key symbols as
KEY_DOWN*/
2001-11-05 02:05:21 +03:00
signal(SIGWINCH, onsig);
int x, y;
2001-11-30 00:44:22 +03:00
getmaxyx(stdscr, y, x);
if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
2001-11-30 00:44:22 +03:00
endwin();
std::cerr << "Window is too small. A size of at least "
2011-10-13 21:51:18 +04:00
<< cmCursesMainForm::MIN_WIDTH << " x "
<< cmCursesMainForm::MIN_HEIGHT << " is required to run ccmake."
<< std::endl;
2001-11-30 00:44:22 +03:00
return 1;
}
2001-11-30 00:44:22 +03:00
cmCursesMainForm* myform;
myform = new cmCursesMainForm(args, x);
if (myform->LoadCache(cacheDir.c_str())) {
curses_clear();
touchwin(stdscr);
endwin();
delete myform;
2003-01-22 19:27:53 +03:00
std::cerr << "Error running cmake::LoadCache(). Aborting.\n";
return 1;
}
2001-11-30 00:44:22 +03:00
cmSystemTools::SetMessageCallback(CMakeMessageHandler, myform);
2001-11-30 00:44:22 +03:00
cmCursesForm::CurrentForm = myform;
myform->InitializeUI();
if (myform->Configure(1) == 0) {
myform->Render(1, 1, x, y);
myform->HandleInput();
}
2011-10-13 21:51:18 +04:00
2001-11-05 02:05:21 +03:00
// Need to clean-up better
curses_clear();
2001-11-30 00:44:22 +03:00
touchwin(stdscr);
2001-11-05 02:05:21 +03:00
endwin();
2001-11-30 00:44:22 +03:00
delete cmCursesForm::CurrentForm;
2016-06-27 23:44:16 +03:00
cmCursesForm::CurrentForm = CM_NULLPTR;
2001-11-30 00:44:22 +03:00
2001-12-06 19:49:16 +03:00
std::cout << std::endl << std::endl;
2011-10-13 21:51:18 +04:00
2001-11-05 02:05:21 +03:00
return 0;
}