Watcom: Use single quote for all file/path items in wlink command

Watcom Linker use single quote if necessary for quoting target name,
libraries names and libraries search path.  Object names were already
fixed.
This commit is contained in:
Jiri Malak 2014-04-04 23:06:13 +02:00 committed by Brad King
parent 9b1abc543e
commit cb9b1e13e4
9 changed files with 64 additions and 31 deletions

View File

@ -51,7 +51,7 @@ set(CMAKE_C_CREATE_IMPORT_LIBRARY
set(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY}) set(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY})
set(CMAKE_C_LINK_EXECUTABLE set(CMAKE_C_LINK_EXECUTABLE
"wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' <LINK_FLAGS> file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name <TARGET> <LINK_FLAGS> file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
set(CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE}) set(CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE})
@ -73,7 +73,7 @@ set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE
"<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -d+ <DEFINES> -fo<PREPROCESSED_SOURCE> -pl -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}") "<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -d+ <DEFINES> -fo<PREPROCESSED_SOURCE> -pl -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}")
set(CMAKE_CXX_CREATE_SHARED_LIBRARY set(CMAKE_CXX_CREATE_SHARED_LIBRARY
"wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' <LINK_FLAGS> option implib=<TARGET_IMPLIB> file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name <TARGET> <LINK_FLAGS> option implib=<TARGET_IMPLIB> file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
string(REPLACE " option implib=<TARGET_IMPLIB>" "" string(REPLACE " option implib=<TARGET_IMPLIB>" ""
CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_LIBRARY}") CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")

View File

@ -689,6 +689,7 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang,
std::string createRule = "CMAKE_"; std::string createRule = "CMAKE_";
createRule += llang; createRule += llang;
createRule += target.GetCreateRuleVariable(); createRule += target.GetCreateRuleVariable();
bool useWatcomQuote = this->Makefile->IsOn(createRule+"_USE_WATCOM_QUOTE");
std::string targetName = target.Target->GetFullName(); std::string targetName = target.Target->GetFullName();
// Executable : // Executable :
// Shared Library: // Shared Library:
@ -700,7 +701,7 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang,
std::string flags; // should be set std::string flags; // should be set
std::string linkFlags; // should be set std::string linkFlags; // should be set
this->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags, this->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
&target); &target, useWatcomQuote);
linkLibs = frameworkPath + linkPath + linkLibs; linkLibs = frameworkPath + linkPath + linkLibs;
cmLocalGenerator::RuleVariables vars; cmLocalGenerator::RuleVariables vars;
vars.Language = llang.c_str(); vars.Language = llang.c_str();
@ -1611,7 +1612,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
std::string& linkFlags, std::string& linkFlags,
std::string& frameworkPath, std::string& frameworkPath,
std::string& linkPath, std::string& linkPath,
cmGeneratorTarget* target) cmGeneratorTarget* target,
bool useWatcomQuote)
{ {
std::string buildType = std::string buildType =
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
@ -1675,7 +1677,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
} }
} }
this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
*target, false, false); *target, false, false, useWatcomQuote);
} }
break; break;
case cmTarget::EXECUTABLE: case cmTarget::EXECUTABLE:
@ -1700,7 +1702,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
} }
this->AddLanguageFlags(flags, linkLanguage, buildType); this->AddLanguageFlags(flags, linkLanguage, buildType);
this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
*target, false, false); *target, false, false, useWatcomQuote);
if(cmSystemTools::IsOn if(cmSystemTools::IsOn
(this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) (this->Makefile->GetDefinition("BUILD_SHARED_LIBS")))
{ {
@ -1759,9 +1761,8 @@ std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib,
OutputFormat format) OutputFormat format)
{ {
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
// Work-ardound command line parsing limitations in MSVC 6.0 and // Work-ardound command line parsing limitations in MSVC 6.0
// Watcom. if(this->Makefile->IsOn("MSVC60"))
if(this->Makefile->IsOn("MSVC60") || this->Makefile->IsOn("WATCOM"))
{ {
// Search for the last space. // Search for the last space.
std::string::size_type pos = lib.rfind(' '); std::string::size_type pos = lib.rfind(' ');
@ -1798,9 +1799,11 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
std::string& linkPath, std::string& linkPath,
cmGeneratorTarget &tgt, cmGeneratorTarget &tgt,
bool relink, bool relink,
bool forResponseFile) bool forResponseFile,
bool useWatcomQuote)
{ {
OutputFormat shellFormat = forResponseFile? RESPONSE : SHELL; OutputFormat shellFormat = (forResponseFile) ? RESPONSE :
((useWatcomQuote) ? WATCOMQUOTE : SHELL);
bool escapeAllowMakeVars = !forResponseFile; bool escapeAllowMakeVars = !forResponseFile;
cmOStringStream fout; cmOStringStream fout;
const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
@ -2594,7 +2597,7 @@ std::string cmLocalGenerator::ConvertToOutputFormat(const std::string& source,
{ {
result = cmSystemTools::ConvertToOutputPath(result.c_str()); result = cmSystemTools::ConvertToOutputPath(result.c_str());
} }
else if( output == SHELL) else if(output == SHELL || output == WATCOMQUOTE)
{ {
// For the MSYS shell convert drive letters to posix paths, so // For the MSYS shell convert drive letters to posix paths, so
// that c:/some/path becomes /c/some/path. This is needed to // that c:/some/path becomes /c/some/path. This is needed to
@ -2616,11 +2619,11 @@ std::string cmLocalGenerator::ConvertToOutputFormat(const std::string& source,
pos++; pos++;
} }
} }
result = this->EscapeForShell(result, true, false); result = this->EscapeForShell(result, true, false, output == WATCOMQUOTE);
} }
else if(output == RESPONSE) else if(output == RESPONSE)
{ {
result = this->EscapeForShell(result, false, false); result = this->EscapeForShell(result, false, false, false);
} }
return result; return result;
} }
@ -3247,7 +3250,8 @@ static bool cmLocalGeneratorIsShellOperator(const std::string& str)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmLocalGenerator::EscapeForShell(const std::string& str, std::string cmLocalGenerator::EscapeForShell(const std::string& str,
bool makeVars, bool makeVars,
bool forEcho) bool forEcho,
bool useWatcomQuote)
{ {
// Do not escape shell operators. // Do not escape shell operators.
if(cmLocalGeneratorIsShellOperator(str)) if(cmLocalGeneratorIsShellOperator(str))
@ -3273,6 +3277,10 @@ std::string cmLocalGenerator::EscapeForShell(const std::string& str,
{ {
flags |= cmsysSystem_Shell_Flag_EchoWindows; flags |= cmsysSystem_Shell_Flag_EchoWindows;
} }
if(useWatcomQuote)
{
flags |= cmsysSystem_Shell_Flag_WatcomQuote;
}
if(this->WatcomWMake) if(this->WatcomWMake)
{ {
flags |= cmsysSystem_Shell_Flag_WatcomWMake; flags |= cmsysSystem_Shell_Flag_WatcomWMake;

View File

@ -106,7 +106,7 @@ public:
* path setting * path setting
*/ */
enum RelativeRoot { NONE, FULL, HOME, START, HOME_OUTPUT, START_OUTPUT }; enum RelativeRoot { NONE, FULL, HOME, START, HOME_OUTPUT, START_OUTPUT };
enum OutputFormat { UNCHANGED, MAKEFILE, SHELL, RESPONSE }; enum OutputFormat { UNCHANGED, MAKEFILE, SHELL, WATCOMQUOTE, RESPONSE };
std::string ConvertToOutputFormat(const std::string& source, std::string ConvertToOutputFormat(const std::string& source,
OutputFormat output); OutputFormat output);
std::string Convert(const std::string& remote, RelativeRoot local, std::string Convert(const std::string& remote, RelativeRoot local,
@ -288,7 +288,8 @@ public:
escapes for the special case of passing to the native echo escapes for the special case of passing to the native echo
command. */ command. */
std::string EscapeForShell(const std::string& str, bool makeVars = false, std::string EscapeForShell(const std::string& str, bool makeVars = false,
bool forEcho = false); bool forEcho = false,
bool useWatcomQuote = false);
/** Backwards-compatibility version of EscapeForShell. */ /** Backwards-compatibility version of EscapeForShell. */
std::string EscapeForShellOldStyle(const std::string& str); std::string EscapeForShellOldStyle(const std::string& str);
@ -370,7 +371,8 @@ public:
std::string& linkFlags, std::string& linkFlags,
std::string& frameworkPath, std::string& frameworkPath,
std::string& linkPath, std::string& linkPath,
cmGeneratorTarget* target); cmGeneratorTarget* target,
bool useWatcomQuote);
virtual void ComputeObjectFilenames( virtual void ComputeObjectFilenames(
std::map<cmSourceFile const*, std::string>& mapping, std::map<cmSourceFile const*, std::string>& mapping,
@ -383,7 +385,8 @@ protected:
std::string& linkPath, std::string& linkPath,
cmGeneratorTarget &, cmGeneratorTarget &,
bool relink, bool relink,
bool forResponseFile); bool forResponseFile,
bool useWatcomQuote);
// Expand rule variables in CMake of the type found in language rules // Expand rule variables in CMake of the type found in language rules
void ExpandRuleVariables(std::string& string, void ExpandRuleVariables(std::string& string,

View File

@ -290,7 +290,6 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
linkRuleVar += linkLanguage; linkRuleVar += linkLanguage;
linkRuleVar += "_LINK_EXECUTABLE"; linkRuleVar += "_LINK_EXECUTABLE";
std::string linkRule = this->GetLinkRule(linkRuleVar); std::string linkRule = this->GetLinkRule(linkRuleVar);
bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE");
std::vector<std::string> commands1; std::vector<std::string> commands1;
cmSystemTools::ExpandListArgument(linkRule, real_link_commands); cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
if(this->Target->IsExecutableWithExports()) if(this->Target->IsExecutableWithExports())
@ -333,12 +332,15 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Expand the rule variables. // Expand the rule variables.
{ {
bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE");
// Set path conversion for link script shells. // Set path conversion for link script shells.
this->LocalGenerator->SetLinkScriptShell(useLinkScript); this->LocalGenerator->SetLinkScriptShell(useLinkScript);
// Collect up flags to link in needed libraries. // Collect up flags to link in needed libraries.
std::string linkLibs; std::string linkLibs;
this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends); this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends,
useWatcomQuote);
// Construct object file lists that may be needed to expand the // Construct object file lists that may be needed to expand the
// rule. // rule.
@ -357,7 +359,12 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
cmLocalGenerator::START_OUTPUT, cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL); cmLocalGenerator::SHELL);
vars.ObjectDir = objectDir.c_str(); vars.ObjectDir = objectDir.c_str();
vars.Target = targetOutPathReal.c_str(); cmLocalGenerator::OutputFormat output = (useWatcomQuote) ?
cmLocalGenerator::WATCOMQUOTE : cmLocalGenerator::SHELL;
std::string target = this->Convert(targetFullPathReal,
cmLocalGenerator::START_OUTPUT,
output);
vars.Target = target.c_str();
vars.TargetPDB = targetOutPathPDB.c_str(); vars.TargetPDB = targetOutPathPDB.c_str();
// Setup the target version. // Setup the target version.

View File

@ -458,8 +458,6 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
this->Target); this->Target);
} }
bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE");
// Determine whether a link script will be used. // Determine whether a link script will be used.
bool useLinkScript = this->GlobalGenerator->GetUseLinkScript(); bool useLinkScript = this->GlobalGenerator->GetUseLinkScript();
@ -541,6 +539,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// Expand the rule variables. // Expand the rule variables.
std::vector<std::string> real_link_commands; std::vector<std::string> real_link_commands;
{ {
bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE");
// Set path conversion for link script shells. // Set path conversion for link script shells.
this->LocalGenerator->SetLinkScriptShell(useLinkScript); this->LocalGenerator->SetLinkScriptShell(useLinkScript);
@ -548,7 +548,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string linkLibs; std::string linkLibs;
if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
{ {
this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends); this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends,
useWatcomQuote);
} }
// Construct object file lists that may be needed to expand the // Construct object file lists that may be needed to expand the
@ -587,7 +588,12 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
cmLocalGenerator::START_OUTPUT, cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL); cmLocalGenerator::SHELL);
vars.ObjectDir = objectDir.c_str(); vars.ObjectDir = objectDir.c_str();
vars.Target = targetOutPathReal.c_str(); cmLocalGenerator::OutputFormat output = (useWatcomQuote) ?
cmLocalGenerator::WATCOMQUOTE : cmLocalGenerator::SHELL;
std::string target = this->Convert(targetFullPathReal,
cmLocalGenerator::START_OUTPUT,
output);
vars.Target = target.c_str();
vars.LinkLibraries = linkLibs.c_str(); vars.LinkLibraries = linkLibs.c_str();
vars.ObjectsQuoted = buildObjs.c_str(); vars.ObjectsQuoted = buildObjs.c_str();
if (this->Target->HasSOName(this->ConfigName)) if (this->Target->HasSOName(this->ConfigName))

