Merge topic 'cleanup-Convert'

4332131d Convert: Make variables a bit more clear
5aca066c Convert: Remove UNCHANGED enum value
146bf926 Convert: Remove 'FULL' conversion
58ba87f8 Convert: Replace Convert(FULL) with equivalent
e80314d7 Ninja: Replace ternary with if()
563ac22a Convert: Replace trivial conversion with new method
08be47cf Convert: Replace UNCHANGED conversions with new API call
564d3a1d Convert: Extract ConvertToRelativePath from Convert()
95a659f1 Convert: Replace FULL conversions with equivalent
a8c7ccb1 VS: Replace FULL/UNCHANGED conversion with equivalent
5ad25ef4 Convert: Remove NONE conversion
ac463841 Convert: Replace uses of Convert(NONE)
998d9ee9 VS: Replace variable with an if()
ee49f006 Makefiles: Replace ternaries with if()s
51f7dcb0 Makefiles: Inline MakeLauncher into only caller
ba4ba7c3 Makefiles: Simplify MakeLauncher return value
...
This commit is contained in:
Brad King 2016-08-30 09:29:53 -04:00 committed by CMake Topic Stage
commit e3a4c2e02c
25 changed files with 346 additions and 387 deletions

View File

@ -57,9 +57,9 @@ protected:
// The windows module definition source file (.def), if any. // The windows module definition source file (.def), if any.
cmSourceFile const* ModuleDefinitionFile; cmSourceFile const* ModuleDefinitionFile;
std::string Convert( std::string Convert(std::string const& source,
std::string const& source, cmOutputConverter::RelativeRoot relative, cmOutputConverter::RelativeRoot relative,
cmOutputConverter::OutputFormat output = cmOutputConverter::UNCHANGED); cmOutputConverter::OutputFormat output);
void AppendFortranFormatFlags(std::string& flags, void AppendFortranFormatFlags(std::string& flags,
cmSourceFile const& source); cmSourceFile const& source);

View File

@ -238,8 +238,8 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
// written by the original local generator for this directory // written by the original local generator for this directory
// convert the dependencies to paths relative to the home output // convert the dependencies to paths relative to the home output
// directory. We must do the same here. // directory. We must do the same here.
std::string obj_i = std::string obj_i = this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->Convert(obj, cmOutputConverter::HOME_OUTPUT); obj, cmOutputConverter::HOME_OUTPUT);
std::string obj_m = this->LocalGenerator->ConvertToOutputFormat( std::string obj_m = this->LocalGenerator->ConvertToOutputFormat(
obj_i, cmOutputConverter::MAKERULE); obj_i, cmOutputConverter::MAKERULE);
internalDepends << obj_i << std::endl; internalDepends << obj_i << std::endl;

View File

@ -193,15 +193,15 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
stamp += ".mod.stamp"; stamp += ".mod.stamp";
fcStream << "\n"; fcStream << "\n";
fcStream << " \"" fcStream << " \""
<< this->LocalGenerator->Convert( << this->LocalGenerator->ConvertToRelativePath(
mod_lower, cmOutputConverter::START_OUTPUT) mod_lower, cmOutputConverter::START_OUTPUT)
<< "\"\n"; << "\"\n";
fcStream << " \"" fcStream << " \""
<< this->LocalGenerator->Convert( << this->LocalGenerator->ConvertToRelativePath(
mod_upper, cmOutputConverter::START_OUTPUT) mod_upper, cmOutputConverter::START_OUTPUT)
<< "\"\n"; << "\"\n";
fcStream << " \"" fcStream << " \""
<< this->LocalGenerator->Convert( << this->LocalGenerator->ConvertToRelativePath(
stamp, cmOutputConverter::START_OUTPUT) stamp, cmOutputConverter::START_OUTPUT)
<< "\"\n"; << "\"\n";
} }
@ -317,8 +317,8 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
const char* src = info.Source.c_str(); const char* src = info.Source.c_str();
// Write the include dependencies to the output stream. // Write the include dependencies to the output stream.
std::string obj_i = std::string obj_i = this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->Convert(obj, cmOutputConverter::HOME_OUTPUT); obj, cmOutputConverter::HOME_OUTPUT);
std::string obj_m = this->LocalGenerator->ConvertToOutputFormat( std::string obj_m = this->LocalGenerator->ConvertToOutputFormat(
obj_i, cmOutputConverter::MAKERULE); obj_i, cmOutputConverter::MAKERULE);
internalDepends << obj_i << std::endl; internalDepends << obj_i << std::endl;

View File

@ -904,8 +904,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) { it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) {
const std::vector<cmGeneratorTarget*> targets = const std::vector<cmGeneratorTarget*> targets =
(*it)->GetGeneratorTargets(); (*it)->GetGeneratorTargets();
std::string subdir = (*it)->Convert((*it)->GetCurrentBinaryDirectory(), std::string subdir = (*it)->ConvertToRelativePath(
cmOutputConverter::HOME_OUTPUT); (*it)->GetCurrentBinaryDirectory(), cmOutputConverter::HOME_OUTPUT);
if (subdir == ".") { if (subdir == ".") {
subdir = ""; subdir = "";
} }

View File

@ -2547,8 +2547,8 @@ void cmGlobalGenerator::AddRuleHash(const std::vector<std::string>& outputs,
// Shorten the output name (in expected use case). // Shorten the output name (in expected use case).
cmOutputConverter converter(this->GetMakefiles()[0]->GetStateSnapshot()); cmOutputConverter converter(this->GetMakefiles()[0]->GetStateSnapshot());
std::string fname = std::string fname = converter.ConvertToRelativePath(
converter.Convert(outputs[0], cmOutputConverter::HOME_OUTPUT); outputs[0], cmOutputConverter::HOME_OUTPUT);
// Associate the hash with this output. // Associate the hash with this output.
this->RuleHashes[fname] = hash; this->RuleHashes[fname] = hash;

View File

@ -749,7 +749,8 @@ std::string cmGlobalNinjaGenerator::ConvertToNinjaPath(const std::string& path)
{ {
cmLocalNinjaGenerator* ng = cmLocalNinjaGenerator* ng =
static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]); static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]);
std::string convPath = ng->Convert(path, cmOutputConverter::HOME_OUTPUT); std::string convPath =
ng->ConvertToRelativePath(path, cmOutputConverter::HOME_OUTPUT);
convPath = this->NinjaOutputPath(convPath); convPath = this->NinjaOutputPath(convPath);
#ifdef _WIN32 #ifdef _WIN32
std::replace(convPath.begin(), convPath.end(), '/', '\\'); std::replace(convPath.begin(), convPath.end(), '/', '\\');
@ -762,7 +763,8 @@ std::string cmGlobalNinjaGenerator::ConvertToNinjaFolderRule(
{ {
cmLocalNinjaGenerator* ng = cmLocalNinjaGenerator* ng =
static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]); static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]);
std::string convPath = ng->Convert(path + "/all", cmOutputConverter::HOME); std::string convPath =
ng->ConvertToRelativePath(path + "/all", cmOutputConverter::HOME);
convPath = this->NinjaOutputPath(convPath); convPath = this->NinjaOutputPath(convPath);
#ifdef _WIN32 #ifdef _WIN32
std::replace(convPath.begin(), convPath.end(), '/', '\\'); std::replace(convPath.begin(), convPath.end(), '/', '\\');

View File

@ -311,11 +311,14 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
cmakefileStream cmakefileStream
<< "# The top level Makefile was generated from the following files:\n" << "# The top level Makefile was generated from the following files:\n"
<< "set(CMAKE_MAKEFILE_DEPENDS\n" << "set(CMAKE_MAKEFILE_DEPENDS\n"
<< " \"" << lg->Convert(cache, cmOutputConverter::START_OUTPUT) << "\"\n"; << " \""
<< lg->ConvertToRelativePath(cache, cmOutputConverter::START_OUTPUT)
<< "\"\n";
for (std::vector<std::string>::const_iterator i = lfiles.begin(); for (std::vector<std::string>::const_iterator i = lfiles.begin();
i != lfiles.end(); ++i) { i != lfiles.end(); ++i) {
cmakefileStream << " \"" cmakefileStream << " \""
<< lg->Convert(*i, cmOutputConverter::START_OUTPUT) << lg->ConvertToRelativePath(
*i, cmOutputConverter::START_OUTPUT)
<< "\"\n"; << "\"\n";
} }
cmakefileStream << " )\n\n"; cmakefileStream << " )\n\n";
@ -329,10 +332,12 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
cmakefileStream << "# The corresponding makefile is:\n" cmakefileStream << "# The corresponding makefile is:\n"
<< "set(CMAKE_MAKEFILE_OUTPUTS\n" << "set(CMAKE_MAKEFILE_OUTPUTS\n"
<< " \"" << " \""
<< lg->Convert(makefileName, cmOutputConverter::START_OUTPUT) << lg->ConvertToRelativePath(makefileName,
cmOutputConverter::START_OUTPUT)
<< "\"\n" << "\"\n"
<< " \"" << " \""
<< lg->Convert(check, cmOutputConverter::START_OUTPUT) << lg->ConvertToRelativePath(check,
cmOutputConverter::START_OUTPUT)
<< "\"\n"; << "\"\n";
cmakefileStream << " )\n\n"; cmakefileStream << " )\n\n";
@ -345,7 +350,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
for (std::vector<std::string>::const_iterator k = outfiles.begin(); for (std::vector<std::string>::const_iterator k = outfiles.begin();
k != outfiles.end(); ++k) { k != outfiles.end(); ++k) {
cmakefileStream << " \"" cmakefileStream << " \""
<< lg->Convert(*k, cmOutputConverter::HOME_OUTPUT) << lg->ConvertToRelativePath(
*k, cmOutputConverter::HOME_OUTPUT)
<< "\"\n"; << "\"\n";
} }
@ -358,7 +364,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
tmpStr += cmake::GetCMakeFilesDirectory(); tmpStr += cmake::GetCMakeFilesDirectory();
tmpStr += "/CMakeDirectoryInformation.cmake"; tmpStr += "/CMakeDirectoryInformation.cmake";
cmakefileStream << " \"" cmakefileStream << " \""
<< lg->Convert(tmpStr, cmOutputConverter::HOME_OUTPUT) << lg->ConvertToRelativePath(
tmpStr, cmOutputConverter::HOME_OUTPUT)
<< "\"\n"; << "\"\n";
} }
cmakefileStream << " )\n\n"; cmakefileStream << " )\n\n";
@ -519,7 +526,7 @@ void cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
tname += "/fast"; tname += "/fast";
} }
cmOutputConverter conv(mf->GetStateSnapshot()); cmOutputConverter conv(mf->GetStateSnapshot());
tname = conv.Convert(tname, cmOutputConverter::HOME_OUTPUT); tname = conv.ConvertToRelativePath(tname, cmOutputConverter::HOME_OUTPUT);
cmSystemTools::ConvertToOutputSlashes(tname); cmSystemTools::ConvertToOutputSlashes(tname);
makeCommand.push_back(tname); makeCommand.push_back(tname);
if (this->Makefiles.empty()) { if (this->Makefiles.empty()) {
@ -716,8 +723,9 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
std::ostringstream progCmd; std::ostringstream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start ";
// # in target // # in target
progCmd << lg->Convert(progress.Dir, cmOutputConverter::FULL, progCmd << lg->ConvertToOutputFormat(
cmOutputConverter::SHELL); cmSystemTools::CollapseFullPath(progress.Dir),
cmOutputConverter::SHELL);
// //
std::set<cmGeneratorTarget const*> emitted; std::set<cmGeneratorTarget const*> emitted;
progCmd << " " << this->CountProgressMarksInTarget(gtarget, emitted); progCmd << " " << this->CountProgressMarksInTarget(gtarget, emitted);
@ -729,8 +737,9 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
{ {
std::ostringstream progCmd; std::ostringstream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0 progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
progCmd << lg->Convert(progress.Dir, cmOutputConverter::FULL, progCmd << lg->ConvertToOutputFormat(
cmOutputConverter::SHELL); cmSystemTools::CollapseFullPath(progress.Dir),
cmOutputConverter::SHELL);
progCmd << " 0"; progCmd << " 0";
commands.push_back(progCmd.str()); commands.push_back(progCmd.str());
} }

View File

@ -385,7 +385,8 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
if (vcprojName) { if (vcprojName) {
cmLocalGenerator* lg = target->GetLocalGenerator(); cmLocalGenerator* lg = target->GetLocalGenerator();
std::string dir = lg->GetCurrentBinaryDirectory(); std::string dir = lg->GetCurrentBinaryDirectory();
dir = root->Convert(dir.c_str(), cmOutputConverter::START_OUTPUT); dir = root->ConvertToRelativePath(dir.c_str(),
cmOutputConverter::START_OUTPUT);
if (dir == ".") { if (dir == ".") {
dir = ""; // msbuild cannot handle ".\" prefix dir = ""; // msbuild cannot handle ".\" prefix
} }

View File

@ -402,7 +402,8 @@ void cmListFileBacktrace::PrintTitle(std::ostream& out) const
cmOutputConverter converter(this->Bottom); cmOutputConverter converter(this->Bottom);
cmListFileContext lfc = *this->Cur; cmListFileContext lfc = *this->Cur;
if (!this->Bottom.GetState()->GetIsInTryCompile()) { if (!this->Bottom.GetState()->GetIsInTryCompile()) {
lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME); lfc.FilePath =
converter.ConvertToRelativePath(lfc.FilePath, cmOutputConverter::HOME);
} }
out << (lfc.Line ? " at " : " in ") << lfc; out << (lfc.Line ? " at " : " in ") << lfc;
} }
@ -427,7 +428,8 @@ void cmListFileBacktrace::PrintCallStack(std::ostream& out) const
} }
cmListFileContext lfc = *i; cmListFileContext lfc = *i;
if (!this->Bottom.GetState()->GetIsInTryCompile()) { if (!this->Bottom.GetState()->GetIsInTryCompile()) {
lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME); lfc.FilePath =
converter.ConvertToRelativePath(lfc.FilePath, cmOutputConverter::HOME);
} }
out << " " << lfc << "\n"; out << " " << lfc << "\n";
} }

