Commit 0c08da99 authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'watcom-link-quoting'

cb9b1e13 Watcom: Use single quote for all file/path items in wlink command
parents 6736b3e7 cb9b1e13
......@@ -51,7 +51,7 @@ set(CMAKE_C_CREATE_IMPORT_LIBRARY
set(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY})
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})
......@@ -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}")
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>" ""
CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
......
......@@ -689,6 +689,7 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang,
std::string createRule = "CMAKE_";
createRule += llang;
createRule += target.GetCreateRuleVariable();
bool useWatcomQuote = this->Makefile->IsOn(createRule+"_USE_WATCOM_QUOTE");
std::string targetName = target.Target->GetFullName();
// Executable :
// Shared Library:
......@@ -700,7 +701,7 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang,
std::string flags; // should be set
std::string linkFlags; // should be set
this->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
&target);
&target, useWatcomQuote);
linkLibs = frameworkPath + linkPath + linkLibs;
cmLocalGenerator::RuleVariables vars;
vars.Language = llang.c_str();
......@@ -1611,7 +1612,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
std::string& linkFlags,
std::string& frameworkPath,
std::string& linkPath,
cmGeneratorTarget* target)
cmGeneratorTarget* target,
bool useWatcomQuote)
{
std::string buildType =
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
......@@ -1675,7 +1677,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
}
}
this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
*target, false, false);
*target, false, false, useWatcomQuote);
}
break;
case cmTarget::EXECUTABLE:
......@@ -1700,7 +1702,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
}
this->AddLanguageFlags(flags, linkLanguage, buildType);
this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
*target, false, false);
*target, false, false, useWatcomQuote);
if(cmSystemTools::IsOn
(this->Makefile->GetDefinition("BUILD_SHARED_LIBS")))
{
......@@ -1759,9 +1761,8 @@ std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib,
OutputFormat format)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
// Work-ardound command line parsing limitations in MSVC 6.0 and
// Watcom.
if(this->Makefile->IsOn("MSVC60") || this->Makefile->IsOn("WATCOM"))
// Work-ardound command line parsing limitations in MSVC 6.0
if(this->Makefile->IsOn("MSVC60"))
{
// Search for the last space.
std::string::size_type pos = lib.rfind(' ');
......@@ -1798,9 +1799,11 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
std::string& linkPath,
cmGeneratorTarget &tgt,
bool relink,
bool forResponseFile)
bool forResponseFile,
bool useWatcomQuote)
{
OutputFormat shellFormat = forResponseFile? RESPONSE : SHELL;
OutputFormat shellFormat = (forResponseFile) ? RESPONSE :
((useWatcomQuote) ? WATCOMQUOTE : SHELL);
bool escapeAllowMakeVars = !forResponseFile;
cmOStringStream fout;
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());
}
else if( output == SHELL)
else if(output == SHELL || output == WATCOMQUOTE)
{
// For the MSYS shell convert drive letters to posix paths, so
// 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++;
}
}
result = this->EscapeForShell(result, true, false);
result = this->EscapeForShell(result, true, false, output == WATCOMQUOTE);
}
else if(output == RESPONSE)
{
result = this->EscapeForShell(result, false, false);
result = this->EscapeForShell(result, false, false, false);
}
return result;
}
......@@ -3247,7 +3250,8 @@ static bool cmLocalGeneratorIsShellOperator(const std::string& str)
//----------------------------------------------------------------------------
std::string cmLocalGenerator::EscapeForShell(const std::string& str,
bool makeVars,
bool forEcho)
bool forEcho,
bool useWatcomQuote)
{
// Do not escape shell operators.
if(cmLocalGeneratorIsShellOperator(str))
......@@ -3273,6 +3277,10 @@ std::string cmLocalGenerator::EscapeForShell(const std::string& str,
{
flags |= cmsysSystem_Shell_Flag_EchoWindows;
}
if(useWatcomQuote)
{
flags |= cmsysSystem_Shell_Flag_WatcomQuote;
}
if(this->WatcomWMake)
{
flags |= cmsysSystem_Shell_Flag_WatcomWMake;
......
......@@ -106,7 +106,7 @@ public:
* path setting
*/
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,
OutputFormat output);
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
command. */
std::string EscapeForShell(const std::string& str, bool makeVars = false,
bool forEcho = false);
bool forEcho = false,
bool useWatcomQuote = false);
/** Backwards-compatibility version of EscapeForShell. */
std::string EscapeForShellOldStyle(const std::string& str);
......@@ -370,7 +371,8 @@ public:
std::string& linkFlags,
std::string& frameworkPath,
std::string& linkPath,
cmGeneratorTarget* target);
cmGeneratorTarget* target,
bool useWatcomQuote);
virtual void ComputeObjectFilenames(
std::map<cmSourceFile const*, std::string>& mapping,
......@@ -383,7 +385,8 @@ protected:
std::string& linkPath,
cmGeneratorTarget &,
bool relink,
bool forResponseFile);
bool forResponseFile,
bool useWatcomQuote);
// Expand rule variables in CMake of the type found in language rules
void ExpandRuleVariables(std::string& string,
......
......@@ -290,7 +290,6 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
linkRuleVar += linkLanguage;
linkRuleVar += "_LINK_EXECUTABLE";
std::string linkRule = this->GetLinkRule(linkRuleVar);
bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE");
std::vector<std::string> commands1;
cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
if(this->Target->IsExecutableWithExports())
......@@ -333,12 +332,15 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Expand the rule variables.
{
bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE");
// Set path conversion for link script shells.
this->LocalGenerator->SetLinkScriptShell(useLinkScript);
// Collect up flags to link in needed libraries.
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
// rule.
......@@ -357,7 +359,12 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
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();
// Setup the target version.
......
......@@ -458,8 +458,6 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
this->Target);
}
bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE");
// Determine whether a link script will be used.
bool useLinkScript = this->GlobalGenerator->GetUseLinkScript();
......@@ -541,6 +539,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// Expand the rule variables.
std::vector<std::string> real_link_commands;
{
bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE");
// Set path conversion for link script shells.
this->LocalGenerator->SetLinkScriptShell(useLinkScript);
......@@ -548,7 +548,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string linkLibs;
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
......@@ -587,7 +588,12 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
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.ObjectsQuoted = buildObjs.c_str();
if (this->Target->HasSOName(this->ConfigName))
......
......@@ -1826,14 +1826,16 @@ void
cmMakefileTargetGenerator
::CreateLinkLibs(std::string& linkLibs, bool relink,
bool useResponseFile,
std::vector<std::string>& makefile_depends)
std::vector<std::string>& makefile_depends,
bool useWatcomQuote)
{
std::string frameworkPath;
std::string linkPath;
this->LocalGenerator
->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
*this->GeneratorTarget, relink,
useResponseFile);
useResponseFile,
useWatcomQuote);
linkLibs = frameworkPath + linkPath + linkLibs;
if(useResponseFile)
......
......@@ -168,7 +168,8 @@ protected:
/** Create list of flags for link libraries. */
void CreateLinkLibs(std::string& linkLibs, bool relink,
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. */
void CreateObjectLists(bool useLinkScript, bool useArchiveRules,
......
......@@ -439,12 +439,18 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
std::string frameworkPath;
std::string linkPath;
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"],
vars["FLAGS"],
vars["LINK_FLAGS"],
frameworkPath,
linkPath,
gtarget);
gtarget,
useWatcomQuote);
this->addPoolNinjaVariable("JOB_POOL_LINK", this->GetTarget(), vars);
......
......@@ -600,7 +600,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
gg->CreateGeneratorTargets(mf);
cmGeneratorTarget *gtgt = gg->GetGeneratorTarget(tgt);
lg->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
gtgt);
gtgt, false);
linkLibs = frameworkPath + linkPath + linkLibs;
printf("%s\n", linkLibs.c_str() );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment