summaryrefslogtreecommitdiffstats
path: root/Source/cmCableWrapTclCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2001-10-11 21:20:39 (GMT)
committerBrad King <brad.king@kitware.com>2001-10-11 21:20:39 (GMT)
commitb6158ac39c69c634ec0987a6ee9f2adde5d47c93 (patch)
treec1a71e0baf370307348ac7914e9169f18a7282a7 /Source/cmCableWrapTclCommand.cxx
parent8a72356cff6ce39d7fa3c1afd0ab107137702706 (diff)
downloadCMake-b6158ac39c69c634ec0987a6ee9f2adde5d47c93.zip
CMake-b6158ac39c69c634ec0987a6ee9f2adde5d47c93.tar.gz
CMake-b6158ac39c69c634ec0987a6ee9f2adde5d47c93.tar.bz2
ENH: Improved parsing of GCCXML_FLAGS to improve generation of gccxml rule. Also added ADD_DEFINITIONS arguments to the generated rule.
Diffstat (limited to 'Source/cmCableWrapTclCommand.cxx')
-rw-r--r--Source/cmCableWrapTclCommand.cxx49
1 files changed, 39 insertions, 10 deletions
diff --git a/Source/cmCableWrapTclCommand.cxx b/Source/cmCableWrapTclCommand.cxx
index 8dd2ebe..b1b0a7a 100644
--- a/Source/cmCableWrapTclCommand.cxx
+++ b/Source/cmCableWrapTclCommand.cxx
@@ -61,6 +61,8 @@ public:
void AddParsedFlags(std::vector<std::string>& resultArgs);
private:
+ void AddFlag(const std::string&);
+
std::vector<std::string> m_Flags;
};
@@ -69,24 +71,23 @@ void cmCableWrapTclCommand::cmGccXmlFlagsParser::Parse(const char* in_flags)
// Prepare a work string for searching.
std::string flags = in_flags;
- // Look for " -" separating arguments. Currently the find_*_options
- // scripts always output a single space between arguments, so we don't
- // need to worry about removing extra whitespace.
+ // Look for " -" separating arguments.
- // The first argument starts at the beginning of the string.
- std::string::size_type leftPos = 0;
+ // The first argument starts at the first "-" character.
+ std::string::size_type leftPos = flags.find_first_of("-");
+ if(leftPos == std::string::npos) { return; }
std::string::size_type rightPos = flags.find(" -", leftPos);
while(rightPos != std::string::npos)
{
// Pull out and store this argument.
- m_Flags.push_back(flags.substr(leftPos, rightPos-leftPos));
+ this->AddFlag(flags.substr(leftPos, rightPos-leftPos));
// The next argument starts at the '-' from the previously found " -".
leftPos = rightPos+1;
rightPos = flags.find(" -", leftPos);
}
// Pull out and store the last argument.
- m_Flags.push_back(flags.substr(leftPos, std::string::npos));
+ this->AddFlag(flags.substr(leftPos, std::string::npos));
}
void
@@ -100,6 +101,33 @@ cmCableWrapTclCommand::cmGccXmlFlagsParser
}
}
+/**
+ * Used by Parse() to insert a parsed flag. Strips trailing whitespace from
+ * the argument.
+ *
+ * Includes a hack to split "-o /dev/null" into two arguments since
+ * the parser only splits arguments with " -" occurrences.
+ */
+void
+cmCableWrapTclCommand::cmGccXmlFlagsParser
+::AddFlag(const std::string& flag)
+{
+ std::string tmp = flag.substr(0, flag.find_last_not_of(" \t")+1);
+ if(tmp == "-o /dev/null")
+ {
+ m_Flags.push_back("-o");
+ m_Flags.push_back("/dev/null");
+ }
+ else if(tmp == "-D__int64='long long'")
+ {
+ m_Flags.push_back("-D__int64='long");
+ m_Flags.push_back("long'");
+ }
+ else
+ {
+ m_Flags.push_back(tmp);
+ }
+}
cmCableWrapTclCommand::cmCableWrapTclCommand():
m_CableClassSet(NULL), m_MakeDepend(new cmMakeDepend)
@@ -404,12 +432,11 @@ void cmCableWrapTclCommand::GenerateCableClassFiles(const char* name,
std::vector<std::string> commandArgs;
this->AddGccXmlFlagsFromCache(commandArgs);
- //commandArgs.push_back(m_Makefile->GetDefineFlags());
{
std::string tmp = "-I";
tmp += m_Makefile->GetStartDirectory();
- commandArgs.push_back(cmSystemTools::EscapeSpaces(tmp.c_str()));
+ commandArgs.push_back(tmp.c_str());
}
const std::vector<std::string>& includes =
@@ -419,7 +446,8 @@ void cmCableWrapTclCommand::GenerateCableClassFiles(const char* name,
{
std::string tmp = "-I";
tmp += i->c_str();
- commandArgs.push_back(cmSystemTools::EscapeSpaces(tmp.c_str()));
+ m_Makefile->ExpandVariablesInString(tmp);
+ commandArgs.push_back(tmp.c_str());
}
std::string tmp = "-fxml=";
tmp += classXmlName;
@@ -556,6 +584,7 @@ cmCableWrapTclCommand
parser = new cmGccXmlFlagsParser("cmGccXmlFlagsParser");
m_Makefile->RegisterData(parser);
parser->Parse(this->GetGccXmlFlagsFromCache().c_str());
+ parser->Parse(m_Makefile->GetDefineFlags());
}
// Use the parsed flags in the single instance.