View File

@ -74,8 +74,7 @@ std::string cmLocalCommonGenerator::GetTargetFortranFlags(
for (std::vector<std::string>::const_iterator idi = includes.begin(); for (std::vector<std::string>::const_iterator idi = includes.begin();
idi != includes.end(); ++idi) { idi != includes.end(); ++idi) {
std::string flg = modpath_flag; std::string flg = modpath_flag;
flg += flg += this->ConvertToOutputFormat(*idi, cmOutputConverter::SHELL);
this->Convert(*idi, cmOutputConverter::NONE, cmOutputConverter::SHELL);
this->AppendFlags(flags, flg); this->AppendFlags(flags, flg);
} }
} }

View File

@ -176,7 +176,7 @@ void cmLocalGenerator::GenerateTestFiles()
// TODO: Use add_subdirectory instead? // TODO: Use add_subdirectory instead?
fout << "subdirs("; fout << "subdirs(";
std::string outP = children[i].GetDirectory().GetCurrentBinary(); std::string outP = children[i].GetDirectory().GetCurrentBinary();
fout << this->Convert(outP, START_OUTPUT); fout << this->ConvertToRelativePath(outP, START_OUTPUT);
fout << ")" << std::endl; fout << ")" << std::endl;
} }
} }
@ -688,7 +688,9 @@ std::string cmLocalGenerator::ExpandRuleVariable(
} }
} }
if (variable == "CMAKE_COMMAND") { if (variable == "CMAKE_COMMAND") {
return this->Convert(cmSystemTools::GetCMakeCommand(), FULL, SHELL); return this->ConvertToOutputFormat(
cmSystemTools::CollapseFullPath(cmSystemTools::GetCMakeCommand()),
SHELL);
} }
std::vector<std::string> enabledLanguages = std::vector<std::string> enabledLanguages =
this->GetState()->GetEnabledLanguages(); this->GetState()->GetEnabledLanguages();
@ -1183,7 +1185,8 @@ void cmLocalGenerator::GetTargetFlags(
if (sf->GetExtension() == "def") { if (sf->GetExtension() == "def") {
linkFlags += linkFlags +=
this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
linkFlags += this->Convert(sf->GetFullPath(), FULL, SHELL); linkFlags += this->ConvertToOutputFormat(
cmSystemTools::CollapseFullPath(sf->GetFullPath()), SHELL);
linkFlags += " "; linkFlags += " ";
} }
} }
@ -1393,7 +1396,7 @@ std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib,
sp += lib.substr(pos); sp += lib.substr(pos);
// Convert to an output path. // Convert to an output path.
return this->Convert(sp.c_str(), NONE, format); return this->ConvertToOutputFormat(sp.c_str(), format);
} }
} }
} }
@ -1489,7 +1492,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
for (std::vector<std::string>::const_iterator fdi = fwDirs.begin(); for (std::vector<std::string>::const_iterator fdi = fwDirs.begin();
fdi != fwDirs.end(); ++fdi) { fdi != fwDirs.end(); ++fdi) {
frameworkPath += fwSearchFlag; frameworkPath += fwSearchFlag;
frameworkPath += this->Convert(*fdi, NONE, shellFormat); frameworkPath += this->ConvertToOutputFormat(*fdi, shellFormat);
frameworkPath += " "; frameworkPath += " ";
} }
} }
@ -1535,7 +1538,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
for (std::vector<std::string>::iterator ri = runtimeDirs.begin(); for (std::vector<std::string>::iterator ri = runtimeDirs.begin();
ri != runtimeDirs.end(); ++ri) { ri != runtimeDirs.end(); ++ri) {
rpath += cli.GetRuntimeFlag(); rpath += cli.GetRuntimeFlag();
rpath += this->Convert(*ri, NONE, shellFormat); rpath += this->ConvertToOutputFormat(*ri, shellFormat);
rpath += " "; rpath += " ";
} }
fout << rpath; fout << rpath;
@ -1605,7 +1608,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
flags += " "; flags += " ";
flags += sysrootFlag; flags += sysrootFlag;
flags += " "; flags += " ";
flags += this->Convert(sysroot, NONE, SHELL); flags += this->ConvertToOutputFormat(sysroot, SHELL);
} }
if (deploymentTargetFlag && *deploymentTargetFlag && deploymentTarget && if (deploymentTargetFlag && *deploymentTargetFlag && deploymentTarget &&
@ -2237,7 +2240,8 @@ std::string cmLocalGenerator::ConstructComment(
for (std::vector<std::string>::const_iterator o = ccg.GetOutputs().begin(); for (std::vector<std::string>::const_iterator o = ccg.GetOutputs().begin();
o != ccg.GetOutputs().end(); ++o) { o != ccg.GetOutputs().end(); ++o) {
comment += sep; comment += sep;
comment += this->Convert(*o, cmOutputConverter::START_OUTPUT); comment +=
this->ConvertToRelativePath(*o, cmOutputConverter::START_OUTPUT);
sep = ", "; sep = ", ";
} }
return comment; return comment;
@ -2505,13 +2509,14 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
const char* fullPath = source.GetFullPath().c_str(); const char* fullPath = source.GetFullPath().c_str();
// Try referencing the source relative to the source tree. // Try referencing the source relative to the source tree.
std::string relFromSource = this->Convert(fullPath, START); std::string relFromSource = this->ConvertToRelativePath(fullPath, START);
assert(!relFromSource.empty()); assert(!relFromSource.empty());
bool relSource = !cmSystemTools::FileIsFullPath(relFromSource.c_str()); bool relSource = !cmSystemTools::FileIsFullPath(relFromSource.c_str());
bool subSource = relSource && relFromSource[0] != '.'; bool subSource = relSource && relFromSource[0] != '.';
// Try referencing the source relative to the binary tree. // Try referencing the source relative to the binary tree.
std::string relFromBinary = this->Convert(fullPath, START_OUTPUT); std::string relFromBinary =
this->ConvertToRelativePath(fullPath, START_OUTPUT);
assert(!relFromBinary.empty()); assert(!relFromBinary.empty());
bool relBinary = !cmSystemTools::FileIsFullPath(relFromBinary.c_str()); bool relBinary = !cmSystemTools::FileIsFullPath(relFromBinary.c_str());
bool subBinary = relBinary && relFromBinary[0] != '.'; bool subBinary = relBinary && relFromBinary[0] != '.';

View File

@ -41,7 +41,7 @@ void cmLocalNinjaGenerator::Generate()
{ {
// Compute the path to use when referencing the current output // Compute the path to use when referencing the current output
// directory from the top output directory. // directory from the top output directory.
this->HomeRelativeOutputPath = this->Convert( this->HomeRelativeOutputPath = this->ConvertToRelativePath(
this->GetCurrentBinaryDirectory(), cmOutputConverter::HOME_OUTPUT); this->GetCurrentBinaryDirectory(), cmOutputConverter::HOME_OUTPUT);
if (this->HomeRelativeOutputPath == ".") { if (this->HomeRelativeOutputPath == ".") {
this->HomeRelativeOutputPath = ""; this->HomeRelativeOutputPath = "";
@ -132,9 +132,11 @@ std::string cmLocalNinjaGenerator::ConvertToIncludeReference(
std::string const& path, cmOutputConverter::OutputFormat format, std::string const& path, cmOutputConverter::OutputFormat format,
bool forceFullPaths) bool forceFullPaths)
{ {
return this->Convert(path, forceFullPaths ? cmOutputConverter::FULL if (forceFullPaths) {
: cmOutputConverter::HOME_OUTPUT, return this->ConvertToOutputFormat(cmSystemTools::CollapseFullPath(path),
format); format);
}
return this->Convert(path, cmOutputConverter::HOME_OUTPUT, format);
} }
// Private methods. // Private methods.
@ -487,12 +489,13 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher(
std::string output; std::string output;
const std::vector<std::string>& outputs = ccg.GetOutputs(); const std::vector<std::string>& outputs = ccg.GetOutputs();
if (!outputs.empty()) { if (!outputs.empty()) {
cmOutputConverter::RelativeRoot relative_root = if (ccg.GetWorkingDirectory().empty()) {
ccg.GetWorkingDirectory().empty() ? cmOutputConverter::START_OUTPUT output = this->Convert(outputs[0], cmOutputConverter::START_OUTPUT,
: cmOutputConverter::NONE; cmOutputConverter::SHELL);
} else {
output = output =
this->Convert(outputs[0], relative_root, cmOutputConverter::SHELL); this->ConvertToOutputFormat(outputs[0], cmOutputConverter::SHELL);
}
} }
vars.Output = output.c_str(); vars.Output = output.c_str();

View File

@ -140,7 +140,7 @@ void cmLocalUnixMakefileGenerator3::ComputeHomeRelativeOutputPath()
{ {
// Compute the path to use when referencing the current output // Compute the path to use when referencing the current output
// directory from the top output directory. // directory from the top output directory.
this->HomeRelativeOutputPath = this->Convert( this->HomeRelativeOutputPath = this->ConvertToRelativePath(
this->GetCurrentBinaryDirectory(), cmOutputConverter::HOME_OUTPUT); this->GetCurrentBinaryDirectory(), cmOutputConverter::HOME_OUTPUT);
if (this->HomeRelativeOutputPath == ".") { if (this->HomeRelativeOutputPath == ".") {
this->HomeRelativeOutputPath = ""; this->HomeRelativeOutputPath = "";
@ -358,7 +358,7 @@ void cmLocalUnixMakefileGenerator3::WriteObjectConvenienceRule(
this->GetRecursiveMakeCall(tgtMakefileName.c_str(), targetName)); this->GetRecursiveMakeCall(tgtMakefileName.c_str(), targetName));
} }
this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->CreateCDCommand(commands, this->GetBinaryDirectory(),
cmOutputConverter::START_OUTPUT); this->GetCurrentBinaryDirectory());
// Write the rule to the makefile. // Write the rule to the makefile.
std::vector<std::string> no_depends; std::vector<std::string> no_depends;
@ -398,7 +398,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
commands.push_back( commands.push_back(
this->GetRecursiveMakeCall(makefile2.c_str(), localName)); this->GetRecursiveMakeCall(makefile2.c_str(), localName));
this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->CreateCDCommand(commands, this->GetBinaryDirectory(),
cmOutputConverter::START_OUTPUT); this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream, "Convenience name for target.", this->WriteMakeRule(ruleFileStream, "Convenience name for target.",
localName, depends, commands, true); localName, depends, commands, true);
@ -423,7 +423,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
commands.push_back( commands.push_back(
this->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName)); this->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->CreateCDCommand(commands, this->GetBinaryDirectory(),
cmOutputConverter::START_OUTPUT); this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream, "fast build rule for target.", this->WriteMakeRule(ruleFileStream, "fast build rule for target.",
localName, depends, commands, true); localName, depends, commands, true);
@ -439,7 +439,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
commands.push_back( commands.push_back(
this->GetRecursiveMakeCall(makefile2.c_str(), makeTargetName)); this->GetRecursiveMakeCall(makefile2.c_str(), makeTargetName));
this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->CreateCDCommand(commands, this->GetBinaryDirectory(),
cmOutputConverter::START_OUTPUT); this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream, this->WriteMakeRule(ruleFileStream,
"Manual pre-install relink rule for target.", "Manual pre-install relink rule for target.",
localName, depends, commands, true); localName, depends, commands, true);
@ -592,8 +592,8 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule(
} }
} }
std::string cmLocalUnixMakefileGenerator3::ConvertShellCommand( std::string cmLocalUnixMakefileGenerator3::MaybeConvertWatcomShellCommand(
std::string const& cmd, cmOutputConverter::RelativeRoot root) std::string const& cmd)
{ {
if (this->IsWatcomWMake() && cmSystemTools::FileIsFullPath(cmd.c_str()) && if (this->IsWatcomWMake() && cmSystemTools::FileIsFullPath(cmd.c_str()) &&
cmd.find_first_of("( )") != cmd.npos) { cmd.find_first_of("( )") != cmd.npos) {
@ -602,11 +602,10 @@ std::string cmLocalUnixMakefileGenerator3::ConvertShellCommand(
// lines with shell redirection operators. // lines with shell redirection operators.
std::string scmd; std::string scmd;
if (cmSystemTools::GetShortPath(cmd, scmd)) { if (cmSystemTools::GetShortPath(cmd, scmd)) {
return this->Convert(scmd, cmOutputConverter::NONE, return this->ConvertToOutputFormat(scmd, cmOutputConverter::SHELL);
cmOutputConverter::SHELL);
} }
} }
return this->Convert(cmd, root, cmOutputConverter::SHELL); return std::string();
} }
void cmLocalUnixMakefileGenerator3::WriteMakeVariables( void cmLocalUnixMakefileGenerator3::WriteMakeVariables(
@ -638,19 +637,25 @@ void cmLocalUnixMakefileGenerator3::WriteMakeVariables(
#endif #endif
} }
std::string cmakeShellCommand =
this->MaybeConvertWatcomShellCommand(cmSystemTools::GetCMakeCommand());
if (cmakeShellCommand.empty()) {
cmakeShellCommand = this->ConvertToOutputFormat(
cmSystemTools::CollapseFullPath(cmSystemTools::GetCMakeCommand()),
cmOutputConverter::SHELL);
}
/* clang-format off */ /* clang-format off */
makefileStream makefileStream
<< "# The CMake executable.\n" << "# The CMake executable.\n"
<< "CMAKE_COMMAND = " << "CMAKE_COMMAND = "
<< this->ConvertShellCommand(cmSystemTools::GetCMakeCommand(), << cmakeShellCommand
cmOutputConverter::FULL)
<< "\n" << "\n"
<< "\n"; << "\n";
makefileStream makefileStream
<< "# The command to remove a file.\n" << "# The command to remove a file.\n"
<< "RM = " << "RM = "
<< this->ConvertShellCommand(cmSystemTools::GetCMakeCommand(), << cmakeShellCommand
cmOutputConverter::FULL)
<< " -E remove -f\n" << " -E remove -f\n"
<< "\n"; << "\n";
makefileStream makefileStream
@ -660,16 +665,16 @@ void cmLocalUnixMakefileGenerator3::WriteMakeVariables(
makefileStream makefileStream
<< "# The top-level source directory on which CMake was run.\n" << "# The top-level source directory on which CMake was run.\n"
<< "CMAKE_SOURCE_DIR = " << "CMAKE_SOURCE_DIR = "
<< this->Convert(this->GetSourceDirectory(), << this->ConvertToOutputFormat(
cmOutputConverter::FULL, cmSystemTools::CollapseFullPath(this->GetSourceDirectory()),
cmOutputConverter::SHELL) cmOutputConverter::SHELL)
<< "\n" << "\n"
<< "\n"; << "\n";
makefileStream makefileStream
<< "# The top-level build directory on which CMake was run.\n" << "# The top-level build directory on which CMake was run.\n"
<< "CMAKE_BINARY_DIR = " << "CMAKE_BINARY_DIR = "
<< this->Convert(this->GetBinaryDirectory(), << this->ConvertToOutputFormat(
cmOutputConverter::FULL, cmSystemTools::CollapseFullPath(this->GetBinaryDirectory()),
cmOutputConverter::SHELL) cmOutputConverter::SHELL)
<< "\n" << "\n"
<< "\n"; << "\n";
@ -784,8 +789,8 @@ void cmLocalUnixMakefileGenerator3::WriteSpecialTargetsBottom(
std::string runRule = std::string runRule =
"$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"; "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)";
runRule += " --check-build-system "; runRule += " --check-build-system ";
runRule += this->Convert(cmakefileName, cmOutputConverter::NONE, runRule +=
cmOutputConverter::SHELL); this->ConvertToOutputFormat(cmakefileName, cmOutputConverter::SHELL);
runRule += " 0"; runRule += " 0";
std::vector<std::string> no_depends; std::vector<std::string> no_depends;
@ -793,7 +798,7 @@ void cmLocalUnixMakefileGenerator3::WriteSpecialTargetsBottom(
commands.push_back(runRule); commands.push_back(runRule);
if (!this->IsRootMakefile()) { if (!this->IsRootMakefile()) {
this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->CreateCDCommand(commands, this->GetBinaryDirectory(),
cmOutputConverter::START_OUTPUT); this->GetCurrentBinaryDirectory());
} }
this->WriteMakeRule( this->WriteMakeRule(
makefileStream, "Special rule to run CMake to check the build system " makefileStream, "Special rule to run CMake to check the build system "
@ -829,8 +834,7 @@ std::string cmLocalUnixMakefileGenerator3::GetRelativeTargetDirectory(
{ {
std::string dir = this->HomeRelativeOutputPath; std::string dir = this->HomeRelativeOutputPath;
dir += this->GetTargetDirectory(target); dir += this->GetTargetDirectory(target);
return this->Convert(dir, cmOutputConverter::NONE, return dir;
cmOutputConverter::UNCHANGED);
} }
void cmLocalUnixMakefileGenerator3::AppendFlags(std::string& flags, void cmLocalUnixMakefileGenerator3::AppendFlags(std::string& flags,
@ -900,19 +904,19 @@ void cmLocalUnixMakefileGenerator3::AppendCustomDepend(
void cmLocalUnixMakefileGenerator3::AppendCustomCommands( void cmLocalUnixMakefileGenerator3::AppendCustomCommands(
std::vector<std::string>& commands, const std::vector<cmCustomCommand>& ccs, std::vector<std::string>& commands, const std::vector<cmCustomCommand>& ccs,
cmGeneratorTarget* target, cmOutputConverter::RelativeRoot relative) cmGeneratorTarget* target, std::string const& relative)
{ {
for (std::vector<cmCustomCommand>::const_iterator i = ccs.begin(); for (std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
i != ccs.end(); ++i) { i != ccs.end(); ++i) {
cmCustomCommandGenerator ccg(*i, this->ConfigName, this); cmCustomCommandGenerator ccg(*i, this->ConfigName, this);
this->AppendCustomCommand(commands, ccg, target, true, relative); this->AppendCustomCommand(commands, ccg, target, relative, true);
} }
} }
void cmLocalUnixMakefileGenerator3::AppendCustomCommand( void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
std::vector<std::string>& commands, cmCustomCommandGenerator const& ccg, std::vector<std::string>& commands, cmCustomCommandGenerator const& ccg,
cmGeneratorTarget* target, bool echo_comment, cmGeneratorTarget* target, std::string const& relative, bool echo_comment,
cmOutputConverter::RelativeRoot relative, std::ostream* content) std::ostream* content)
{ {
// Optionally create a command to display the custom command's // Optionally create a command to display the custom command's
// comment text. This is used for pre-build, pre-link, and // comment text. This is used for pre-build, pre-link, and
@ -962,7 +966,8 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
// working directory will be the start-output directory. // working directory will be the start-output directory.
bool had_slash = cmd.find('/') != cmd.npos; bool had_slash = cmd.find('/') != cmd.npos;
if (workingDir.empty()) { if (workingDir.empty()) {
cmd = this->Convert(cmd, cmOutputConverter::START_OUTPUT); cmd =
this->ConvertToRelativePath(cmd, cmOutputConverter::START_OUTPUT);
} }
bool has_slash = cmd.find('/') != cmd.npos; bool has_slash = cmd.find('/') != cmd.npos;
if (had_slash && !has_slash) { if (had_slash && !has_slash) {
@ -971,10 +976,43 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
// without the current directory being in the search path. // without the current directory being in the search path.
cmd = "./" + cmd; cmd = "./" + cmd;
} }
std::string launcher = this->MakeLauncher(
ccg, target, workingDir.empty() ? cmOutputConverter::START_OUTPUT std::string launcher;
: cmOutputConverter::NONE); // Short-circuit if there is no launcher.
cmd = launcher + this->ConvertShellCommand(cmd, cmOutputConverter::NONE); const char* prop = "RULE_LAUNCH_CUSTOM";
const char* val = this->GetRuleLauncher(target, prop);
if (val && *val) {
// Expand rules in the empty string. It may insert the launcher and
// perform replacements.
RuleVariables vars;
vars.RuleLauncher = prop;
vars.CMTarget = target;
std::string output;
const std::vector<std::string>& outputs = ccg.GetOutputs();
if (!outputs.empty()) {
if (workingDir.empty()) {
output = this->Convert(outputs[0], cmOutputConverter::START_OUTPUT,
cmOutputConverter::SHELL);
} else {
output = this->ConvertToOutputFormat(outputs[0],
cmOutputConverter::SHELL);
}
}
vars.Output = output.c_str();
this->ExpandRuleVariables(launcher, vars);
if (!launcher.empty()) {
launcher += " ";
}
}
std::string shellCommand = this->MaybeConvertWatcomShellCommand(cmd);
if (shellCommand.empty()) {
shellCommand =
this->ConvertToOutputFormat(cmd, cmOutputConverter::SHELL);
}
cmd = launcher + shellCommand;
ccg.AppendArguments(c, cmd); ccg.AppendArguments(c, cmd);
if (content) { if (content) {
@ -1017,37 +1055,6 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
commands.insert(commands.end(), commands1.begin(), commands1.end()); commands.insert(commands.end(), commands1.begin(), commands1.end());
} }
std::string cmLocalUnixMakefileGenerator3::MakeLauncher(
cmCustomCommandGenerator const& ccg, cmGeneratorTarget* target,
cmOutputConverter::RelativeRoot relative)
{
// Short-circuit if there is no launcher.
const char* prop = "RULE_LAUNCH_CUSTOM";
const char* val = this->GetRuleLauncher(target, prop);
if (!(val && *val)) {
return "";
}
// Expand rules in the empty string. It may insert the launcher and
// perform replacements.
RuleVariables vars;
vars.RuleLauncher = prop;
vars.CMTarget = target;
std::string output;
const std::vector<std::string>& outputs = ccg.GetOutputs();
if (!outputs.empty()) {
output = this->Convert(outputs[0], relative, cmOutputConverter::SHELL);
}
vars.Output = output.c_str();
std::string launcher;
this->ExpandRuleVariables(launcher, vars);
if (!launcher.empty()) {
launcher += " ";
}
return launcher;
}
void cmLocalUnixMakefileGenerator3::AppendCleanCommand( void cmLocalUnixMakefileGenerator3::AppendCleanCommand(
std::vector<std::string>& commands, const std::vector<std::string>& files, std::vector<std::string>& commands, const std::vector<std::string>& files,
cmGeneratorTarget* target, const char* filename) cmGeneratorTarget* target, const char* filename)
@ -1061,8 +1068,7 @@ void cmLocalUnixMakefileGenerator3::AppendCleanCommand(
cleanfile += filename; cleanfile += filename;
} }
cleanfile += ".cmake"; cleanfile += ".cmake";
std::string cleanfilePath = std::string cleanfilePath = cmSystemTools::CollapseFullPath(cleanfile);
this->Convert(cleanfile, cmOutputConverter::FULL);
cmsys::ofstream fout(cleanfilePath.c_str()); cmsys::ofstream fout(cleanfilePath.c_str());
if (!fout) { if (!fout) {
cmSystemTools::Error("Could not create ", cleanfilePath.c_str()); cmSystemTools::Error("Could not create ", cleanfilePath.c_str());
@ -1071,8 +1077,8 @@ void cmLocalUnixMakefileGenerator3::AppendCleanCommand(
fout << "file(REMOVE_RECURSE\n"; fout << "file(REMOVE_RECURSE\n";
for (std::vector<std::string>::const_iterator f = files.begin(); for (std::vector<std::string>::const_iterator f = files.begin();
f != files.end(); ++f) { f != files.end(); ++f) {
std::string fc = this->Convert(*f, cmOutputConverter::START_OUTPUT, std::string fc =
cmOutputConverter::UNCHANGED); this->ConvertToRelativePath(*f, cmOutputConverter::START_OUTPUT);
fout << " " << cmOutputConverter::EscapeForCMake(fc) << "\n"; fout << " " << cmOutputConverter::EscapeForCMake(fc) << "\n";
} }
fout << ")\n"; fout << ")\n";
@ -1148,8 +1154,9 @@ void cmLocalUnixMakefileGenerator3::AppendEcho(
cmd += color_name; cmd += color_name;
if (progress) { if (progress) {
cmd += "--progress-dir="; cmd += "--progress-dir=";
cmd += this->Convert(progress->Dir, cmOutputConverter::FULL, cmd += this->ConvertToOutputFormat(
cmOutputConverter::SHELL); cmSystemTools::CollapseFullPath(progress->Dir),
cmOutputConverter::SHELL);
cmd += " "; cmd += " ";
cmd += "--progress-num="; cmd += "--progress-num=";
cmd += progress->Arg; cmd += progress->Arg;
@ -1558,9 +1565,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
this->AppendCustomDepends(depends, gt->GetPreBuildCommands()); this->AppendCustomDepends(depends, gt->GetPreBuildCommands());
this->AppendCustomDepends(depends, gt->GetPostBuildCommands()); this->AppendCustomDepends(depends, gt->GetPostBuildCommands());
this->AppendCustomCommands(commands, gt->GetPreBuildCommands(), gt, this->AppendCustomCommands(commands, gt->GetPreBuildCommands(), gt,
cmOutputConverter::START_OUTPUT); this->GetCurrentBinaryDirectory());
this->AppendCustomCommands(commands, gt->GetPostBuildCommands(), gt, this->AppendCustomCommands(commands, gt->GetPostBuildCommands(), gt,
cmOutputConverter::START_OUTPUT); this->GetCurrentBinaryDirectory());
std::string targetName = gt->GetName(); std::string targetName = gt->GetName();
this->WriteMakeRule(ruleFileStream, targetString.c_str(), targetName, this->WriteMakeRule(ruleFileStream, targetString.c_str(), targetName,
depends, commands, true); depends, commands, true);
@ -1597,15 +1604,16 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
{ {
std::ostringstream progCmd; std::ostringstream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start ";
progCmd << this->Convert(progressDir, cmOutputConverter::FULL, progCmd << this->ConvertToOutputFormat(
cmOutputConverter::SHELL); cmSystemTools::CollapseFullPath(progressDir), cmOutputConverter::SHELL);
std::string progressFile = cmake::GetCMakeFilesDirectory(); std::string progressFile = cmake::GetCMakeFilesDirectory();
progressFile += "/progress.marks"; progressFile += "/progress.marks";
std::string progressFileNameFull = this->ConvertToFullPath(progressFile); std::string progressFileNameFull = this->ConvertToFullPath(progressFile);
progCmd << " " progCmd << " "
<< this->Convert(progressFileNameFull, cmOutputConverter::FULL, << this->ConvertToOutputFormat(
cmOutputConverter::SHELL); cmSystemTools::CollapseFullPath(progressFileNameFull),
cmOutputConverter::SHELL);
commands.push_back(progCmd.str()); commands.push_back(progCmd.str());
} }
std::string mf2Dir = cmake::GetCMakeFilesDirectoryPostSlash(); std::string mf2Dir = cmake::GetCMakeFilesDirectoryPostSlash();
@ -1613,12 +1621,12 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
commands.push_back( commands.push_back(
this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget)); this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->CreateCDCommand(commands, this->GetBinaryDirectory(),
cmOutputConverter::START_OUTPUT); this->GetCurrentBinaryDirectory());
{ {
std::ostringstream progCmd; std::ostringstream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0 progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
progCmd << this->Convert(progressDir, cmOutputConverter::FULL, progCmd << this->ConvertToOutputFormat(
cmOutputConverter::SHELL); cmSystemTools::CollapseFullPath(progressDir), cmOutputConverter::SHELL);
progCmd << " 0"; progCmd << " 0";
commands.push_back(progCmd.str()); commands.push_back(progCmd.str());
} }
@ -1633,7 +1641,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
commands.push_back( commands.push_back(
this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget)); this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->CreateCDCommand(commands, this->GetBinaryDirectory(),
cmOutputConverter::START_OUTPUT); this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream, "The main clean target", "clean", this->WriteMakeRule(ruleFileStream, "The main clean target", "clean",
depends, commands, true); depends, commands, true);
commands.clear(); commands.clear();
@ -1659,7 +1667,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
commands.push_back( commands.push_back(
this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget)); this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->CreateCDCommand(commands, this->GetBinaryDirectory(),
cmOutputConverter::START_OUTPUT); this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream, "Prepare targets for installation.", this->WriteMakeRule(ruleFileStream, "Prepare targets for installation.",
"preinstall", depends, commands, true); "preinstall", depends, commands, true);
depends.clear(); depends.clear();
@ -1674,12 +1682,12 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
std::string runRule = std::string runRule =
"$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"; "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)";
runRule += " --check-build-system "; runRule += " --check-build-system ";
runRule += this->Convert(cmakefileName, cmOutputConverter::NONE, runRule +=
cmOutputConverter::SHELL); this->ConvertToOutputFormat(cmakefileName, cmOutputConverter::SHELL);
runRule += " 1"; runRule += " 1";
commands.push_back(runRule); commands.push_back(runRule);
this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->CreateCDCommand(commands, this->GetBinaryDirectory(),
cmOutputConverter::START_OUTPUT); this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream, "clear depends", "depend", depends, this->WriteMakeRule(ruleFileStream, "clear depends", "depend", depends,
commands, true); commands, true);
} }
@ -1846,7 +1854,8 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
for (std::vector<std::string>::iterator i = includes.begin(); for (std::vector<std::string>::iterator i = includes.begin();
i != includes.end(); ++i) { i != includes.end(); ++i) {
cmakefileStream << " \"" cmakefileStream << " \""
<< this->Convert(*i, cmOutputConverter::HOME_OUTPUT) << this->ConvertToRelativePath(
*i, cmOutputConverter::HOME_OUTPUT)
<< "\"\n"; << "\"\n";
} }
cmakefileStream << " )\n"; cmakefileStream << " )\n";
@ -1888,8 +1897,7 @@ std::string cmLocalUnixMakefileGenerator3::GetRecursiveMakeCall(
// Call make on the given file. // Call make on the given file.
std::string cmd; std::string cmd;
cmd += "$(MAKE) -f "; cmd += "$(MAKE) -f ";
cmd += cmd += this->ConvertToOutputFormat(makefile, cmOutputConverter::SHELL);
this->Convert(makefile, cmOutputConverter::NONE, cmOutputConverter::SHELL);
cmd += " "; cmd += " ";
cmGlobalUnixMakefileGenerator3* gg = cmGlobalUnixMakefileGenerator3* gg =
@ -1911,7 +1919,8 @@ std::string cmLocalUnixMakefileGenerator3::GetRecursiveMakeCall(
// Add the target. // Add the target.
if (!tgt.empty()) { if (!tgt.empty()) {
// The make target is always relative to the top of the build tree. // The make target is always relative to the top of the build tree.
std::string tgt2 = this->Convert(tgt, cmOutputConverter::HOME_OUTPUT); std::string tgt2 =
this->ConvertToRelativePath(tgt, cmOutputConverter::HOME_OUTPUT);
// The target may have been written with windows paths. // The target may have been written with windows paths.
cmSystemTools::ConvertToOutputSlashes(tgt2); cmSystemTools::ConvertToOutputSlashes(tgt2);
@ -2046,12 +2055,10 @@ void cmLocalUnixMakefileGenerator3::AddImplicitDepends(
void cmLocalUnixMakefileGenerator3::CreateCDCommand( void cmLocalUnixMakefileGenerator3::CreateCDCommand(
std::vector<std::string>& commands, const char* tgtDir, std::vector<std::string>& commands, const char* tgtDir,
cmOutputConverter::RelativeRoot relRetDir) std::string const& relDir)
{ {
const char* retDir = this->GetRelativeRootPath(relRetDir);
// do we need to cd? // do we need to cd?
if (!strcmp(tgtDir, retDir)) { if (tgtDir == relDir) {
return; return;
} }
@ -2073,7 +2080,7 @@ void cmLocalUnixMakefileGenerator3::CreateCDCommand(
// Change back to the starting directory. // Change back to the starting directory.
cmd = cd_cmd; cmd = cd_cmd;
cmd += this->ConvertToOutputForExisting(relRetDir); cmd += this->ConvertToOutputForExisting(relDir);
commands.push_back(cmd); commands.push_back(cmd);
} else { } else {
// On UNIX we must construct a single shell command to change // On UNIX we must construct a single shell command to change

View File

@ -121,8 +121,7 @@ public:
// create a command that cds to the start dir then runs the commands // create a command that cds to the start dir then runs the commands
void CreateCDCommand(std::vector<std::string>& commands, void CreateCDCommand(std::vector<std::string>& commands,
const char* targetDir, const char* targetDir, std::string const& relDir);
cmOutputConverter::RelativeRoot returnDir);
static std::string ConvertToQuotedOutputPath(const char* p, static std::string ConvertToQuotedOutputPath(const char* p,
bool useWatcomQuote); bool useWatcomQuote);
@ -229,15 +228,16 @@ protected:
const std::vector<cmCustomCommand>& ccs); const std::vector<cmCustomCommand>& ccs);
void AppendCustomDepend(std::vector<std::string>& depends, void AppendCustomDepend(std::vector<std::string>& depends,
cmCustomCommandGenerator const& cc); cmCustomCommandGenerator const& cc);
void AppendCustomCommands( void AppendCustomCommands(std::vector<std::string>& commands,
std::vector<std::string>& commands, const std::vector<cmCustomCommand>& ccs,
const std::vector<cmCustomCommand>& ccs, cmGeneratorTarget* target, cmGeneratorTarget* target,
cmOutputConverter::RelativeRoot relative = cmOutputConverter::HOME_OUTPUT); std::string const& relative);
void AppendCustomCommand( void AppendCustomCommand(std::vector<std::string>& commands,
std::vector<std::string>& commands, cmCustomCommandGenerator const& ccg, cmCustomCommandGenerator const& ccg,
cmGeneratorTarget* target, bool echo_comment = false, cmGeneratorTarget* target,
cmOutputConverter::RelativeRoot relative = cmOutputConverter::HOME_OUTPUT, std::string const& relative,
std::ostream* content = CM_NULLPTR); bool echo_comment = false,
std::ostream* content = CM_NULLPTR);
void AppendCleanCommand(std::vector<std::string>& commands, void AppendCleanCommand(std::vector<std::string>& commands,
const std::vector<std::string>& files, const std::vector<std::string>& files,
cmGeneratorTarget* target, cmGeneratorTarget* target,
@ -250,11 +250,7 @@ protected:
void CheckMultipleOutputs(bool verbose); void CheckMultipleOutputs(bool verbose);
private: private:
std::string ConvertShellCommand(std::string const& cmd, std::string MaybeConvertWatcomShellCommand(std::string const& cmd);
cmOutputConverter::RelativeRoot root);
std::string MakeLauncher(cmCustomCommandGenerator const& ccg,
cmGeneratorTarget* target,
cmOutputConverter::RelativeRoot relative);
void ComputeObjectFilenames( void ComputeObjectFilenames(
std::map<cmSourceFile const*, std::string>& mapping, std::map<cmSourceFile const*, std::string>& mapping,

View File

@ -269,8 +269,8 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
args += this->GetBinaryDirectory(); args += this->GetBinaryDirectory();
commandLine.push_back(args); commandLine.push_back(args);
commandLine.push_back("--check-stamp-file"); commandLine.push_back("--check-stamp-file");
std::string stampFilename = this->Convert( std::string stampFilename = this->ConvertToOutputFormat(
stampName.c_str(), cmOutputConverter::FULL, cmOutputConverter::SHELL); cmSystemTools::CollapseFullPath(stampName), cmOutputConverter::SHELL);
commandLine.push_back(stampFilename.c_str()); commandLine.push_back(stampFilename.c_str());
std::vector<std::string> const& listFiles = this->Makefile->GetListFiles(); std::vector<std::string> const& listFiles = this->Makefile->GetListFiles();
@ -278,8 +278,8 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
cmCustomCommandLines commandLines; cmCustomCommandLines commandLines;
commandLines.push_back(commandLine); commandLines.push_back(commandLine);
const char* no_working_directory = 0; const char* no_working_directory = 0;
std::string fullpathStampName = this->Convert( std::string fullpathStampName =
stampName.c_str(), cmOutputConverter::FULL, cmOutputConverter::UNCHANGED); cmSystemTools::CollapseFullPath(stampName.c_str());
this->Makefile->AddCustomCommandToOutput( this->Makefile->AddCustomCommandToOutput(
fullpathStampName.c_str(), listFiles, makefileIn.c_str(), commandLines, fullpathStampName.c_str(), listFiles, makefileIn.c_str(), commandLines,
comment.c_str(), no_working_directory, true); comment.c_str(), no_working_directory, true);
@ -788,8 +788,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
target->GetProperty("Fortran_MODULE_DIRECTORY"); target->GetProperty("Fortran_MODULE_DIRECTORY");
std::string modDir; std::string modDir;
if (target_mod_dir) { if (target_mod_dir) {
modDir = this->Convert(target_mod_dir, cmOutputConverter::START_OUTPUT, modDir = this->ConvertToRelativePath(target_mod_dir,
cmOutputConverter::UNCHANGED); cmOutputConverter::START_OUTPUT);
} else { } else {
modDir = "."; modDir = ".";
} }
@ -1300,9 +1300,8 @@ void cmLocalVisualStudio7GeneratorInternals::OutputLibraries(
cmLocalVisualStudio7Generator* lg = this->LocalGenerator; cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) { for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) {
if (l->IsPath) { if (l->IsPath) {
std::string rel = std::string rel = lg->ConvertToRelativePath(
lg->Convert(l->Value.c_str(), cmOutputConverter::START_OUTPUT, l->Value.c_str(), cmOutputConverter::START_OUTPUT);
cmOutputConverter::UNCHANGED);
fout << lg->ConvertToXMLOutputPath(rel.c_str()) << " "; fout << lg->ConvertToXMLOutputPath(rel.c_str()) << " ";
} else if (!l->Target || } else if (!l->Target ||
l->Target->GetType() != cmState::INTERFACE_LIBRARY) { l->Target->GetType() != cmState::INTERFACE_LIBRARY) {
@ -1322,8 +1321,8 @@ void cmLocalVisualStudio7GeneratorInternals::OutputObjects(
const char* sep = isep ? isep : ""; const char* sep = isep ? isep : "";
for (std::vector<std::string>::const_iterator oi = objs.begin(); for (std::vector<std::string>::const_iterator oi = objs.begin();
oi != objs.end(); ++oi) { oi != objs.end(); ++oi) {
std::string rel = lg->Convert(oi->c_str(), cmOutputConverter::START_OUTPUT, std::string rel =
cmOutputConverter::UNCHANGED); lg->ConvertToRelativePath(oi->c_str(), cmOutputConverter::START_OUTPUT);
fout << sep << lg->ConvertToXMLOutputPath(rel.c_str()); fout << sep << lg->ConvertToXMLOutputPath(rel.c_str());
sep = " "; sep = " ";
} }
@ -1346,9 +1345,8 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories(
// Switch to a relative path specification if it is shorter. // Switch to a relative path specification if it is shorter.
if (cmSystemTools::FileIsFullPath(dir.c_str())) { if (cmSystemTools::FileIsFullPath(dir.c_str())) {
std::string rel = std::string rel = this->ConvertToRelativePath(
this->Convert(dir.c_str(), cmOutputConverter::START_OUTPUT, dir.c_str(), cmOutputConverter::START_OUTPUT);
cmOutputConverter::UNCHANGED);
if (rel.size() < dir.size()) { if (rel.size() < dir.size()) {
dir = rel; dir = rel;
} }

View File

@ -127,7 +127,6 @@ std::string cmLocalVisualStudioGenerator::ConstructScript(
{ {
bool useLocal = this->CustomCommandUseLocal(); bool useLocal = this->CustomCommandUseLocal();
std::string workingDirectory = ccg.GetWorkingDirectory(); std::string workingDirectory = ccg.GetWorkingDirectory();
RelativeRoot relativeRoot = workingDirectory.empty() ? START_OUTPUT : NONE;
// Avoid leading or trailing newlines. // Avoid leading or trailing newlines.
std::string newline = ""; std::string newline = "";
@ -156,7 +155,8 @@ std::string cmLocalVisualStudioGenerator::ConstructScript(
script += newline; script += newline;
newline = newline_text; newline = newline_text;
script += "cd "; script += "cd ";
script += this->Convert(workingDirectory, FULL, SHELL); script += this->ConvertToOutputFormat(
cmSystemTools::CollapseFullPath(workingDirectory), SHELL);
script += check_error; script += check_error;
// Change the working drive. // Change the working drive.
@ -203,7 +203,11 @@ std::string cmLocalVisualStudioGenerator::ConstructScript(
} }
} }
script += this->Convert(cmd.c_str(), relativeRoot, SHELL); if (workingDirectory.empty()) {
script += this->Convert(cmd.c_str(), START_OUTPUT, SHELL);
} else {
script += this->ConvertToOutputFormat(cmd.c_str(), SHELL);
}
ccg.AppendArguments(c, script); ccg.AppendArguments(c, script);
// After each custom command, check for an error result. // After each custom command, check for an error result.

View File

@ -135,8 +135,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
std::string targetFullPathReal = outpath + targetNameReal; std::string targetFullPathReal = outpath + targetNameReal;
std::string targetFullPathPDB = pdbOutputPath + targetNamePDB; std::string targetFullPathPDB = pdbOutputPath + targetNamePDB;
std::string targetFullPathImport = outpathImp + targetNameImport; std::string targetFullPathImport = outpathImp + targetNameImport;
std::string targetOutPathPDB = this->Convert( std::string targetOutPathPDB = this->LocalGenerator->ConvertToOutputFormat(
targetFullPathPDB, cmOutputConverter::NONE, cmOutputConverter::SHELL); targetFullPathPDB, cmOutputConverter::SHELL);
// Convert to the output path to use in constructing commands. // Convert to the output path to use in constructing commands.
std::string targetOutPath = this->Convert( std::string targetOutPath = this->Convert(
targetFullPath, cmOutputConverter::START_OUTPUT, cmOutputConverter::SHELL); targetFullPath, cmOutputConverter::START_OUTPUT, cmOutputConverter::SHELL);
@ -218,49 +218,43 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Construct a list of files associated with this executable that // Construct a list of files associated with this executable that
// may need to be cleaned. // may need to be cleaned.
std::vector<std::string> exeCleanFiles; std::vector<std::string> exeCleanFiles;
exeCleanFiles.push_back(this->Convert(targetFullPath, exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
cmOutputConverter::START_OUTPUT, targetFullPath, cmOutputConverter::START_OUTPUT));
cmOutputConverter::UNCHANGED));
#ifdef _WIN32 #ifdef _WIN32
// There may be a manifest file for this target. Add it to the // There may be a manifest file for this target. Add it to the
// clean set just in case. // clean set just in case.
exeCleanFiles.push_back(this->Convert((targetFullPath + ".manifest").c_str(), exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
cmOutputConverter::START_OUTPUT, (targetFullPath + ".manifest").c_str(), cmOutputConverter::START_OUTPUT));
cmOutputConverter::UNCHANGED));
#endif #endif
if (targetNameReal != targetName) { if (targetNameReal != targetName) {
exeCleanFiles.push_back(this->Convert(targetFullPathReal, exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
cmOutputConverter::START_OUTPUT, targetFullPathReal, cmOutputConverter::START_OUTPUT));
cmOutputConverter::UNCHANGED));
} }
if (!targetNameImport.empty()) { if (!targetNameImport.empty()) {
exeCleanFiles.push_back(this->Convert(targetFullPathImport, exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
cmOutputConverter::START_OUTPUT, targetFullPathImport, cmOutputConverter::START_OUTPUT));
cmOutputConverter::UNCHANGED));
std::string implib; std::string implib;
if (this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport, if (this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport,
implib)) { implib)) {
exeCleanFiles.push_back(this->Convert(implib, exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
cmOutputConverter::START_OUTPUT, implib, cmOutputConverter::START_OUTPUT));
cmOutputConverter::UNCHANGED));
} }
} }
// List the PDB for cleaning only when the whole target is // List the PDB for cleaning only when the whole target is
// cleaned. We do not want to delete the .pdb file just before // cleaned. We do not want to delete the .pdb file just before
// linking the target. // linking the target.
this->CleanFiles.push_back(this->Convert(targetFullPathPDB, this->CleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
cmOutputConverter::START_OUTPUT, targetFullPathPDB, cmOutputConverter::START_OUTPUT));
cmOutputConverter::UNCHANGED));
// Add the pre-build and pre-link rules building but not when relinking. // Add the pre-build and pre-link rules building but not when relinking.
if (!relink) { if (!relink) {
this->LocalGenerator->AppendCustomCommands( this->LocalGenerator->AppendCustomCommands(
commands, this->GeneratorTarget->GetPreBuildCommands(), commands, this->GeneratorTarget->GetPreBuildCommands(),
this->GeneratorTarget); this->GeneratorTarget, this->LocalGenerator->GetBinaryDirectory());
this->LocalGenerator->AppendCustomCommands( this->LocalGenerator->AppendCustomCommands(
commands, this->GeneratorTarget->GetPreLinkCommands(), commands, this->GeneratorTarget->GetPreLinkCommands(),
this->GeneratorTarget); this->GeneratorTarget, this->LocalGenerator->GetBinaryDirectory());
} }
// Determine whether a link script will be used. // Determine whether a link script will be used.
@ -357,9 +351,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
vars.Manifests = manifests.c_str(); vars.Manifests = manifests.c_str();
if (this->GeneratorTarget->GetProperty("LINK_WHAT_YOU_USE")) { if (this->GeneratorTarget->GetProperty("LINK_WHAT_YOU_USE")) {
std::string cmakeCommand = std::string cmakeCommand = this->LocalGenerator->ConvertToOutputFormat(
this->Convert(cmSystemTools::GetCMakeCommand(), cmLocalGenerator::NONE, cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
cmLocalGenerator::SHELL);
cmakeCommand += " -E __run_iwyu --lwyu="; cmakeCommand += " -E __run_iwyu --lwyu=";
cmakeCommand += targetOutPathReal; cmakeCommand += targetOutPathReal;
real_link_commands.push_back(cmakeCommand); real_link_commands.push_back(cmakeCommand);
@ -389,7 +382,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
} }
this->LocalGenerator->CreateCDCommand( this->LocalGenerator->CreateCDCommand(
commands1, this->Makefile->GetCurrentBinaryDirectory(), commands1, this->Makefile->GetCurrentBinaryDirectory(),
cmOutputConverter::HOME_OUTPUT); this->LocalGenerator->GetBinaryDirectory());
commands.insert(commands.end(), commands1.begin(), commands1.end()); commands.insert(commands.end(), commands1.begin(), commands1.end());
commands1.clear(); commands1.clear();
@ -402,7 +395,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
commands1.push_back(symlink); commands1.push_back(symlink);
this->LocalGenerator->CreateCDCommand( this->LocalGenerator->CreateCDCommand(
commands1, this->Makefile->GetCurrentBinaryDirectory(), commands1, this->Makefile->GetCurrentBinaryDirectory(),
cmOutputConverter::HOME_OUTPUT); this->LocalGenerator->GetBinaryDirectory());
commands.insert(commands.end(), commands1.begin(), commands1.end()); commands.insert(commands.end(), commands1.begin(), commands1.end());
commands1.clear(); commands1.clear();
} }
@ -411,7 +404,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
if (!relink) { if (!relink) {
this->LocalGenerator->AppendCustomCommands( this->LocalGenerator->AppendCustomCommands(
commands, this->GeneratorTarget->GetPostBuildCommands(), commands, this->GeneratorTarget->GetPostBuildCommands(),
this->GeneratorTarget); this->GeneratorTarget, this->LocalGenerator->GetBinaryDirectory());
} }
// Write the build rule. // Write the build rule.

View File

@ -112,7 +112,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules()
// Add post-build rules. // Add post-build rules.
this->LocalGenerator->AppendCustomCommands( this->LocalGenerator->AppendCustomCommands(
commands, this->GeneratorTarget->GetPostBuildCommands(), commands, this->GeneratorTarget->GetPostBuildCommands(),
this->GeneratorTarget); this->GeneratorTarget, this->LocalGenerator->GetBinaryDirectory());
// Depend on the object files. // Depend on the object files.
this->AppendObjectDepends(depends); this->AppendObjectDepends(depends);
@ -310,8 +310,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
// Construct the output path version of the names for use in command // Construct the output path version of the names for use in command
// arguments. // arguments.
std::string targetOutPathPDB = this->Convert( std::string targetOutPathPDB = this->LocalGenerator->ConvertToOutputFormat(
targetFullPathPDB, cmOutputConverter::NONE, cmOutputConverter::SHELL); targetFullPathPDB, cmOutputConverter::SHELL);
std::string targetOutPath = this->Convert( std::string targetOutPath = this->Convert(
targetFullPath, cmOutputConverter::START_OUTPUT, cmOutputConverter::SHELL); targetFullPath, cmOutputConverter::START_OUTPUT, cmOutputConverter::SHELL);
std::string targetOutPathSO = std::string targetOutPathSO =
@ -367,46 +367,40 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
// Clean files associated with this library. // Clean files associated with this library.
std::vector<std::string> libCleanFiles; std::vector<std::string> libCleanFiles;
libCleanFiles.push_back(this->Convert(targetFullPath, libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
cmOutputConverter::START_OUTPUT, targetFullPath, cmOutputConverter::START_OUTPUT));
cmOutputConverter::UNCHANGED));
if (targetNameReal != targetName) { if (targetNameReal != targetName) {
libCleanFiles.push_back(this->Convert(targetFullPathReal, libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
cmOutputConverter::START_OUTPUT, targetFullPathReal, cmOutputConverter::START_OUTPUT));
cmOutputConverter::UNCHANGED));
} }
if (targetNameSO != targetName && targetNameSO != targetNameReal) { if (targetNameSO != targetName && targetNameSO != targetNameReal) {
libCleanFiles.push_back(this->Convert(targetFullPathSO, libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
cmOutputConverter::START_OUTPUT, targetFullPathSO, cmOutputConverter::START_OUTPUT));
cmOutputConverter::UNCHANGED));
} }
if (!targetNameImport.empty()) { if (!targetNameImport.empty()) {
libCleanFiles.push_back(this->Convert(targetFullPathImport, libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
cmOutputConverter::START_OUTPUT, targetFullPathImport, cmOutputConverter::START_OUTPUT));
cmOutputConverter::UNCHANGED));
std::string implib; std::string implib;
if (this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport, if (this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport,
implib)) { implib)) {
libCleanFiles.push_back(this->Convert(implib, libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
cmOutputConverter::START_OUTPUT, implib, cmOutputConverter::START_OUTPUT));
cmOutputConverter::UNCHANGED));
} }
} }
// List the PDB for cleaning only when the whole target is // List the PDB for cleaning only when the whole target is
// cleaned. We do not want to delete the .pdb file just before // cleaned. We do not want to delete the .pdb file just before
// linking the target. // linking the target.
this->CleanFiles.push_back(this->Convert(targetFullPathPDB, this->CleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
cmOutputConverter::START_OUTPUT, targetFullPathPDB, cmOutputConverter::START_OUTPUT));
cmOutputConverter::UNCHANGED));
#ifdef _WIN32 #ifdef _WIN32
// There may be a manifest file for this target. Add it to the // There may be a manifest file for this target. Add it to the
// clean set just in case. // clean set just in case.
if (this->GeneratorTarget->GetType() != cmState::STATIC_LIBRARY) { if (this->GeneratorTarget->GetType() != cmState::STATIC_LIBRARY) {
libCleanFiles.push_back(this->Convert( libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
(targetFullPath + ".manifest").c_str(), cmOutputConverter::START_OUTPUT, (targetFullPath + ".manifest").c_str(),
cmOutputConverter::UNCHANGED)); cmOutputConverter::START_OUTPUT));
} }
#endif #endif
@ -418,7 +412,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
this->GeneratorTarget, "target"); this->GeneratorTarget, "target");
this->LocalGenerator->CreateCDCommand( this->LocalGenerator->CreateCDCommand(
commands1, this->Makefile->GetCurrentBinaryDirectory(), commands1, this->Makefile->GetCurrentBinaryDirectory(),
cmOutputConverter::HOME_OUTPUT); this->LocalGenerator->GetBinaryDirectory());
commands.insert(commands.end(), commands1.begin(), commands1.end()); commands.insert(commands.end(), commands1.begin(), commands1.end());
commands1.clear(); commands1.clear();
} }
@ -427,10 +421,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
if (!relink) { if (!relink) {
this->LocalGenerator->AppendCustomCommands( this->LocalGenerator->AppendCustomCommands(
commands, this->GeneratorTarget->GetPreBuildCommands(), commands, this->GeneratorTarget->GetPreBuildCommands(),
this->GeneratorTarget); this->GeneratorTarget, this->LocalGenerator->GetBinaryDirectory());
this->LocalGenerator->AppendCustomCommands( this->LocalGenerator->AppendCustomCommands(
commands, this->GeneratorTarget->GetPreLinkCommands(), commands, this->GeneratorTarget->GetPreLinkCommands(),
this->GeneratorTarget); this->GeneratorTarget, this->LocalGenerator->GetBinaryDirectory());
} }
// Determine whether a link script will be used. // Determine whether a link script will be used.
@ -572,8 +566,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
vars.TargetInstallNameDir = ""; vars.TargetInstallNameDir = "";
} else { } else {
// Convert to a path for the native build tool. // Convert to a path for the native build tool.
install_name_dir = this->LocalGenerator->Convert( install_name_dir = this->LocalGenerator->ConvertToOutputFormat(
install_name_dir, cmOutputConverter::NONE, cmOutputConverter::SHELL); install_name_dir, cmOutputConverter::SHELL);
vars.TargetInstallNameDir = install_name_dir.c_str(); vars.TargetInstallNameDir = install_name_dir.c_str();
} }
} }
@ -640,9 +634,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
cmSystemTools::ExpandListArgument(linkRule, real_link_commands); cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
if (this->GeneratorTarget->GetProperty("LINK_WHAT_YOU_USE") && if (this->GeneratorTarget->GetProperty("LINK_WHAT_YOU_USE") &&
(this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY)) { (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY)) {
std::string cmakeCommand = std::string cmakeCommand = this->LocalGenerator->ConvertToOutputFormat(
this->Convert(cmSystemTools::GetCMakeCommand(), cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
cmLocalGenerator::NONE, cmLocalGenerator::SHELL);
cmakeCommand += " -E __run_iwyu --lwyu="; cmakeCommand += " -E __run_iwyu --lwyu=";
cmakeCommand += targetOutPathReal; cmakeCommand += targetOutPathReal;
real_link_commands.push_back(cmakeCommand); real_link_commands.push_back(cmakeCommand);
@ -672,7 +665,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
} }
this->LocalGenerator->CreateCDCommand( this->LocalGenerator->CreateCDCommand(
commands1, this->Makefile->GetCurrentBinaryDirectory(), commands1, this->Makefile->GetCurrentBinaryDirectory(),
cmOutputConverter::HOME_OUTPUT); this->LocalGenerator->GetBinaryDirectory());
commands.insert(commands.end(), commands1.begin(), commands1.end()); commands.insert(commands.end(), commands1.begin(), commands1.end());
commands1.clear(); commands1.clear();
@ -689,7 +682,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
commands1.push_back(symlink); commands1.push_back(symlink);
this->LocalGenerator->CreateCDCommand( this->LocalGenerator->CreateCDCommand(
commands1, this->Makefile->GetCurrentBinaryDirectory(), commands1, this->Makefile->GetCurrentBinaryDirectory(),
cmOutputConverter::HOME_OUTPUT); this->LocalGenerator->GetBinaryDirectory());
commands.insert(commands.end(), commands1.begin(), commands1.end()); commands.insert(commands.end(), commands1.begin(), commands1.end());
commands1.clear(); commands1.clear();
} }
@ -698,7 +691,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
if (!relink) { if (!relink) {
this->LocalGenerator->AppendCustomCommands( this->LocalGenerator->AppendCustomCommands(
commands, this->GeneratorTarget->GetPostBuildCommands(), commands, this->GeneratorTarget->GetPostBuildCommands(),
this->GeneratorTarget); this->GeneratorTarget, this->LocalGenerator->GetBinaryDirectory());
} }
// Compute the list of outputs. // Compute the list of outputs.

