ENH: Adding support for # escape in Watcom WMake.

This commit is contained in:
Brad King 2006-10-25 11:23:04 -04:00
parent 9e29a742a9
commit 54731fa2c8
6 changed files with 49 additions and 5 deletions

View File

@ -50,6 +50,7 @@ cmLocalGenerator *cmGlobalWatcomWMakeGenerator::CreateLocalGenerator()
lg->SetSilentNoColon(true); lg->SetSilentNoColon(true);
lg->SetDefineWindowsNULL(true); lg->SetDefineWindowsNULL(true);
lg->SetWindowsShell(true); lg->SetWindowsShell(true);
lg->SetWatcomWMake(true);
lg->SetMakeSilentFlag("-s -h"); lg->SetMakeSilentFlag("-s -h");
lg->SetGlobalGenerator(this); lg->SetGlobalGenerator(this);
lg->SetIgnoreLibPrefix(true); lg->SetIgnoreLibPrefix(true);

View File

@ -40,6 +40,7 @@ cmLocalGenerator::cmLocalGenerator()
this->Parent = 0; this->Parent = 0;
this->WindowsShell = false; this->WindowsShell = false;
this->WindowsVSIDE = false; this->WindowsVSIDE = false;
this->WatcomWMake = false;
this->MSYSShell = false; this->MSYSShell = false;
this->IgnoreLibPrefix = false; this->IgnoreLibPrefix = false;
this->UseRelativePaths = false; this->UseRelativePaths = false;
@ -2348,6 +2349,10 @@ std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars,
{ {
flags |= cmsysSystem_Shell_Flag_EchoWindows; flags |= cmsysSystem_Shell_Flag_EchoWindows;
} }
if(this->WatcomWMake)
{
flags |= cmsysSystem_Shell_Flag_WatcomWMake;
}
// Compute the buffer size needed. // Compute the buffer size needed.
int size = (this->WindowsShell ? int size = (this->WindowsShell ?

View File

@ -278,6 +278,7 @@ protected:
std::map<cmStdString, cmStdString> UniqueObjectNamesMap; std::map<cmStdString, cmStdString> UniqueObjectNamesMap;
bool WindowsShell; bool WindowsShell;
bool WindowsVSIDE; bool WindowsVSIDE;
bool WatcomWMake;
bool ForceUnixPath; bool ForceUnixPath;
bool MSYSShell; bool MSYSShell;
bool UseRelativePaths; bool UseRelativePaths;

View File

@ -104,6 +104,11 @@ public:
*/ */
void SetWindowsShell(bool v) {this->WindowsShell = v;} void SetWindowsShell(bool v) {this->WindowsShell = v;}
/**
* Set to true if the make tool being used is Watcom WMake.
*/
void SetWatcomWMake(bool v) {this->WatcomWMake = v;}
/** /**
* Set to true if the shell being used is the MSYS shell. * Set to true if the shell being used is the MSYS shell.
* This controls if statements in the makefile and the SHELL variable. * This controls if statements in the makefile and the SHELL variable.

View File

@ -222,7 +222,7 @@ static int kwsysSystem_Shell__GetArgumentSize(const char* in,
} }
} }
/* Check whether this character needs escaping. */ /* Check whether this character needs escaping for the shell. */
if(isUnix) if(isUnix)
{ {
/* On Unix a few special characters need escaping even inside a /* On Unix a few special characters need escaping even inside a
@ -261,7 +261,7 @@ static int kwsysSystem_Shell__GetArgumentSize(const char* in,
} }
} }
/* The dollar sign needs special handling in some environments. */ /* Check whether this character needs escaping for a make tool. */
if(*c == '$') if(*c == '$')
{ {
if(flags & kwsysSystem_Shell_Flag_Make) if(flags & kwsysSystem_Shell_Flag_Make)
@ -277,6 +277,16 @@ static int kwsysSystem_Shell__GetArgumentSize(const char* in,
size += 2; size += 2;
} }
} }
else if(*c == '#')
{
if((flags & kwsysSystem_Shell_Flag_Make) &&
(flags & kwsysSystem_Shell_Flag_WatcomWMake))
{
/* In Watcom WMake makefiles a pound is written $# so we need
one extra character. */
++size;
}
}
} }
/* Check whether the argument needs surrounding quotes. */ /* Check whether the argument needs surrounding quotes. */
@ -333,7 +343,7 @@ static char* kwsysSystem_Shell__GetArgument(const char* in, char* out,
} }
} }
/* Check whether this character needs escaping. */ /* Check whether this character needs escaping for the shell. */
if(isUnix) if(isUnix)
{ {
/* On Unix a few special characters need escaping even inside a /* On Unix a few special characters need escaping even inside a
@ -377,7 +387,7 @@ static char* kwsysSystem_Shell__GetArgument(const char* in, char* out,
} }
} }
/* The dollar sign needs special handling in some environments. */ /* Check whether this character needs escaping for a make tool. */
if(*c == '$') if(*c == '$')
{ {
if(flags & kwsysSystem_Shell_Flag_Make) if(flags & kwsysSystem_Shell_Flag_Make)
@ -405,6 +415,23 @@ static char* kwsysSystem_Shell__GetArgument(const char* in, char* out,
*out++ = '$'; *out++ = '$';
} }
} }
else if(*c == '#')
{
if((flags & kwsysSystem_Shell_Flag_Make) &&
(flags & kwsysSystem_Shell_Flag_WatcomWMake))
{
/* In Watcom WMake makefiles a pound is written $#. The make
tool will replace it with just # before passing it to the
shell. */
*out++ = '$';
*out++ = '#';
}
else
{
/* Otherwise a pound is written just #. */
*out++ = '#';
}
}
else else
{ {
/* Store this character. */ /* Store this character. */

View File

@ -32,6 +32,7 @@
#define kwsysSystem_Shell_Flag_Make kwsys_ns(System_Shell_Flag_Make) #define kwsysSystem_Shell_Flag_Make kwsys_ns(System_Shell_Flag_Make)
#define kwsysSystem_Shell_Flag_VSIDE kwsys_ns(System_Shell_Flag_VSIDE) #define kwsysSystem_Shell_Flag_VSIDE kwsys_ns(System_Shell_Flag_VSIDE)
#define kwsysSystem_Shell_Flag_EchoWindows kwsys_ns(System_Shell_Flag_EchoWindows) #define kwsysSystem_Shell_Flag_EchoWindows kwsys_ns(System_Shell_Flag_EchoWindows)
#define kwsysSystem_Shell_Flag_WatcomWMake kwsys_ns(System_Shell_Flag_WatcomWMake)
#define kwsysSystem_Shell_Flag_AllowMakeVariables kwsys_ns(System_Shell_Flag_AllowMakeVariables) #define kwsysSystem_Shell_Flag_AllowMakeVariables kwsys_ns(System_Shell_Flag_AllowMakeVariables)
#if defined(__cplusplus) #if defined(__cplusplus)
@ -82,12 +83,15 @@ enum kwsysSystem_Shell_Flag_e
/** In a windows whell the argument is being passed to "echo". */ /** In a windows whell the argument is being passed to "echo". */
kwsysSystem_Shell_Flag_EchoWindows = (1<<2), kwsysSystem_Shell_Flag_EchoWindows = (1<<2),
/** The target shell is in a Watcom WMake makefile. */
kwsysSystem_Shell_Flag_WatcomWMake = (1<<3),
/** Make variable reference syntax $(MAKEVAR) should not be escaped /** Make variable reference syntax $(MAKEVAR) should not be escaped
to allow a build tool to replace it. Replacement values to allow a build tool to replace it. Replacement values
containing spaces, quotes, backslashes, or other containing spaces, quotes, backslashes, or other
non-alphanumeric characters that have significance to some makes non-alphanumeric characters that have significance to some makes
or shells produce undefined behavior. */ or shells produce undefined behavior. */
kwsysSystem_Shell_Flag_AllowMakeVariables = (1<<3) kwsysSystem_Shell_Flag_AllowMakeVariables = (1<<4)
}; };
#if defined(__cplusplus) #if defined(__cplusplus)
@ -107,6 +111,7 @@ enum kwsysSystem_Shell_Flag_e
# undef kwsysSystem_Shell_Flag_Make # undef kwsysSystem_Shell_Flag_Make
# undef kwsysSystem_Shell_Flag_VSIDE # undef kwsysSystem_Shell_Flag_VSIDE
# undef kwsysSystem_Shell_Flag_EchoWindows # undef kwsysSystem_Shell_Flag_EchoWindows
# undef kwsysSystem_Shell_Flag_WatcomWMake
# undef kwsysSystem_Shell_Flag_AllowMakeVariables # undef kwsysSystem_Shell_Flag_AllowMakeVariables
#endif #endif