View File

@ -1826,14 +1826,16 @@ void
cmMakefileTargetGenerator cmMakefileTargetGenerator
::CreateLinkLibs(std::string& linkLibs, bool relink, ::CreateLinkLibs(std::string& linkLibs, bool relink,
bool useResponseFile, bool useResponseFile,
std::vector<std::string>& makefile_depends) std::vector<std::string>& makefile_depends,
bool useWatcomQuote)
{ {
std::string frameworkPath; std::string frameworkPath;
std::string linkPath; std::string linkPath;
this->LocalGenerator this->LocalGenerator
->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
*this->GeneratorTarget, relink, *this->GeneratorTarget, relink,
useResponseFile); useResponseFile,
useWatcomQuote);
linkLibs = frameworkPath + linkPath + linkLibs; linkLibs = frameworkPath + linkPath + linkLibs;
if(useResponseFile) if(useResponseFile)

View File

@ -168,7 +168,8 @@ protected:
/** Create list of flags for link libraries. */ /** Create list of flags for link libraries. */
void CreateLinkLibs(std::string& linkLibs, bool relink, void CreateLinkLibs(std::string& linkLibs, bool relink,
bool useResponseFile, bool useResponseFile,
std::vector<std::string>& makefile_depends); std::vector<std::string>& makefile_depends,
bool useWatcomQuote);
/** Create lists of object files for linking and cleaning. */ /** Create lists of object files for linking and cleaning. */
void CreateObjectLists(bool useLinkScript, bool useArchiveRules, void CreateObjectLists(bool useLinkScript, bool useArchiveRules,

View File

@ -439,12 +439,18 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
std::string frameworkPath; std::string frameworkPath;
std::string linkPath; std::string linkPath;
cmGeneratorTarget* gtarget = this->GetGeneratorTarget(); cmGeneratorTarget* gtarget = this->GetGeneratorTarget();
std::string createRule = "CMAKE_";
createRule += this->TargetLinkLanguage;
createRule += gtarget->GetCreateRuleVariable();
bool useWatcomQuote = mf->IsOn(createRule+"_USE_WATCOM_QUOTE");
this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"], this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"],
vars["FLAGS"], vars["FLAGS"],
vars["LINK_FLAGS"], vars["LINK_FLAGS"],
frameworkPath, frameworkPath,
linkPath, linkPath,
gtarget); gtarget,
useWatcomQuote);
this->addPoolNinjaVariable("JOB_POOL_LINK", this->GetTarget(), vars); this->addPoolNinjaVariable("JOB_POOL_LINK", this->GetTarget(), vars);

View File

@ -600,7 +600,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
gg->CreateGeneratorTargets(mf); gg->CreateGeneratorTargets(mf);
cmGeneratorTarget *gtgt = gg->GetGeneratorTarget(tgt); cmGeneratorTarget *gtgt = gg->GetGeneratorTarget(tgt);
lg->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags, lg->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
gtgt); gtgt, false);
linkLibs = frameworkPath + linkPath + linkLibs; linkLibs = frameworkPath + linkPath + linkLibs;
printf("%s\n", linkLibs.c_str() ); printf("%s\n", linkLibs.c_str() );