View File

@ -172,8 +172,8 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
const std::vector<std::string>& outputs = ccg.GetOutputs(); const std::vector<std::string>& outputs = ccg.GetOutputs();
for (std::vector<std::string>::const_iterator o = outputs.begin(); for (std::vector<std::string>::const_iterator o = outputs.begin();
o != outputs.end(); ++o) { o != outputs.end(); ++o) {
this->CleanFiles.push_back(this->Convert( this->CleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
*o, cmOutputConverter::START_OUTPUT, cmOutputConverter::UNCHANGED)); *o, cmOutputConverter::START_OUTPUT));
} }
} }
} }
@ -312,8 +312,10 @@ void cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()(
output += "/"; output += "/";
output += cmSystemTools::GetFilenameName(input); output += cmSystemTools::GetFilenameName(input);
this->Generator->CleanFiles.push_back( this->Generator->CleanFiles.push_back(
this->Generator->Convert(output, cmOutputConverter::START_OUTPUT)); this->Generator->LocalGenerator->ConvertToRelativePath(
output = this->Generator->Convert(output, cmOutputConverter::HOME_OUTPUT); output, cmOutputConverter::START_OUTPUT));
output = this->Generator->LocalGenerator->ConvertToRelativePath(
output, cmOutputConverter::HOME_OUTPUT);
// Create a rule to copy the content into the bundle. // Create a rule to copy the content into the bundle.
std::vector<std::string> depends; std::vector<std::string> depends;
@ -324,11 +326,11 @@ void cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()(
this->Generator->LocalGenerator->AppendEcho( this->Generator->LocalGenerator->AppendEcho(
commands, copyEcho, cmLocalUnixMakefileGenerator3::EchoBuild); commands, copyEcho, cmLocalUnixMakefileGenerator3::EchoBuild);
std::string copyCommand = "$(CMAKE_COMMAND) -E copy "; std::string copyCommand = "$(CMAKE_COMMAND) -E copy ";
copyCommand += this->Generator->Convert(input, cmOutputConverter::NONE, copyCommand += this->Generator->LocalGenerator->ConvertToOutputFormat(
cmOutputConverter::SHELL); input, cmOutputConverter::SHELL);
copyCommand += " "; copyCommand += " ";
copyCommand += this->Generator->Convert(output, cmOutputConverter::NONE, copyCommand += this->Generator->LocalGenerator->ConvertToOutputFormat(
cmOutputConverter::SHELL); output, cmOutputConverter::SHELL);
commands.push_back(copyCommand); commands.push_back(copyCommand);
this->Generator->LocalGenerator->WriteMakeRule( this->Generator->LocalGenerator->WriteMakeRule(
*this->Generator->BuildFileStream, CM_NULLPTR, output, depends, commands, *this->Generator->BuildFileStream, CM_NULLPTR, output, depends, commands,
@ -393,9 +395,9 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
std::string objFullPath = this->LocalGenerator->GetCurrentBinaryDirectory(); std::string objFullPath = this->LocalGenerator->GetCurrentBinaryDirectory();
objFullPath += "/"; objFullPath += "/";
objFullPath += obj; objFullPath += obj;
objFullPath = this->Convert(objFullPath, cmOutputConverter::FULL); objFullPath = cmSystemTools::CollapseFullPath(objFullPath);
std::string srcFullPath = std::string srcFullPath =
this->Convert(source.GetFullPath(), cmOutputConverter::FULL); cmSystemTools::CollapseFullPath(source.GetFullPath());
this->LocalGenerator->AddImplicitDepends( this->LocalGenerator->AddImplicitDepends(
this->GeneratorTarget, lang, objFullPath.c_str(), srcFullPath.c_str()); this->GeneratorTarget, lang, objFullPath.c_str(), srcFullPath.c_str());
} }
@ -464,8 +466,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
} }
// Get the output paths for source and object files. // Get the output paths for source and object files.
std::string sourceFile = this->Convert( std::string sourceFile = this->LocalGenerator->ConvertToOutputFormat(
source.GetFullPath(), cmOutputConverter::NONE, cmOutputConverter::SHELL); source.GetFullPath(), cmOutputConverter::SHELL);
// Construct the build message. // Construct the build message.
std::vector<std::string> no_commands; std::vector<std::string> no_commands;
@ -516,8 +518,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
targetOutPathReal = targetOutPathReal =
this->Convert(targetFullPathReal, cmOutputConverter::START_OUTPUT, this->Convert(targetFullPathReal, cmOutputConverter::START_OUTPUT,
cmOutputConverter::SHELL); cmOutputConverter::SHELL);
targetOutPathPDB = this->Convert( targetOutPathPDB = this->LocalGenerator->ConvertToOutputFormat(
targetFullPathPDB, cmOutputConverter::NONE, cmOutputConverter::SHELL); targetFullPathPDB, cmOutputConverter::SHELL);
targetOutPathCompilePDB = targetOutPathCompilePDB =
this->Convert(targetFullPathCompilePDB, cmOutputConverter::START_OUTPUT, this->Convert(targetFullPathCompilePDB, cmOutputConverter::START_OUTPUT,
cmOutputConverter::SHELL); cmOutputConverter::SHELL);
@ -539,7 +541,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
vars.TargetCompilePDB = targetOutPathCompilePDB.c_str(); vars.TargetCompilePDB = targetOutPathCompilePDB.c_str();
vars.Source = sourceFile.c_str(); vars.Source = sourceFile.c_str();
std::string shellObj = std::string shellObj =
this->Convert(obj, cmOutputConverter::NONE, cmOutputConverter::SHELL); this->LocalGenerator->ConvertToOutputFormat(obj, cmOutputConverter::SHELL);
vars.Object = shellObj.c_str(); vars.Object = shellObj.c_str();
std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); std::string objectDir = this->GeneratorTarget->GetSupportDirectory();
objectDir = this->Convert(objectDir, cmOutputConverter::START_OUTPUT, objectDir = this->Convert(objectDir, cmOutputConverter::START_OUTPUT,
@ -584,9 +586,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
lang_can_export_cmds && compileCommands.size() == 1) { lang_can_export_cmds && compileCommands.size() == 1) {
std::string compileCommand = compileCommands[0]; std::string compileCommand = compileCommands[0];
this->LocalGenerator->ExpandRuleVariables(compileCommand, vars); this->LocalGenerator->ExpandRuleVariables(compileCommand, vars);
std::string workingDirectory = this->LocalGenerator->Convert( std::string workingDirectory = cmSystemTools::CollapseFullPath(
this->LocalGenerator->GetCurrentBinaryDirectory(), this->LocalGenerator->GetCurrentBinaryDirectory());
cmOutputConverter::FULL);
compileCommand.replace(compileCommand.find(langFlags), langFlags.size(), compileCommand.replace(compileCommand.find(langFlags), langFlags.size(),
this->GetFlags(lang)); this->GetFlags(lang));
std::string langDefines = std::string("$(") + lang + "_DEFINES)"; std::string langDefines = std::string("$(") + lang + "_DEFINES)";
@ -649,7 +650,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
// Change the command working directory to the local build tree. // Change the command working directory to the local build tree.
this->LocalGenerator->CreateCDCommand( this->LocalGenerator->CreateCDCommand(
compileCommands, this->LocalGenerator->GetCurrentBinaryDirectory(), compileCommands, this->LocalGenerator->GetCurrentBinaryDirectory(),
cmOutputConverter::HOME_OUTPUT); this->LocalGenerator->GetBinaryDirectory());
commands.insert(commands.end(), compileCommands.begin(), commands.insert(commands.end(), compileCommands.begin(),
compileCommands.end()); compileCommands.end());
} }
@ -699,8 +700,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
std::vector<std::string> preprocessCommands; std::vector<std::string> preprocessCommands;
cmSystemTools::ExpandListArgument(preprocessRule, preprocessCommands); cmSystemTools::ExpandListArgument(preprocessRule, preprocessCommands);
std::string shellObjI = this->Convert(objI, cmOutputConverter::NONE, std::string shellObjI = this->LocalGenerator->ConvertToOutputFormat(
cmOutputConverter::SHELL); objI, cmOutputConverter::SHELL);
vars.PreprocessedSource = shellObjI.c_str(); vars.PreprocessedSource = shellObjI.c_str();
// Expand placeholders in the commands. // Expand placeholders in the commands.
@ -712,7 +713,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
this->LocalGenerator->CreateCDCommand( this->LocalGenerator->CreateCDCommand(
preprocessCommands, preprocessCommands,
this->LocalGenerator->GetCurrentBinaryDirectory(), this->LocalGenerator->GetCurrentBinaryDirectory(),
cmOutputConverter::HOME_OUTPUT); this->LocalGenerator->GetBinaryDirectory());
commands.insert(commands.end(), preprocessCommands.begin(), commands.insert(commands.end(), preprocessCommands.begin(),
preprocessCommands.end()); preprocessCommands.end());
} else { } else {
@ -746,8 +747,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
std::vector<std::string> assemblyCommands; std::vector<std::string> assemblyCommands;
cmSystemTools::ExpandListArgument(assemblyRule, assemblyCommands); cmSystemTools::ExpandListArgument(assemblyRule, assemblyCommands);
std::string shellObjS = this->Convert(objS, cmOutputConverter::NONE, std::string shellObjS = this->LocalGenerator->ConvertToOutputFormat(
cmOutputConverter::SHELL); objS, cmOutputConverter::SHELL);
vars.AssemblySource = shellObjS.c_str(); vars.AssemblySource = shellObjS.c_str();
// Expand placeholders in the commands. // Expand placeholders in the commands.
@ -758,7 +759,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
this->LocalGenerator->CreateCDCommand( this->LocalGenerator->CreateCDCommand(
assemblyCommands, this->LocalGenerator->GetCurrentBinaryDirectory(), assemblyCommands, this->LocalGenerator->GetCurrentBinaryDirectory(),
cmOutputConverter::HOME_OUTPUT); this->LocalGenerator->GetBinaryDirectory());
commands.insert(commands.end(), assemblyCommands.begin(), commands.insert(commands.end(), assemblyCommands.begin(),
assemblyCommands.end()); assemblyCommands.end());
} else { } else {
@ -849,7 +850,7 @@ void cmMakefileTargetGenerator::WriteTargetCleanRules()
this->GeneratorTarget); this->GeneratorTarget);
this->LocalGenerator->CreateCDCommand( this->LocalGenerator->CreateCDCommand(
commands, this->LocalGenerator->GetCurrentBinaryDirectory(), commands, this->LocalGenerator->GetCurrentBinaryDirectory(),
cmOutputConverter::HOME_OUTPUT); this->LocalGenerator->GetBinaryDirectory());
// Write the rule. // Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR,
@ -999,9 +1000,10 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
// paths. Make sure PWD is set to the original name of the home // paths. Make sure PWD is set to the original name of the home
// output directory to help cmSystemTools to create the same // output directory to help cmSystemTools to create the same
// translation table for the dependency scanning process. // translation table for the dependency scanning process.
depCmd << "cd " << (this->LocalGenerator->Convert( depCmd << "cd " << (this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->GetBinaryDirectory(), cmSystemTools::CollapseFullPath(
cmOutputConverter::FULL, cmOutputConverter::SHELL)) this->LocalGenerator->GetBinaryDirectory()),
cmOutputConverter::SHELL))
<< " && "; << " && ";
#endif #endif
// Generate a call this signature: // Generate a call this signature:
@ -1015,20 +1017,29 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
// the state of our local generator sufficiently for its needs. // the state of our local generator sufficiently for its needs.
depCmd << "$(CMAKE_COMMAND) -E cmake_depends \"" depCmd << "$(CMAKE_COMMAND) -E cmake_depends \""
<< this->GlobalGenerator->GetName() << "\" " << this->GlobalGenerator->GetName() << "\" "
<< this->Convert(this->LocalGenerator->GetSourceDirectory(), << this->LocalGenerator->ConvertToOutputFormat(
cmOutputConverter::FULL, cmOutputConverter::SHELL) cmSystemTools::CollapseFullPath(
this->LocalGenerator->GetSourceDirectory()),
cmOutputConverter::SHELL)
<< " " << " "
<< this->Convert(this->LocalGenerator->GetCurrentSourceDirectory(), << this->LocalGenerator->ConvertToOutputFormat(
cmOutputConverter::FULL, cmOutputConverter::SHELL) cmSystemTools::CollapseFullPath(
this->LocalGenerator->GetCurrentSourceDirectory()),
cmOutputConverter::SHELL)
<< " " << " "
<< this->Convert(this->LocalGenerator->GetBinaryDirectory(), << this->LocalGenerator->ConvertToOutputFormat(
cmOutputConverter::FULL, cmOutputConverter::SHELL) cmSystemTools::CollapseFullPath(
this->LocalGenerator->GetBinaryDirectory()),
cmOutputConverter::SHELL)
<< " " << " "
<< this->Convert(this->LocalGenerator->GetCurrentBinaryDirectory(), << this->LocalGenerator->ConvertToOutputFormat(
cmOutputConverter::FULL, cmOutputConverter::SHELL) cmSystemTools::CollapseFullPath(
this->LocalGenerator->GetCurrentBinaryDirectory()),
cmOutputConverter::SHELL)
<< " " << " "
<< this->Convert(this->InfoFileNameFull, cmOutputConverter::FULL, << this->LocalGenerator->ConvertToOutputFormat(
cmOutputConverter::SHELL); cmSystemTools::CollapseFullPath(this->InfoFileNameFull),
cmOutputConverter::SHELL);
if (this->LocalGenerator->GetColorMakefile()) { if (this->LocalGenerator->GetColorMakefile()) {
depCmd << " --color=$(COLOR)"; depCmd << " --color=$(COLOR)";
} }
@ -1094,8 +1105,8 @@ void cmMakefileTargetGenerator::GenerateCustomRuleFile(
// Now append the actual user-specified commands. // Now append the actual user-specified commands.
std::ostringstream content; std::ostringstream content;
this->LocalGenerator->AppendCustomCommand( this->LocalGenerator->AppendCustomCommand(
commands, ccg, this->GeneratorTarget, false, commands, ccg, this->GeneratorTarget,
cmOutputConverter::HOME_OUTPUT, &content); this->LocalGenerator->GetBinaryDirectory(), false, &content);
// Collect the dependencies. // Collect the dependencies.
std::vector<std::string> depends; std::vector<std::string> depends;
@ -1115,10 +1126,8 @@ void cmMakefileTargetGenerator::GenerateCustomRuleFile(
for (cmCustomCommand::ImplicitDependsList::const_iterator idi = for (cmCustomCommand::ImplicitDependsList::const_iterator idi =
ccg.GetCC().GetImplicitDepends().begin(); ccg.GetCC().GetImplicitDepends().begin();
idi != ccg.GetCC().GetImplicitDepends().end(); ++idi) { idi != ccg.GetCC().GetImplicitDepends().end(); ++idi) {
std::string objFullPath = std::string objFullPath = cmSystemTools::CollapseFullPath(outputs[0]);
this->Convert(outputs[0], cmOutputConverter::FULL); std::string srcFullPath = cmSystemTools::CollapseFullPath(idi->second);
std::string srcFullPath =
this->Convert(idi->second, cmOutputConverter::FULL);
this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, idi->first, this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, idi->first,
objFullPath.c_str(), objFullPath.c_str(),
srcFullPath.c_str()); srcFullPath.c_str());
@ -1174,7 +1183,8 @@ void cmMakefileTargetGenerator::WriteObjectsVariable(
for (std::vector<std::string>::const_iterator i = for (std::vector<std::string>::const_iterator i =
this->ExternalObjects.begin(); this->ExternalObjects.begin();
i != this->ExternalObjects.end(); ++i) { i != this->ExternalObjects.end(); ++i) {
object = this->Convert(*i, cmOutputConverter::START_OUTPUT); object = this->LocalGenerator->ConvertToRelativePath(
*i, cmOutputConverter::START_OUTPUT);
*this->BuildFileStream << " " << lineContinue << "\n" *this->BuildFileStream << " " << lineContinue << "\n"
<< this->Makefile->GetSafeDefinition( << this->Makefile->GetSafeDefinition(
"CMAKE_OBJECT_NAME"); "CMAKE_OBJECT_NAME");
@ -1261,9 +1271,8 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(
this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget); this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget);
std::string buildTargetRuleName = dir; std::string buildTargetRuleName = dir;
buildTargetRuleName += relink ? "/preinstall" : "/build"; buildTargetRuleName += relink ? "/preinstall" : "/build";
buildTargetRuleName = buildTargetRuleName = this->LocalGenerator->ConvertToRelativePath(
this->Convert(buildTargetRuleName, cmOutputConverter::HOME_OUTPUT, buildTargetRuleName, cmOutputConverter::HOME_OUTPUT);
cmOutputConverter::UNCHANGED);
// Build the list of target outputs to drive. // Build the list of target outputs to drive.
std::vector<std::string> depends; std::vector<std::string> depends;
@ -1576,8 +1585,8 @@ void cmMakefileTargetGenerator::CreateLinkLibs(
// Reference the response file. // Reference the response file.
linkLibs = responseFlag; linkLibs = responseFlag;
linkLibs += this->Convert(link_rsp, cmOutputConverter::NONE, linkLibs += this->LocalGenerator->ConvertToOutputFormat(
cmOutputConverter::SHELL); link_rsp, cmOutputConverter::SHELL);
} }
} }
@ -1625,8 +1634,8 @@ void cmMakefileTargetGenerator::CreateObjectLists(
// Reference the response file. // Reference the response file.
buildObjs += responseFlag; buildObjs += responseFlag;
buildObjs += this->Convert(objects_rsp, cmOutputConverter::NONE, buildObjs += this->LocalGenerator->ConvertToOutputFormat(
cmOutputConverter::SHELL); objects_rsp, cmOutputConverter::SHELL);
} }
} else if (useLinkScript) { } else if (useLinkScript) {
if (!useArchiveRules) { if (!useArchiveRules) {
@ -1683,8 +1692,8 @@ void cmMakefileTargetGenerator::GenDefFile(
name_of_def_file += std::string("/") + this->GeneratorTarget->GetName(); name_of_def_file += std::string("/") + this->GeneratorTarget->GetName();
name_of_def_file += ".def"; name_of_def_file += ".def";
std::string cmd = cmSystemTools::GetCMakeCommand(); std::string cmd = cmSystemTools::GetCMakeCommand();
cmd = cmd = this->LocalGenerator->ConvertToOutputFormat(
this->Convert(cmd, cmOutputConverter::NONE, cmOutputConverter::SHELL); cmd, cmOutputConverter::SHELL);
cmd += " -E __create_def "; cmd += " -E __create_def ";
cmd += this->Convert(name_of_def_file, cmOutputConverter::START_OUTPUT, cmd += this->Convert(name_of_def_file, cmOutputConverter::START_OUTPUT,
cmOutputConverter::SHELL); cmOutputConverter::SHELL);

View File

@ -75,14 +75,14 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
this->LocalGenerator->AppendCustomCommands( this->LocalGenerator->AppendCustomCommands(
commands, this->GeneratorTarget->GetPreBuildCommands(), commands, this->GeneratorTarget->GetPreBuildCommands(),
this->GeneratorTarget); this->GeneratorTarget, this->LocalGenerator->GetBinaryDirectory());
// Depend on all custom command outputs for sources // Depend on all custom command outputs for sources
this->DriveCustomCommands(depends); this->DriveCustomCommands(depends);
this->LocalGenerator->AppendCustomCommands( this->LocalGenerator->AppendCustomCommands(
commands, this->GeneratorTarget->GetPostBuildCommands(), commands, this->GeneratorTarget->GetPostBuildCommands(),
this->GeneratorTarget); this->GeneratorTarget, this->LocalGenerator->GetBinaryDirectory());
// Add dependencies on targets that must be built first. // Add dependencies on targets that must be built first.
this->AppendTargetDepends(depends); this->AppendTargetDepends(depends);

View File

@ -543,8 +543,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
std::string install_dir = std::string install_dir =
this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName); this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName);
if (!install_dir.empty()) { if (!install_dir.empty()) {
vars["INSTALLNAME_DIR"] = localGen.Convert( vars["INSTALLNAME_DIR"] = localGen.ConvertToOutputFormat(
install_dir, cmOutputConverter::NONE, cmOutputConverter::SHELL); install_dir, cmOutputConverter::SHELL);
} }
} }
} }

