diff options
author | Brad King <brad.king@kitware.com> | 2014-04-03 16:51:40 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-04-03 16:51:40 (GMT) |
commit | 8acd2b3ab432557d29ab30cb302e79f89ef22076 (patch) | |
tree | f8336b064a41500308ceb10d8b3b88a61cc71fac /Source | |
parent | 63141883628a5eef6e992edba46d1732d17888ea (diff) | |
parent | e8633e66785eb2f3618d7b31bfd22f26e7a38055 (diff) | |
download | CMake-8acd2b3ab432557d29ab30cb302e79f89ef22076.zip CMake-8acd2b3ab432557d29ab30cb302e79f89ef22076.tar.gz CMake-8acd2b3ab432557d29ab30cb302e79f89ef22076.tar.bz2 |
Merge topic 'vs-flag-with-following-value'
e8633e66 VS: Fix /analyze:log flag mapping (#14858)
650199e7 VS: Support mapping flags with values following separately (#14858)
f2a3dd9d cmIDEOptions: Factor FlagMap update out to separate method
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmIDEFlagTable.h | 1 | ||||
-rw-r--r-- | Source/cmIDEOptions.cxx | 80 | ||||
-rw-r--r-- | Source/cmIDEOptions.h | 2 | ||||
-rw-r--r-- | Source/cmVS11CLFlagTable.h | 9 | ||||
-rw-r--r-- | Source/cmVS12CLFlagTable.h | 9 |
5 files changed, 60 insertions, 41 deletions
diff --git a/Source/cmIDEFlagTable.h b/Source/cmIDEFlagTable.h index e372c0a..d9a045d 100644 --- a/Source/cmIDEFlagTable.h +++ b/Source/cmIDEFlagTable.h @@ -31,6 +31,7 @@ struct cmIDEFlagTable // old value with semicolons (e.g. // /NODEFAULTLIB: => // IgnoreDefaultLibraryNames) + UserFollowing = (1<<5), // expect value in following argument UserValueIgnored = UserValue | UserIgnored, UserValueRequired = UserValue | UserRequired diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index e03223f..1f3c066 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -19,6 +19,7 @@ cmIDEOptions::cmIDEOptions() this->DoingDefine = false; this->AllowDefine = true; this->AllowSlash = false; + this->DoingFollowing = 0; for(int i=0; i < FlagTableCount; ++i) { this->FlagTable[i] = 0; @@ -41,6 +42,14 @@ void cmIDEOptions::HandleFlag(const char* flag) return; } + // If the last option expected a following value, this is it. + if(this->DoingFollowing) + { + this->FlagMapUpdate(this->DoingFollowing, flag); + this->DoingFollowing = 0; + return; + } + // Look for known arguments. if(flag[0] == '-' || (this->AllowSlash && flag[0] == '/')) { @@ -99,40 +108,22 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table, (!(entry->special & cmIDEFlagTable::UserRequired) || static_cast<int>(strlen(flag+1)) > n)) { - if(entry->special & cmIDEFlagTable::UserIgnored) - { - // Ignore the user-specified value. - this->FlagMap[entry->IDEName] = entry->value; - } - else if(entry->special & cmIDEFlagTable::SemicolonAppendable) - { - const char *new_value = flag+1+n; - - std::map<std::string,std::string>::iterator itr; - itr = this->FlagMap.find(entry->IDEName); - if(itr != this->FlagMap.end()) - { - // Append to old value (if present) with semicolons; - itr->second += ";"; - itr->second += new_value; - } - else - { - this->FlagMap[entry->IDEName] = new_value; - } - } - else - { - // Use the user-specified value. - this->FlagMap[entry->IDEName] = flag+1+n; - } + this->FlagMapUpdate(entry, flag+n+1); entry_found = true; } } else if(strcmp(flag+1, entry->commandFlag) == 0) { - // This flag table entry provides a fixed value. - this->FlagMap[entry->IDEName] = entry->value; + if(entry->special & cmIDEFlagTable::UserFollowing) + { + // This flag expects a value in the following argument. + this->DoingFollowing = entry; + } + else + { + // This flag table entry provides a fixed value. + this->FlagMap[entry->IDEName] = entry->value; + } entry_found = true; } @@ -151,6 +142,37 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table, } //---------------------------------------------------------------------------- +void cmIDEOptions::FlagMapUpdate(cmIDEFlagTable const* entry, + const char* new_value) +{ + if(entry->special & cmIDEFlagTable::UserIgnored) + { + // Ignore the user-specified value. + this->FlagMap[entry->IDEName] = entry->value; + } + else if(entry->special & cmIDEFlagTable::SemicolonAppendable) + { + std::map<std::string,std::string>::iterator itr; + itr = this->FlagMap.find(entry->IDEName); + if(itr != this->FlagMap.end()) + { + // Append to old value (if present) with semicolons; + itr->second += ";"; + itr->second += new_value; + } + else + { + this->FlagMap[entry->IDEName] = new_value; + } + } + else + { + // Use the user-specified value. + this->FlagMap[entry->IDEName] = new_value; + } +} + +//---------------------------------------------------------------------------- void cmIDEOptions::AddDefine(const std::string& def) { this->Defines.push_back(def); diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index 691893f..e7749ec 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -51,11 +51,13 @@ protected: bool DoingDefine; bool AllowDefine; bool AllowSlash; + cmIDEFlagTable const* DoingFollowing; enum { FlagTableCount = 16 }; cmIDEFlagTable const* FlagTable[FlagTableCount]; void HandleFlag(const char* flag); bool CheckFlagTable(cmIDEFlagTable const* table, const char* flag, bool& flag_handled); + void FlagMapUpdate(cmIDEFlagTable const* entry, const char* new_value); virtual void StoreUnknownFlag(const char* flag) = 0; }; diff --git a/Source/cmVS11CLFlagTable.h b/Source/cmVS11CLFlagTable.h index 5ab8ebb..a61ab16 100644 --- a/Source/cmVS11CLFlagTable.h +++ b/Source/cmVS11CLFlagTable.h @@ -248,9 +248,9 @@ static cmVS7FlagTable cmVS11CLFlagTable[] = {"ForcedUsingFiles", "FU", "Forced #using File", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable}, - {"PREfastAdditionalOptions", "analyze:", - "Additional Code Analysis Native options", - "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable}, + {"PREfastLog", "analyze:log", + "Code Analysis Log", + "", cmVS7FlagTable::UserFollowing}, {"PREfastAdditionalPlugins", "analyze:plugin", "Additional Code Analysis Native plugins", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable}, @@ -283,9 +283,6 @@ static cmVS7FlagTable cmVS11CLFlagTable[] = "", cmVS7FlagTable::UserValue}, // Skip [XMLDocumentationFileName] - no command line Switch. // Skip [BrowseInformationFile] - no command line Switch. - {"PREfastLog", "analyze:log ", - "Code Analysis Log", - "", cmVS7FlagTable::UserValue}, // Skip [AdditionalOptions] - no command line Switch. {0,0,0,0,0} }; diff --git a/Source/cmVS12CLFlagTable.h b/Source/cmVS12CLFlagTable.h index 8f51319..0a7916f 100644 --- a/Source/cmVS12CLFlagTable.h +++ b/Source/cmVS12CLFlagTable.h @@ -254,9 +254,9 @@ static cmVS7FlagTable cmVS12CLFlagTable[] = {"ForcedUsingFiles", "FU", "Forced #using File", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable}, - {"PREfastAdditionalOptions", "analyze:", - "Additional Code Analysis Native options", - "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable}, + {"PREfastLog", "analyze:log", + "Code Analysis Log", + "", cmVS7FlagTable::UserFollowing}, {"PREfastAdditionalPlugins", "analyze:plugin", "Additional Code Analysis Native plugins", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable}, @@ -289,9 +289,6 @@ static cmVS7FlagTable cmVS12CLFlagTable[] = "", cmVS7FlagTable::UserValue}, // Skip [XMLDocumentationFileName] - no command line Switch. // Skip [BrowseInformationFile] - no command line Switch. - {"PREfastLog", "analyze:log ", - "Code Analysis Log", - "", cmVS7FlagTable::UserValue}, // Skip [AdditionalOptions] - no command line Switch. {0,0,0,0,0} }; |