VS: Add method to re-parse specific option parser fields

This will allow a client to parse flags, replace the flag tables, and
then re-parse a field in which flags for a secondary tool were
collected.
This commit is contained in:
Brad King
2017-03-07 15:10:30 -05:00
parent a05fc93ee6
commit f7bb40c92d
2 changed files with 23 additions and 1 deletions

View File

@@ -43,6 +43,8 @@ cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions(
this->FortranRuntimeDebug = false;
this->FortranRuntimeDLL = false;
this->FortranRuntimeMT = false;
this->UnknownFlagField = "AdditionalOptions";
}
cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions(
@@ -67,6 +69,8 @@ cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions(
this->FortranRuntimeDebug = false;
this->FortranRuntimeDLL = false;
this->FortranRuntimeMT = false;
this->UnknownFlagField = "AdditionalOptions";
}
void cmVisualStudioGeneratorOptions::AddTable(cmVS7FlagTable const* table)
@@ -229,6 +233,18 @@ void cmVisualStudioGeneratorOptions::PrependInheritedString(
value = "%(" + key + ") " + value;
}
void cmVisualStudioGeneratorOptions::Reparse(std::string const& key)
{
std::map<std::string, FlagValue>::iterator i = this->FlagMap.find(key);
if (i == this->FlagMap.end() || i->second.size() != 1) {
return;
}
std::string const original = i->second[0];
i->second[0] = "";
this->UnknownFlagField = key;
this->Parse(original.c_str());
}
void cmVisualStudioGeneratorOptions::StoreUnknownFlag(const char* flag)
{
// Look for Intel Fortran flags that do not map well in the flag table.
@@ -255,7 +271,7 @@ void cmVisualStudioGeneratorOptions::StoreUnknownFlag(const char* flag)
std::string const opts = cmOutputConverter::EscapeWindowsShellArgument(
flag, cmOutputConverter::Shell_Flag_AllowMakeVariables |
cmOutputConverter::Shell_Flag_VSIDE);
this->AppendFlagString("AdditionalOptions", opts);
this->AppendFlagString(this->UnknownFlagField, opts);
}
void cmVisualStudioGeneratorOptions::SetConfiguration(const char* config)

View File

@@ -52,6 +52,10 @@ public:
void PrependInheritedString(std::string const& key);
// Parse the content of the given flag table entry again to extract
// known flags and leave the rest in the original entry.
void Reparse(std::string const& key);
// Fix the ExceptionHandling option to default to off.
void FixExceptionHandlingDefault();
@@ -84,6 +88,8 @@ private:
bool FortranRuntimeDLL;
bool FortranRuntimeMT;
std::string UnknownFlagField;
virtual void StoreUnknownFlag(const char* flag);
};