View File

@ -46,34 +46,32 @@ std::string cmOutputConverter::ConvertToOutputForExisting(
return this->ConvertToOutputFormat(remote, format); return this->ConvertToOutputFormat(remote, format);
} }
std::string cmOutputConverter::ConvertToOutputForExisting( std::string cmOutputConverter::ConvertToRelativePath(
RelativeRoot remote, OutputFormat format) const const std::string& source, RelativeRoot relative) const
{ {
// The relative root must have a path (i.e. not FULL or NONE) std::string result;
assert(remote != FULL);
assert(remote != NONE);
const char* remotePath = this->GetRelativeRootPath(remote); switch (relative) {
assert(remotePath != CM_NULLPTR);
return this->ConvertToOutputForExisting(remotePath, format);
}
const char* cmOutputConverter::GetRelativeRootPath(RelativeRoot relroot) const
{
switch (relroot) {
case HOME: case HOME:
return this->GetState()->GetSourceDirectory(); result = this->ConvertToRelativePath(
this->GetState()->GetSourceDirectoryComponents(), source);
break;
case START: case START:
return this->StateSnapshot.GetDirectory().GetCurrentSource(); result = this->ConvertToRelativePath(
this->StateSnapshot.GetDirectory().GetCurrentSourceComponents(),
source);
break;
case HOME_OUTPUT: case HOME_OUTPUT:
return this->GetState()->GetBinaryDirectory(); result = this->ConvertToRelativePath(
this->GetState()->GetBinaryDirectoryComponents(), source);
break;
case START_OUTPUT: case START_OUTPUT:
return this->StateSnapshot.GetDirectory().GetCurrentBinary(); result = this->ConvertToRelativePath(
default: this->StateSnapshot.GetDirectory().GetCurrentBinaryComponents(),
source);
break; break;
} }
return CM_NULLPTR; return result;
} }
std::string cmOutputConverter::Convert(const std::string& source, std::string cmOutputConverter::Convert(const std::string& source,
@ -81,33 +79,7 @@ std::string cmOutputConverter::Convert(const std::string& source,
OutputFormat output) const OutputFormat output) const
{ {
// Convert the path to a relative path. // Convert the path to a relative path.
std::string result = source; std::string result = this->ConvertToRelativePath(source, relative);
switch (relative) {
case HOME:
result = this->ConvertToRelativePath(
this->GetState()->GetSourceDirectoryComponents(), result);
break;
case START:
result = this->ConvertToRelativePath(
this->StateSnapshot.GetDirectory().GetCurrentSourceComponents(),
result);
break;
case HOME_OUTPUT:
result = this->ConvertToRelativePath(
this->GetState()->GetBinaryDirectoryComponents(), result);
break;
case START_OUTPUT:
result = this->ConvertToRelativePath(
this->StateSnapshot.GetDirectory().GetCurrentBinaryComponents(),
result);
break;
case FULL:
result = cmSystemTools::CollapseFullPath(result);
break;
case NONE:
break;
}
return this->ConvertToOutputFormat(result, output); return this->ConvertToOutputFormat(result, output);
} }
@ -146,27 +118,6 @@ std::string cmOutputConverter::ConvertDirectorySeparatorsForShell(
return result; return result;
} }
std::string cmOutputConverter::Convert(RelativeRoot remote,
const std::string& local,
OutputFormat output) const
{
// The relative root must have a path (i.e. not FULL or NONE)
assert(remote != FULL);
assert(remote != NONE);
const char* remotePath = this->GetRelativeRootPath(remote);
assert(remotePath != CM_NULLPTR);
if (local.empty()) {
return this->ConvertToOutputFormat(remotePath, output);
}
std::vector<std::string> components;
cmSystemTools::SplitPath(local, components);
std::string result = this->ConvertToRelativePath(components, remotePath);
return this->ConvertToOutputFormat(result, output);
}
static bool cmOutputConverterNotAbove(const char* a, const char* b) static bool cmOutputConverterNotAbove(const char* a, const char* b)
{ {
return (cmSystemTools::ComparePath(a, b) || return (cmSystemTools::ComparePath(a, b) ||

View File

@ -38,8 +38,6 @@ public:
*/ */
enum RelativeRoot enum RelativeRoot
{ {
NONE,
FULL,
HOME, HOME,
START, START,
HOME_OUTPUT, HOME_OUTPUT,
@ -47,7 +45,6 @@ public:
}; };
enum OutputFormat enum OutputFormat
{ {
UNCHANGED,
MAKERULE, MAKERULE,
SHELL, SHELL,
WATCOMQUOTE, WATCOMQUOTE,
@ -56,26 +53,16 @@ public:
std::string ConvertToOutputFormat(const std::string& source, std::string ConvertToOutputFormat(const std::string& source,
OutputFormat output) const; OutputFormat output) const;
std::string Convert(const std::string& remote, RelativeRoot local, std::string Convert(const std::string& remote, RelativeRoot local,
OutputFormat output = UNCHANGED) const; OutputFormat output) const;
std::string Convert(RelativeRoot remote, const std::string& local, std::string ConvertToRelativePath(const std::string& remote,
OutputFormat output = UNCHANGED) const; RelativeRoot local) const;
std::string ConvertDirectorySeparatorsForShell( std::string ConvertDirectorySeparatorsForShell(
const std::string& source) const; const std::string& source) const;
/**
* Get path for the specified relative root.
*/
const char* GetRelativeRootPath(RelativeRoot relroot) const;
///! for existing files convert to output path and short path if spaces ///! for existing files convert to output path and short path if spaces
std::string ConvertToOutputForExisting(const std::string& remote, std::string ConvertToOutputForExisting(const std::string& remote,
OutputFormat format = SHELL) const; OutputFormat format = SHELL) const;
/** For existing path identified by RelativeRoot convert to output
path and short path if spaces. */
std::string ConvertToOutputForExisting(RelativeRoot remote,
OutputFormat format = SHELL) const;
void SetLinkScriptShell(bool linkScriptShell); void SetLinkScriptShell(bool linkScriptShell);
/** /**

View File

@ -602,7 +602,8 @@ void cmTarget::GetTllSignatureTraces(std::ostream& s, TLLSignature sig) const
it != this->TLLCommands.end(); ++it) { it != this->TLLCommands.end(); ++it) {
if (it->first == sig) { if (it->first == sig) {
cmListFileContext lfc = it->second; cmListFileContext lfc = it->second;
lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME); lfc.FilePath =
converter.ConvertToRelativePath(lfc.FilePath, cmOutputConverter::HOME);
s << " * " << lfc << std::endl; s << " * " << lfc << std::endl;
} }
} }

View File

@ -2415,9 +2415,8 @@ void cmVisualStudio10TargetGenerator::AddLibraries(
ItemVector libs = cli.GetItems(); ItemVector libs = cli.GetItems();
for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) { for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) {
if (l->IsPath) { if (l->IsPath) {
std::string path = this->LocalGenerator->Convert( std::string path = this->LocalGenerator->ConvertToRelativePath(
l->Value.c_str(), cmOutputConverter::START_OUTPUT, l->Value.c_str(), cmOutputConverter::START_OUTPUT);
cmOutputConverter::UNCHANGED);
this->ConvertToWindowsSlash(path); this->ConvertToWindowsSlash(path);
libVec.push_back(path); libVec.push_back(path);
} else if (!l->Target || } else if (!l->Target ||