ENH: Added a special flags integer field to the flag map entries. Added flags for user values and other special cases. Added precompiled header flag translation entries. This addresses bug#3512.

This commit is contained in:
Brad King 2007-02-01 15:02:35 -05:00
parent 293f24763f
commit 939ae77b7b
1 changed files with 141 additions and 79 deletions

View File

@ -291,12 +291,18 @@ struct cmVS7FlagTable
const char* commandFlag; // command line flag const char* commandFlag; // command line flag
const char* comment; // comment const char* comment; // comment
const char* value; // string value const char* value; // string value
}; unsigned int special; // flags for special handling requests
enum
{
UserValue = (1<<0), // flag contains a user-specified value
UserIgnored = (1<<1), // ignore any user value
UserRequired = (1<<2), // match only when user value is non-empty
Continue = (1<<3), // continue looking for matching entries
// A statically allocated string so that user value options can be UserValueIgnored = UserValue | UserIgnored,
// identified with a single pointer comparison and can never be UserValueRequired = UserValue | UserRequired
// confused with actual values. };
static const char CMFLAG_USER_VALUE[] = "<USER_VALUE>"; };
// fill the table here currently the comment field is not used for // fill the table here currently the comment field is not used for
// anything other than documentation NOTE: Make sure the longer // anything other than documentation NOTE: Make sure the longer
@ -304,83 +310,108 @@ static const char CMFLAG_USER_VALUE[] = "<USER_VALUE>";
cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] = cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] =
{ {
// option flags (some flags map to the same option) // option flags (some flags map to the same option)
{"BasicRuntimeChecks", "GZ", "Stack frame checks", "1"}, {"BasicRuntimeChecks", "GZ", "Stack frame checks", "1", 0},
{"BasicRuntimeChecks", "RTCsu", "Both stack and uninitialized checks", "3"}, {"BasicRuntimeChecks", "RTCsu",
{"BasicRuntimeChecks", "RTCs", "Stack frame checks", "1"}, "Both stack and uninitialized checks", "3", 0},
{"BasicRuntimeChecks", "RTCu", "Uninitialized Variables ", "2"}, {"BasicRuntimeChecks", "RTCs", "Stack frame checks", "1", 0},
{"BasicRuntimeChecks", "RTC1", "Both stack and uninitialized checks ", "3"}, {"BasicRuntimeChecks", "RTCu", "Uninitialized Variables ", "2", 0},
{"DebugInformationFormat", "Z7", "debug format", "1"}, {"BasicRuntimeChecks", "RTC1",
{"DebugInformationFormat", "Zd", "debug format", "2"}, "Both stack and uninitialized checks", "3", 0},
{"DebugInformationFormat", "Zi", "debug format", "3"}, {"DebugInformationFormat", "Z7", "debug format", "1", 0},
{"DebugInformationFormat", "ZI", "debug format", "4"}, {"DebugInformationFormat", "Zd", "debug format", "2", 0},
{"EnableEnhancedInstructionSet", "arch:SSE2", "Use sse2 instructions", "2"}, {"DebugInformationFormat", "Zi", "debug format", "3", 0},
{"EnableEnhancedInstructionSet", "arch:SSE", "Use sse instructions", "1"}, {"DebugInformationFormat", "ZI", "debug format", "4", 0},
{"FavorSizeOrSpeed", "Ot", "Favor fast code", "1"}, {"EnableEnhancedInstructionSet", "arch:SSE2",
{"FavorSizeOrSpeed", "Os", "Favor small code", "2"}, "Use sse2 instructions", "2", 0},
{"CompileAs", "TC", "Compile as c code", "1"}, {"EnableEnhancedInstructionSet", "arch:SSE",
{"CompileAs", "TP", "Compile as c++ code", "2"}, "Use sse instructions", "1", 0},
{"Optimization", "Od", "Non Debug", "0"}, {"FavorSizeOrSpeed", "Ot", "Favor fast code", "1", 0},
{"Optimization", "O1", "Min Size", "1"}, {"FavorSizeOrSpeed", "Os", "Favor small code", "2", 0},
{"Optimization", "O2", "Max Speed", "2"}, {"CompileAs", "TC", "Compile as c code", "1", 0},
{"Optimization", "Ox", "Max Optimization", "3"}, {"CompileAs", "TP", "Compile as c++ code", "2", 0},
{"OptimizeForProcessor", "GB", "Blended processor mode", "0"}, {"Optimization", "Od", "Non Debug", "0", 0},
{"OptimizeForProcessor", "G5", "Pentium", "1"}, {"Optimization", "O1", "Min Size", "1", 0},
{"OptimizeForProcessor", "G6", "PPro PII PIII", "2"}, {"Optimization", "O2", "Max Speed", "2", 0},
{"OptimizeForProcessor", "G7", "Pentium 4 or Athlon", "3"}, {"Optimization", "Ox", "Max Optimization", "3", 0},
{"InlineFunctionExpansion", "Ob0", "no inlines", "0"}, {"OptimizeForProcessor", "GB", "Blended processor mode", "0", 0},
{"InlineFunctionExpansion", "Ob1", "when inline keyword", "1"}, {"OptimizeForProcessor", "G5", "Pentium", "1", 0},
{"InlineFunctionExpansion", "Ob2", "any time you can inline", "2"}, {"OptimizeForProcessor", "G6", "PPro PII PIII", "2", 0},
{"RuntimeLibrary", "MTd", "Multithreded debug", "1"}, {"OptimizeForProcessor", "G7", "Pentium 4 or Athlon", "3", 0},
{"RuntimeLibrary", "MT", "Multithreded", "0"}, {"InlineFunctionExpansion", "Ob0", "no inlines", "0", 0},
{"RuntimeLibrary", "MDd", "Multithreded dll debug", "3"}, {"InlineFunctionExpansion", "Ob1", "when inline keyword", "1", 0},
{"RuntimeLibrary", "MD", "Multithreded dll", "2"}, {"InlineFunctionExpansion", "Ob2", "any time you can inline", "2", 0},
{"RuntimeLibrary", "MLd", "Sinble Thread debug", "5"}, {"RuntimeLibrary", "MTd", "Multithreded debug", "1", 0},
{"RuntimeLibrary", "ML", "Sinble Thread", "4"}, {"RuntimeLibrary", "MT", "Multithreded", "0", 0},
{"StructMemberAlignment", "Zp16", "struct align 16 byte ", "5"}, {"RuntimeLibrary", "MDd", "Multithreded dll debug", "3", 0},
{"StructMemberAlignment", "Zp1", "struct align 1 byte ", "1"}, {"RuntimeLibrary", "MD", "Multithreded dll", "2", 0},
{"StructMemberAlignment", "Zp2", "struct align 2 byte ", "2"}, {"RuntimeLibrary", "MLd", "Sinble Thread debug", "5", 0},
{"StructMemberAlignment", "Zp4", "struct align 4 byte ", "3"}, {"RuntimeLibrary", "ML", "Sinble Thread", "4", 0},
{"StructMemberAlignment", "Zp8", "struct align 8 byte ", "4"}, {"StructMemberAlignment", "Zp16", "struct align 16 byte ", "5", 0},
{"WarningLevel", "W1", "Warning level", "1"}, {"StructMemberAlignment", "Zp1", "struct align 1 byte ", "1", 0},
{"WarningLevel", "W2", "Warning level", "2"}, {"StructMemberAlignment", "Zp2", "struct align 2 byte ", "2", 0},
{"WarningLevel", "W3", "Warning level", "3"}, {"StructMemberAlignment", "Zp4", "struct align 4 byte ", "3", 0},
{"WarningLevel", "W4", "Warning level", "4"}, {"StructMemberAlignment", "Zp8", "struct align 8 byte ", "4", 0},
{"WarningLevel", "W1", "Warning level", "1", 0},
{"WarningLevel", "W2", "Warning level", "2", 0},
{"WarningLevel", "W3", "Warning level", "3", 0},
{"WarningLevel", "W4", "Warning level", "4", 0},
// Precompiled header and related options. Note that the
// UsePrecompiledHeader entries are marked as "Continue" so that the
// corresponding PrecompiledHeaderThrough entry can be found.
{"UsePrecompiledHeader", "Yc", "Create Precompiled Header", "1",
cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
{"PrecompiledHeaderThrough", "Yc", "Precompiled Header Name", "",
cmVS7FlagTable::UserValueRequired},
{"UsePrecompiledHeader", "YX", "Automatically Generate", "2",
cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
{"PrecompiledHeaderThrough", "YX", "Precompiled Header Name", "",
cmVS7FlagTable::UserValueRequired},
{"UsePrecompiledHeader", "Yu", "Use Precompiled Header", "3",
cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
{"PrecompiledHeaderThrough", "Yu", "Precompiled Header Name", "",
cmVS7FlagTable::UserValueRequired},
{"PrecompiledHeaderFile", "Fp", "Generated Precompiled Header", "",
cmVS7FlagTable::UserValue},
{"ForcedIncludeFiles", "FI", "Forced include files", "",
cmVS7FlagTable::UserValueRequired},
// boolean flags // boolean flags
{"BufferSecurityCheck", "GS", "Buffer security check", "TRUE"}, {"BufferSecurityCheck", "GS", "Buffer security check", "TRUE", 0},
{"EnableFibreSafeOptimization", "GT", "OmitFramePointers", "TRUE"}, {"EnableFibreSafeOptimization", "GT", "OmitFramePointers", "TRUE", 0},
{"EnableFunctionLevelLinking", "Gy", "EnableFunctionLevelLinking", "TRUE"}, {"EnableFunctionLevelLinking", "Gy",
{"EnableIntrinsicFunctions", "Oi", "EnableIntrinsicFunctions", "TRUE"}, "EnableFunctionLevelLinking", "TRUE", 0},
{"ExceptionHandling", "EHsc", "enable c++ exceptions", "TRUE"}, {"EnableIntrinsicFunctions", "Oi", "EnableIntrinsicFunctions", "TRUE", 0},
{"ExceptionHandling", "EHa", "enable c++ exceptions", "2"}, {"ExceptionHandling", "EHsc", "enable c++ exceptions", "TRUE", 0},
{"ExceptionHandling", "GX", "enable c++ exceptions", "TRUE"}, {"ExceptionHandling", "EHa", "enable c++ exceptions", "2", 0},
{"GlobalOptimizations", "Og", "Global Optimize", "TRUE"}, {"ExceptionHandling", "GX", "enable c++ exceptions", "TRUE", 0},
{"ImproveFloatingPointConsistency", "Op", {"GlobalOptimizations", "Og", "Global Optimize", "TRUE", 0},
"ImproveFloatingPointConsistency", "TRUE"}, {"ImproveFloatingPointConsistency", "Op",
{"MinimalRebuild", "Gm", "minimal rebuild", "TRUE"}, "ImproveFloatingPointConsistency", "TRUE", 0},
{"OmitFramePointers", "Oy", "OmitFramePointers", "TRUE"}, {"MinimalRebuild", "Gm", "minimal rebuild", "TRUE", 0},
{"OptimizeForWindowsApplication", "GA", "Optimize for windows", "TRUE"}, {"OmitFramePointers", "Oy", "OmitFramePointers", "TRUE", 0},
{"RuntimeTypeInfo", "GR", {"OptimizeForWindowsApplication", "GA", "Optimize for windows", "TRUE", 0},
"Turn on Run time type information for c++", "TRUE"}, {"RuntimeTypeInfo", "GR",
{"SmallerTypeCheck", "RTCc", "smaller type check", "TRUE"}, "Turn on Run time type information for c++", "TRUE", 0},
{"SuppressStartupBanner", "nologo", "SuppressStartupBanner", "TRUE"}, {"SmallerTypeCheck", "RTCc", "smaller type check", "TRUE", 0},
{"WarnAsError", "WX", "Treat warnings as errors", "TRUE"}, {"SuppressStartupBanner", "nologo", "SuppressStartupBanner", "TRUE", 0},
{0,0,0,0 } {"WarnAsError", "WX", "Treat warnings as errors", "TRUE", 0},
{0,0,0,0,0}
}; };
cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] = cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] =
{ {
// option flags (some flags map to the same option) // option flags (some flags map to the same option)
{"GenerateManifest", "MANIFEST:NO", "disable manifest generation", "FALSE"}, {"GenerateManifest", "MANIFEST:NO",
{"GenerateManifest", "MANIFEST", "enable manifest generation", "TRUE"}, "disable manifest generation", "FALSE", 0},
{"LinkIncremental", "INCREMENTAL:NO", "link incremental", "1"}, {"GenerateManifest", "MANIFEST", "enable manifest generation", "TRUE", 0},
{"LinkIncremental", "INCREMENTAL:YES", "link incremental", "2"}, {"LinkIncremental", "INCREMENTAL:NO", "link incremental", "1", 0},
{"IgnoreDefaultLibraryNames", "NODEFAULTLIB:", "default libs to ignore", {"LinkIncremental", "INCREMENTAL:YES", "link incremental", "2", 0},
CMFLAG_USER_VALUE}, {"IgnoreDefaultLibraryNames", "NODEFAULTLIB:", "default libs to ignore", "",
cmVS7FlagTable::UserValue},
{"IgnoreAllDefaultLibraries", "NODEFAULTLIB", "ignore all default libs", {"IgnoreAllDefaultLibraries", "NODEFAULTLIB", "ignore all default libs",
"TRUE"}, "TRUE", 0},
{0,0,0,0 } {0,0,0,0,0}
}; };
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -1790,25 +1821,56 @@ void cmLocalVisualStudio7GeneratorOptions::HandleFlag(const char* flag)
else if(this->FlagTable) else if(this->FlagTable)
{ {
// Look for an entry in the flag table matching this flag. // Look for an entry in the flag table matching this flag.
bool flag_handled = false;
for(cmVS7FlagTable const* entry = this->FlagTable; for(cmVS7FlagTable const* entry = this->FlagTable;
entry->IDEName; ++entry) entry->IDEName; ++entry)
{ {
if(entry->value == CMFLAG_USER_VALUE) bool entry_found = false;
if(entry->special & cmVS7FlagTable::UserValue)
{ {
// This flag table entry accepts a user value. // This flag table entry accepts a user-specified value. If
// the entry specifies UserRequired we must match only if a
// non-empty value is given.
int n = static_cast<int>(strlen(entry->commandFlag)); int n = static_cast<int>(strlen(entry->commandFlag));
if(strncmp(flag+1, entry->commandFlag, n) == 0) if(strncmp(flag+1, entry->commandFlag, n) == 0 &&
(!(entry->special & cmVS7FlagTable::UserRequired) ||
static_cast<int>(strlen(flag+1)) > n))
{ {
this->FlagMap[entry->IDEName] = flag+1+n; if(entry->special & cmVS7FlagTable::UserIgnored)
return; {
// Ignore the user-specified value.
this->FlagMap[entry->IDEName] = entry->value;
}
else
{
// Use the user-specified value.
this->FlagMap[entry->IDEName] = flag+1+n;
}
entry_found = true;
} }
} }
else if(strcmp(flag+1, entry->commandFlag) == 0) else if(strcmp(flag+1, entry->commandFlag) == 0)
{ {
// This flag table entry provides a fixed value. // This flag table entry provides a fixed value.
this->FlagMap[entry->IDEName] = entry->value; this->FlagMap[entry->IDEName] = entry->value;
entry_found = true;
}
// If the flag has been handled by an entry not requesting a
// search continuation we are done.
if(entry_found && !(entry->special & cmVS7FlagTable::Continue))
{
return; return;
} }
// If the entry was found the flag has been handled.
flag_handled |= entry_found;
}
// If any map entry handled the flag we are done.
if(flag_handled)
{
return;
} }
} }
} }