2009-09-28 11:43:28 -04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2002-01-21 15:30:43 -05:00
|
|
|
|
2009-09-28 11:43:28 -04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2002-01-21 15:30:43 -05:00
|
|
|
|
2009-09-28 11:43:28 -04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2016-04-29 09:40:20 -04:00
|
|
|
#include "cmCursesStandardIncludes.h"
|
|
|
|
|
2016-04-29 10:53:13 -04:00
|
|
|
#include "../cmDocumentation.h"
|
2001-11-05 08:37:22 -05:00
|
|
|
#include "../cmSystemTools.h"
|
2001-11-29 16:44:22 -05:00
|
|
|
#include "../cmake.h"
|
2001-11-04 18:05:21 -05:00
|
|
|
|
|
|
|
#include <signal.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
2001-11-14 09:56:33 -05:00
|
|
|
#include "cmCursesMainForm.h"
|
2013-12-18 14:38:56 -07:00
|
|
|
#include <cmsys/Encoding.hxx>
|
2001-11-14 09:56:33 -05:00
|
|
|
|
|
|
|
#include <form.h>
|
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
static const char* cmDocumentationName[][2] = {
|
|
|
|
{ 0, " ccmake - Curses Interface for CMake." },
|
|
|
|
{ 0, 0 }
|
2003-02-14 10:53:37 -05:00
|
|
|
};
|
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
static const char* cmDocumentationUsage[][2] = {
|
|
|
|
{ 0, " ccmake <path-to-source>\n"
|
|
|
|
" ccmake <path-to-existing-build>" },
|
|
|
|
{ 0, "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." },
|
|
|
|
{ 0, 0 }
|
2014-06-12 22:18:32 +02:00
|
|
|
};
|
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
static const char* cmDocumentationUsageNote[][2] = {
|
|
|
|
{ 0, "Run 'ccmake --help' for more information." },
|
|
|
|
{ 0, 0 }
|
2003-02-14 10:53:37 -05:00
|
|
|
};
|
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
static const char* cmDocumentationOptions[]
|
|
|
|
[2] = { CMAKE_STANDARD_OPTIONS_TABLE,
|
|
|
|
{ 0, 0 } };
|
2003-04-02 22:48:12 -05:00
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
cmCursesForm* cmCursesForm::CurrentForm = 0;
|
2001-11-04 18:05:21 -05:00
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
extern "C" {
|
2002-06-11 09:14:19 -04:00
|
|
|
|
2002-06-18 17:20:07 -04:00
|
|
|
void onsig(int)
|
2001-11-04 18:05:21 -05:00
|
|
|
{
|
2016-05-16 10:34:04 -04:00
|
|
|
if (cmCursesForm::CurrentForm) {
|
2001-11-04 18:05:21 -05:00
|
|
|
endwin();
|
2016-05-16 10:34:04 -04:00
|
|
|
initscr(); /* Initialization */
|
|
|
|
noecho(); /* Echo off */
|
|
|
|
cbreak(); /* nl- or cr not needed */
|
|
|
|
keypad(stdscr, TRUE); /* Use key symbols as
|
|
|
|
KEY_DOWN*/
|
2001-11-04 18:05:21 -05:00
|
|
|
refresh();
|
2016-05-16 10:34:04 -04:00
|
|
|
int x, y;
|
2001-11-29 16:44:22 -05:00
|
|
|
getmaxyx(stdscr, y, x);
|
2016-05-16 10:34:04 -04:00
|
|
|
cmCursesForm::CurrentForm->Render(1, 1, x, y);
|
2001-11-29 16:44:22 -05:00
|
|
|
cmCursesForm::CurrentForm->UpdateStatusBar();
|
2016-05-16 10:34:04 -04:00
|
|
|
}
|
2001-11-04 18:05:21 -05:00
|
|
|
signal(SIGWINCH, onsig);
|
|
|
|
}
|
2002-06-11 09:14:19 -04:00
|
|
|
}
|
2001-11-04 18:05:21 -05:00
|
|
|
|
2014-05-15 09:38:30 -04:00
|
|
|
void CMakeMessageHandler(const char* message, const char* title, bool&,
|
|
|
|
void* clientData)
|
2001-11-29 16:44:22 -05:00
|
|
|
{
|
2016-05-16 10:34:04 -04:00
|
|
|
cmCursesForm* self = static_cast<cmCursesForm*>(clientData);
|
2002-09-18 14:18:43 -04:00
|
|
|
self->AddError(message, title);
|
2001-11-29 16:44:22 -05:00
|
|
|
}
|
|
|
|
|
2013-12-18 14:38:56 -07:00
|
|
|
int main(int argc, char const* const* argv)
|
2001-11-04 18:05:21 -05:00
|
|
|
{
|
2013-12-18 14:38:56 -07:00
|
|
|
cmsys::Encoding::CommandLineArguments encoding_args =
|
|
|
|
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
|
|
|
|
argc = encoding_args.argc();
|
|
|
|
argv = encoding_args.argv();
|
|
|
|
|
2013-11-07 15:30:59 -05:00
|
|
|
cmSystemTools::FindCMakeResources(argv[0]);
|
2003-02-14 10:53:37 -05:00
|
|
|
cmDocumentation doc;
|
2011-11-13 22:44:53 +01:00
|
|
|
doc.addCMakeStandardDocSections();
|
2016-05-16 10:34:04 -04:00
|
|
|
if (doc.CheckOptions(argc, argv)) {
|
2003-02-18 20:42:02 -05:00
|
|
|
cmake hcm;
|
2015-05-04 23:01:29 +02:00
|
|
|
hcm.SetHomeDirectory("");
|
|
|
|
hcm.SetHomeOutputDirectory("");
|
2013-10-16 12:54:52 -04:00
|
|
|
hcm.AddCMakePaths();
|
2006-10-04 19:21:20 -04:00
|
|
|
std::vector<cmDocumentationEntry> generators;
|
|
|
|
hcm.GetGeneratorDocumentation(generators);
|
2003-08-06 14:49:52 -04:00
|
|
|
doc.SetName("ccmake");
|
2016-05-16 10:34:04 -04:00
|
|
|
doc.SetSection("Name", cmDocumentationName);
|
|
|
|
doc.SetSection("Usage", cmDocumentationUsage);
|
|
|
|
if (argc == 1) {
|
|
|
|
doc.AppendSection("Usage", cmDocumentationUsageNote);
|
2011-10-13 19:51:18 +02:00
|
|
|
}
|
2016-05-16 10:34:04 -04:00
|
|
|
doc.SetSection("Generators", generators);
|
|
|
|
doc.PrependSection("Options", cmDocumentationOptions);
|
|
|
|
return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1;
|
|
|
|
}
|
2011-10-13 19:51:18 +02:00
|
|
|
|
2001-12-04 11:16:04 -05:00
|
|
|
bool debug = false;
|
2001-11-29 16:44:22 -05:00
|
|
|
unsigned int i;
|
2001-11-30 10:58:23 -05:00
|
|
|
int j;
|
2001-11-29 16:44:22 -05:00
|
|
|
std::vector<std::string> args;
|
2016-05-16 10:34:04 -04:00
|
|
|
for (j = 0; j < argc; ++j) {
|
|
|
|
if (strcmp(argv[j], "-debug") == 0) {
|
2001-12-04 11:16:04 -05:00
|
|
|
debug = true;
|
2016-05-16 10:34:04 -04:00
|
|
|
} else {
|
2001-12-04 11:16:04 -05:00
|
|
|
args.push_back(argv[j]);
|
2001-11-29 16:44:22 -05:00
|
|
|
}
|
2016-05-16 10:34:04 -04:00
|
|
|
}
|
2001-11-04 18:05:21 -05:00
|
|
|
|
2002-05-07 11:03:56 -04:00
|
|
|
std::string cacheDir = cmSystemTools::GetCurrentWorkingDirectory();
|
2016-05-16 10:34:04 -04:00
|
|
|
for (i = 1; i < args.size(); ++i) {
|
2001-11-29 16:44:22 -05:00
|
|
|
std::string arg = args[i];
|
2016-05-16 10:34:04 -04:00
|
|
|
if (arg.find("-B", 0) == 0) {
|
2002-05-07 11:03:56 -04:00
|
|
|
cacheDir = arg.substr(2);
|
2001-11-04 18:05:21 -05:00
|
|
|
}
|
2016-05-16 10:34:04 -04:00
|
|
|
}
|
2001-11-04 18:05:21 -05:00
|
|
|
|
2001-11-29 16:44:22 -05:00
|
|
|
cmSystemTools::DisableRunCommandOutput();
|
2001-11-04 18:05:21 -05:00
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
if (debug) {
|
2001-12-04 11:16:04 -05:00
|
|
|
cmCursesForm::DebugStart();
|
2016-05-16 10:34:04 -04:00
|
|
|
}
|
2001-12-04 11:16:04 -05:00
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
initscr(); /* Initialization */
|
|
|
|
noecho(); /* Echo off */
|
|
|
|
cbreak(); /* nl- or cr not needed */
|
|
|
|
keypad(stdscr, TRUE); /* Use key symbols as
|
|
|
|
KEY_DOWN*/
|
2001-11-04 18:05:21 -05:00
|
|
|
|
|
|
|
signal(SIGWINCH, onsig);
|
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
int x, y;
|
2001-11-29 16:44:22 -05:00
|
|
|
getmaxyx(stdscr, y, x);
|
2016-05-16 10:34:04 -04:00
|
|
|
if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
|
2001-11-29 16:44:22 -05:00
|
|
|
endwin();
|
|
|
|
std::cerr << "Window is too small. A size of at least "
|
2011-10-13 19:51:18 +02:00
|
|
|
<< cmCursesMainForm::MIN_WIDTH << " x "
|
2016-05-16 10:34:04 -04:00
|
|
|
<< cmCursesMainForm::MIN_HEIGHT << " is required to run ccmake."
|
|
|
|
<< std::endl;
|
2001-11-29 16:44:22 -05:00
|
|
|
return 1;
|
2016-05-16 10:34:04 -04:00
|
|
|
}
|
2001-11-29 16:44:22 -05:00
|
|
|
|
|
|
|
cmCursesMainForm* myform;
|
|
|
|
|
2002-05-01 11:34:27 -04:00
|
|
|
myform = new cmCursesMainForm(args, x);
|
2016-05-16 10:34:04 -04:00
|
|
|
if (myform->LoadCache(cacheDir.c_str())) {
|
2003-01-22 10:33:34 -05:00
|
|
|
curses_clear();
|
|
|
|
touchwin(stdscr);
|
|
|
|
endwin();
|
|
|
|
delete myform;
|
2003-01-22 11:27:53 -05:00
|
|
|
std::cerr << "Error running cmake::LoadCache(). Aborting.\n";
|
2003-01-22 10:33:34 -05:00
|
|
|
return 1;
|
2016-05-16 10:34:04 -04:00
|
|
|
}
|
2001-11-29 16:44:22 -05:00
|
|
|
|
2014-05-15 09:38:30 -04:00
|
|
|
cmSystemTools::SetMessageCallback(CMakeMessageHandler, myform);
|
2001-11-29 16:44:22 -05:00
|
|
|
|
|
|
|
cmCursesForm::CurrentForm = myform;
|
|
|
|
|
|
|
|
myform->InitializeUI();
|
2016-05-16 10:34:04 -04:00
|
|
|
if (myform->Configure(1) == 0) {
|
2003-05-29 11:14:48 -04:00
|
|
|
myform->Render(1, 1, x, y);
|
|
|
|
myform->HandleInput();
|
2016-05-16 10:34:04 -04:00
|
|
|
}
|
2011-10-13 19:51:18 +02:00
|
|
|
|
2001-11-04 18:05:21 -05:00
|
|
|
// Need to clean-up better
|
2001-11-30 11:34:13 -05:00
|
|
|
curses_clear();
|
2001-11-29 16:44:22 -05:00
|
|
|
touchwin(stdscr);
|
2001-11-04 18:05:21 -05:00
|
|
|
endwin();
|
2001-11-29 16:44:22 -05:00
|
|
|
delete cmCursesForm::CurrentForm;
|
|
|
|
cmCursesForm::CurrentForm = 0;
|
|
|
|
|
2001-12-06 11:49:16 -05:00
|
|
|
std::cout << std::endl << std::endl;
|
2011-10-13 19:51:18 +02:00
|
|
|
|
2001-11-04 18:05:21 -05:00
|
|
|
return 0;
|
|
|
|
}
|