From cff74e9a78b79c1dc3a0a689bf454a2e78ee6f9f Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 8 Jun 2001 14:40:28 -0400 Subject: [PATCH] ENH: Added proper request for/generation of CABLE, GCCXML, and GCCXML_FLAGS cache entries. This also allowed the correct generation of gccxml rules. --- Source/cmCableWrapTclCommand.cxx | 127 ++++++++++++++++++++++--------- Source/cmCableWrapTclCommand.h | 3 + 2 files changed, 96 insertions(+), 34 deletions(-) diff --git a/Source/cmCableWrapTclCommand.cxx b/Source/cmCableWrapTclCommand.cxx index 8fca05668..57eea823b 100644 --- a/Source/cmCableWrapTclCommand.cxx +++ b/Source/cmCableWrapTclCommand.cxx @@ -252,46 +252,44 @@ void cmCableWrapTclCommand::GenerateCableClassFiles(const char* name, cmSystemTools::Error("Error opening file for writing: ", classCxxName.c_str()); } - + + // Generate the rule to have GCC-XML parse the classes to be wrapped. { - std::string command = "${GCCXML}"; - m_Makefile->ExpandVariablesInString(command); - // Only add the rule if GCC-XML is available. - if((command != "") && (command != "${GCCXML}")) + std::string command = this->GetGccXmlFromCache(); + std::vector depends; + depends.push_back(command); + + std::string commandArgs = this->GetGccXmlFlagsFromCache(); + commandArgs += " "; + commandArgs += m_Makefile->GetDefineFlags(); + commandArgs += " -I\""; + commandArgs += m_Makefile->GetStartDirectory(); + commandArgs += "\""; + + const std::vector& includes = + m_Makefile->GetIncludeDirectories(); + for(std::vector::const_iterator i = includes.begin(); + i != includes.end(); ++i) { - std::vector depends; - depends.push_back(command); - command = cmSystemTools::EscapeSpaces(command.c_str()); - - std::string defineFlags = m_Makefile->GetDefineFlags(); - std::string includeFlags = "-I"; - includeFlags += std::string("\"") + m_Makefile->GetStartDirectory() + "\""; - - const std::vector& includes = - m_Makefile->GetIncludeDirectories(); - for(std::vector::const_iterator i = includes.begin(); - i != includes.end(); ++i) - { - includeFlags += " -I"; - includeFlags += cmSystemTools::EscapeSpaces(i->c_str()); - } - - command += " "+defineFlags+" "+includeFlags+" -fsyntax-only \"-fxml="+classXmlName+"\" "+classCxxName; - - std::vector outputs; - outputs.push_back(classXmlName); - - m_Makefile->AddCustomCommand(classCxxName.c_str(), - command.c_str(), - "", - depends, - outputs, m_TargetName.c_str()); + commandArgs += " -I"; + commandArgs += cmSystemTools::EscapeSpaces(i->c_str()); } + + commandArgs += " -fsyntax-only -fxml="+classXmlName+" "+classCxxName; + + std::vector outputs; + outputs.push_back(classXmlName); + + m_Makefile->AddCustomCommand(classCxxName.c_str(), + command.c_str(), + commandArgs.c_str(), + depends, + outputs, m_TargetName.c_str()); } + // Generate the rule to run cable on the GCC-XML output to generate wrappers. { - std::string command = "${CABLE}"; - m_Makefile->ExpandVariablesInString(command); + std::string command = this->GetCableFromCache(); std::vector depends; depends.push_back(command); std::string commandArgs = " "+classConfigName+" -tcl "+classTclFullName+".cxx"; @@ -321,3 +319,64 @@ void cmCableWrapTclCommand::GenerateCableClassFiles(const char* name, file.GetDepends().push_back("wrapCalls.h"); m_Makefile->AddSource(file, m_TargetName.c_str()); } + + +/** + * Get the "GCCXML" cache entry value. If there is no cache entry for GCCXML, + * one will be created and initialized to NOTFOUND. + */ +std::string cmCableWrapTclCommand::GetGccXmlFromCache() const +{ + const char* gccxml = + cmCacheManager::GetInstance()->GetCacheValue("GCCXML"); + if(gccxml) + { return gccxml; } + + m_Makefile->AddDefinition("GCCXML","NOTFOUND"); + cmCacheManager::GetInstance()->AddCacheEntry("GCCXML", + "NOTFOUND", + "Path to GCC-XML executable.", + cmCacheManager::FILEPATH); + return "NOTFOUND"; +} + + +/** + * Get the "GCCXML_FLAGS" cache entry value. If there is no cache + * entry for GCCXML_FLAGS, one will be created and initialized "". + */ +std::string cmCableWrapTclCommand::GetGccXmlFlagsFromCache() const +{ + const char* gccxmlFlags = + cmCacheManager::GetInstance()->GetCacheValue("GCCXML_FLAGS"); + if(gccxmlFlags) + { return gccxmlFlags; } + + m_Makefile->AddDefinition("GCCXML_FLAGS",""); + cmCacheManager::GetInstance()->AddCacheEntry( + "GCCXML_FLAGS", + "", + "Flags to GCC-XML to get it to parse the native compiler's headers.", + cmCacheManager::STRING); + return ""; +} + + +/** + * Get the "CABLE" cache entry value. If there is no cache entry for CABLE, + * one will be created and initialized to NOTFOUND. + */ +std::string cmCableWrapTclCommand::GetCableFromCache() const +{ + const char* cable = + cmCacheManager::GetInstance()->GetCacheValue("CABLE"); + if(cable) + { return cable; } + + m_Makefile->AddDefinition("CABLE","NOTFOUND"); + cmCacheManager::GetInstance()->AddCacheEntry("CABLE", + "NOTFOUND", + "Path to CABLE executable.", + cmCacheManager::FILEPATH); + return "NOTFOUND"; +} diff --git a/Source/cmCableWrapTclCommand.h b/Source/cmCableWrapTclCommand.h index 055b03503..a86f8ff41 100644 --- a/Source/cmCableWrapTclCommand.h +++ b/Source/cmCableWrapTclCommand.h @@ -98,6 +98,9 @@ public: protected: void GenerateCableFiles() const; void GenerateCableClassFiles(const char*, const cmCableClass&, unsigned int) const; + std::string GetGccXmlFromCache() const; + std::string GetGccXmlFlagsFromCache() const; + std::string GetCableFromCache() const; private: /**