ENH: add new command VARIABLE_REQUIRES for better debugging of list files
This commit is contained in:
parent
4d5f9deb00
commit
da17f30cb5
|
@ -507,7 +507,8 @@ void CMakeSetupDialog::RunCMake(bool generateProjectFiles)
|
||||||
// always save the current gui values to disk
|
// always save the current gui values to disk
|
||||||
this->SaveCacheFromGUI();
|
this->SaveCacheFromGUI();
|
||||||
// Make sure we are working from the cache on disk
|
// Make sure we are working from the cache on disk
|
||||||
this->LoadCacheFromDiskToGUI();
|
this->LoadCacheFromDiskToGUI();
|
||||||
|
m_OKButton.EnableWindow(false);
|
||||||
// create a cmake object
|
// create a cmake object
|
||||||
cmake make;
|
cmake make;
|
||||||
// create the arguments for the cmake object
|
// create the arguments for the cmake object
|
||||||
|
@ -528,7 +529,6 @@ void CMakeSetupDialog::RunCMake(bool generateProjectFiles)
|
||||||
{
|
{
|
||||||
cmSystemTools::Error(
|
cmSystemTools::Error(
|
||||||
"Error in generation process, project files may be invalid");
|
"Error in generation process, project files may be invalid");
|
||||||
cmSystemTools::ResetErrorOccuredFlag();
|
|
||||||
}
|
}
|
||||||
// update the GUI with any new values in the caused by the
|
// update the GUI with any new values in the caused by the
|
||||||
// generation process
|
// generation process
|
||||||
|
@ -539,12 +539,15 @@ void CMakeSetupDialog::RunCMake(bool generateProjectFiles)
|
||||||
m_BuildPathChanged = false;
|
m_BuildPathChanged = false;
|
||||||
// put the cursor back
|
// put the cursor back
|
||||||
::SetCursor(LoadCursor(NULL, IDC_ARROW));
|
::SetCursor(LoadCursor(NULL, IDC_ARROW));
|
||||||
|
cmSystemTools::ResetErrorOccuredFlag();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Callback for build projects button
|
// Callback for build projects button
|
||||||
void CMakeSetupDialog::OnConfigure()
|
void CMakeSetupDialog::OnConfigure()
|
||||||
{
|
{
|
||||||
|
// enable error messages each time configure is pressed
|
||||||
|
cmSystemTools::EnableMessages();
|
||||||
this->RunCMake(false);
|
this->RunCMake(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,7 +669,7 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_OKButton.EnableWindow(false);
|
m_OKButton.EnableWindow(false);
|
||||||
if(cache.size() > 0)
|
if(cache.size() > 0 && !cmSystemTools::GetErrorOccuredFlag())
|
||||||
{
|
{
|
||||||
bool enable = true;
|
bool enable = true;
|
||||||
items = m_CacheEntriesList.GetItems();
|
items = m_CacheEntriesList.GetItems();
|
||||||
|
@ -850,6 +853,8 @@ void CMakeSetupDialog::OnCancel()
|
||||||
|
|
||||||
void CMakeSetupDialog::OnOk()
|
void CMakeSetupDialog::OnOk()
|
||||||
{
|
{
|
||||||
|
// enable error messages each time configure is pressed
|
||||||
|
cmSystemTools::EnableMessages();
|
||||||
m_CacheEntriesList.ClearDirty();
|
m_CacheEntriesList.ClearDirty();
|
||||||
this->RunCMake(true);
|
this->RunCMake(true);
|
||||||
cmMakefileGenerator::UnRegisterGenerators();
|
cmMakefileGenerator::UnRegisterGenerators();
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
#include "cmTargetLinkLibrariesCommand.cxx"
|
#include "cmTargetLinkLibrariesCommand.cxx"
|
||||||
#include "cmUseMangledMesaCommand.cxx"
|
#include "cmUseMangledMesaCommand.cxx"
|
||||||
#include "cmUtilitySourceCommand.cxx"
|
#include "cmUtilitySourceCommand.cxx"
|
||||||
|
#include "cmVariableRequiresCommand.cxx"
|
||||||
#include "cmVTKWrapJavaCommand.cxx"
|
#include "cmVTKWrapJavaCommand.cxx"
|
||||||
#include "cmVTKWrapPythonCommand.cxx"
|
#include "cmVTKWrapPythonCommand.cxx"
|
||||||
#include "cmVTKWrapTclCommand.cxx"
|
#include "cmVTKWrapTclCommand.cxx"
|
||||||
|
@ -115,6 +116,7 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands)
|
||||||
commands.push_back(new cmTargetLinkLibrariesCommand);
|
commands.push_back(new cmTargetLinkLibrariesCommand);
|
||||||
commands.push_back(new cmUseMangledMesaCommand);
|
commands.push_back(new cmUseMangledMesaCommand);
|
||||||
commands.push_back(new cmUtilitySourceCommand);
|
commands.push_back(new cmUtilitySourceCommand);
|
||||||
|
commands.push_back(new cmVariableRequiresCommand);
|
||||||
commands.push_back(new cmVTKWrapJavaCommand);
|
commands.push_back(new cmVTKWrapJavaCommand);
|
||||||
commands.push_back(new cmVTKWrapPythonCommand);
|
commands.push_back(new cmVTKWrapPythonCommand);
|
||||||
commands.push_back(new cmVTKWrapTclCommand);
|
commands.push_back(new cmVTKWrapTclCommand);
|
||||||
|
|
|
@ -92,6 +92,7 @@ inline int Chdir(const char* dir)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool cmSystemTools::s_ErrorOccured = false;
|
bool cmSystemTools::s_ErrorOccured = false;
|
||||||
|
bool cmSystemTools::s_DisableMessages = false;
|
||||||
|
|
||||||
void (*cmSystemTools::s_ErrorCallback)(const char*, const char*, bool&);
|
void (*cmSystemTools::s_ErrorCallback)(const char*, const char*, bool&);
|
||||||
|
|
||||||
|
@ -711,14 +712,13 @@ void cmSystemTools::SetErrorCallback(ErrorCallback f)
|
||||||
|
|
||||||
void cmSystemTools::Message(const char* m1, const char *title)
|
void cmSystemTools::Message(const char* m1, const char *title)
|
||||||
{
|
{
|
||||||
static bool disableMessages = false;
|
if(s_DisableMessages)
|
||||||
if(disableMessages)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(s_ErrorCallback)
|
if(s_ErrorCallback)
|
||||||
{
|
{
|
||||||
(*s_ErrorCallback)(m1, title, disableMessages);
|
(*s_ErrorCallback)(m1, title, s_DisableMessages);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -285,8 +285,11 @@ public:
|
||||||
///! change directory the the directory specified
|
///! change directory the the directory specified
|
||||||
static int ChangeDirectory(const char* dir);
|
static int ChangeDirectory(const char* dir);
|
||||||
|
|
||||||
|
static void EnableMessages() { s_DisableMessages = false; }
|
||||||
|
static void DisableMessages() { s_DisableMessages = true; }
|
||||||
private:
|
private:
|
||||||
static bool s_ErrorOccured;
|
static bool s_ErrorOccured;
|
||||||
|
static bool s_DisableMessages;
|
||||||
static ErrorCallback s_ErrorCallback;
|
static ErrorCallback s_ErrorCallback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -44,29 +44,50 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
// cmLibraryCommand
|
// cmLibraryCommand
|
||||||
bool cmVariableRequiresCommand::InitialPass(std::vector<std::string> const& args)
|
bool cmVariableRequiresCommand::InitialPass(std::vector<std::string> const& args)
|
||||||
{
|
{
|
||||||
if(args.size() < 4 )
|
if(args.size() < 3 )
|
||||||
{
|
{
|
||||||
this->SetError("called with incorrect number of arguments");
|
this->SetError("called with incorrect number of arguments");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string testVarible = args[0];
|
m_Arguments = args;
|
||||||
if(m_Makefile->IsON(testVarible.c_str()))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
std::string resultVarible = args[1];
|
|
||||||
std::string message = args[2];
|
|
||||||
bool requirementsMet = true;
|
|
||||||
std::string notSet;
|
|
||||||
for(int i = 3; i < args.size(); ++i)
|
|
||||||
{
|
|
||||||
if(!m_Makefile->IsOn(args[i].c_str()))
|
|
||||||
{
|
|
||||||
requirementsMet = false;
|
|
||||||
notSet += args[i];
|
|
||||||
notSet += " ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmVariableRequiresCommand::FinalPass()
|
||||||
|
{
|
||||||
|
std::string testVarible = m_Arguments[0];
|
||||||
|
if(!m_Makefile->IsOn(testVarible.c_str()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::string resultVarible = m_Arguments[1];
|
||||||
|
bool requirementsMet = true;
|
||||||
|
std::string notSet;
|
||||||
|
for(int i = 2; i < m_Arguments.size(); ++i)
|
||||||
|
{
|
||||||
|
if(!m_Makefile->IsOn(m_Arguments[i].c_str()))
|
||||||
|
{
|
||||||
|
requirementsMet = false;
|
||||||
|
notSet += m_Arguments[i];
|
||||||
|
notSet += "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const char* reqVar = m_Makefile->GetDefinition(resultVarible.c_str());
|
||||||
|
// if reqVar is unset, then set it to requirementsMet
|
||||||
|
// if reqVar is set to true, but requirementsMet is false , then
|
||||||
|
// set reqVar to false.
|
||||||
|
if(!reqVar || (!requirementsMet && m_Makefile->IsOn(reqVar)))
|
||||||
|
{
|
||||||
|
m_Makefile->AddDefinition(resultVarible.c_str(), requirementsMet);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!requirementsMet)
|
||||||
|
{
|
||||||
|
std::string message = "Variable assertion failed:\n";
|
||||||
|
message += testVarible + " Requires that the following unset varibles are set:\n";
|
||||||
|
message += notSet;
|
||||||
|
message += "\nPlease set them, or set ";
|
||||||
|
message += testVarible + " to false, and re-configure.";
|
||||||
|
cmSystemTools::Error(message.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -64,11 +64,13 @@ public:
|
||||||
* the CMakeLists.txt file.
|
* the CMakeLists.txt file.
|
||||||
*/
|
*/
|
||||||
virtual bool InitialPass(std::vector<std::string> const& args);
|
virtual bool InitialPass(std::vector<std::string> const& args);
|
||||||
|
|
||||||
|
///!
|
||||||
|
virtual void FinalPass();
|
||||||
/**
|
/**
|
||||||
* The name of the command as specified in CMakeList.txt.
|
* The name of the command as specified in CMakeList.txt.
|
||||||
*/
|
*/
|
||||||
virtual const char* GetName() { return "MESSAGE";}
|
virtual const char* GetName() { return "VARIABLE_REQUIRES";}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Succinct documentation.
|
* Succinct documentation.
|
||||||
|
@ -84,20 +86,23 @@ public:
|
||||||
virtual const char* GetFullDocumentation()
|
virtual const char* GetFullDocumentation()
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
"VARIABLE_REQUIRES(TEST_VARIBLE RESULT_VARIBLE\"Error Message\" "
|
"VARIABLE_REQUIRES(TEST_VARIBLE RESULT_VARIBLE "
|
||||||
"REQUIRED_VARIABLE1 REQUIRED_VARIABLE2 ...) "
|
"REQUIRED_VARIABLE1 REQUIRED_VARIABLE2 ...) "
|
||||||
"The first argument (TEST_VARIABLE) is the name of the varible to be "
|
"The first argument (TEST_VARIABLE) is the name of the varible to be "
|
||||||
"tested, if that varible is false nothing else is done. If "
|
"tested, if that varible is false nothing else is done. If "
|
||||||
"TEST_VARIABLE is true, then "
|
"TEST_VARIABLE is true, then "
|
||||||
"The next arguemnt (RESULT_VARIABLE) is a vairable that is set to true "
|
"the next arguemnt (RESULT_VARIABLE) is a vairable that is set to true "
|
||||||
"if all the "
|
"if all the "
|
||||||
"required variables are set, the next argument "
|
"required variables are set."
|
||||||
"is a message to be displayed if required varibles are not set. "
|
|
||||||
"The rest of the arguments are varibles that must be true or not "
|
"The rest of the arguments are varibles that must be true or not "
|
||||||
"set to NOTFOUND to avoid an error. ";
|
"set to NOTFOUND to avoid an error. ";
|
||||||
}
|
}
|
||||||
|
|
||||||
cmTypeMacro(cmVariableRequiresCommand, cmCommand);
|
cmTypeMacro(cmVariableRequiresCommand, cmCommand);
|
||||||
|
private:
|
||||||
|
std::string m_ErrorMessage;
|
||||||
|
std::vector<std::string> m_Arguments;
|
||||||
|
bool m_RequirementsMet;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue