Commit 614876c6 authored by Vitaly Stakhovsky's avatar Vitaly Stakhovsky

cmLocalUnixMakefileGenerator3: more methods accept std::string

parent bcc9ea2b
......@@ -574,7 +574,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules(
commands.clear();
std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
tmp += "Makefile2";
commands.push_back(lg->GetRecursiveMakeCall(tmp.c_str(), name));
commands.push_back(lg->GetRecursiveMakeCall(tmp, name));
depends.clear();
if (regenerate) {
depends.emplace_back("cmake_check_build_system");
......@@ -594,7 +594,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules(
localName = name;
localName += "/fast";
commands.push_back(
lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
lg->GetRecursiveMakeCall(makefileName, makeTargetName));
lg->WriteMakeRule(ruleFileStream, "fast build rule for target.",
localName, depends, commands, true);
......@@ -608,7 +608,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules(
depends.clear();
commands.clear();
commands.push_back(
lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
lg->GetRecursiveMakeCall(makefileName, makeTargetName));
lg->WriteMakeRule(ruleFileStream,
"Manual pre-install relink rule for target.",
localName, depends, commands, true);
......@@ -659,12 +659,12 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
makeTargetName = localName;
makeTargetName += "/depend";
commands.push_back(
lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
lg->GetRecursiveMakeCall(makefileName, makeTargetName));
makeTargetName = localName;
makeTargetName += "/build";
commands.push_back(
lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
lg->GetRecursiveMakeCall(makefileName, makeTargetName));
// Write the rule.
localName += "/all";
......@@ -728,7 +728,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
}
std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
tmp += "Makefile2";
commands.push_back(lg->GetRecursiveMakeCall(tmp.c_str(), localName));
commands.push_back(lg->GetRecursiveMakeCall(tmp, localName));
{
std::ostringstream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
......@@ -761,8 +761,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
localName += "/preinstall";
depends.clear();
commands.clear();
commands.push_back(
lg->GetRecursiveMakeCall(makefileName.c_str(), localName));
commands.push_back(lg->GetRecursiveMakeCall(makefileName, localName));
lg->WriteMakeRule(ruleFileStream,
"Pre-install relink rule for target.", localName,
depends, commands, true);
......@@ -783,7 +782,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
depends.clear();
commands.clear();
commands.push_back(
lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
lg->GetRecursiveMakeCall(makefileName, makeTargetName));
lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
makeTargetName, depends, commands, true);
commands.clear();
......
......@@ -233,8 +233,8 @@ public:
virtual void ClearDependencies(cmMakefile* /* mf */, bool /* verbose */) {}
/** Called from command-line hook to update dependencies. */
virtual bool UpdateDependencies(const char* /* tgtInfo */, bool /*verbose*/,
bool /*color*/)
virtual bool UpdateDependencies(const std::string& /* tgtInfo */,
bool /*verbose*/, bool /*color*/)
{
return true;
}
......
......@@ -248,8 +248,8 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
for (auto& localObjectFile : localObjectFiles) {
// Add a convenience rule for building the object file.
this->WriteObjectConvenienceRule(
ruleFileStream, "target to build an object file",
localObjectFile.first.c_str(), localObjectFile.second);
ruleFileStream, "target to build an object file", localObjectFile.first,
localObjectFile.second);
// Check whether preprocessing and assembly rules make sense.
// They make sense only for C and C++ sources.
......@@ -271,9 +271,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
if (lang_has_preprocessor && do_preprocess_rules) {
std::string::size_type dot_pos = localObjectFile.first.rfind(".");
std::string base = localObjectFile.first.substr(0, dot_pos);
this->WriteObjectConvenienceRule(
ruleFileStream, "target to preprocess a source file",
(base + ".i").c_str(), localObjectFile.second);
this->WriteObjectConvenienceRule(ruleFileStream,
"target to preprocess a source file",
(base + ".i"), localObjectFile.second);
localObjectFile.second.HasPreprocessRule = true;
}
......@@ -282,7 +282,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
std::string base = localObjectFile.first.substr(0, dot_pos);
this->WriteObjectConvenienceRule(
ruleFileStream, "target to generate assembly for a file",
(base + ".s").c_str(), localObjectFile.second);
(base + ".s"), localObjectFile.second);
localObjectFile.second.HasAssembleRule = true;
}
}
......@@ -298,7 +298,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
}
void cmLocalUnixMakefileGenerator3::WriteObjectConvenienceRule(
std::ostream& ruleFileStream, const char* comment, const char* output,
std::ostream& ruleFileStream, const char* comment, const std::string& output,
LocalObjectInfo const& info)
{
// If the rule includes the source file extension then create a
......@@ -334,7 +334,7 @@ void cmLocalUnixMakefileGenerator3::WriteObjectConvenienceRule(
targetName += "/";
targetName += output;
commands.push_back(
this->GetRecursiveMakeCall(tgtMakefileName.c_str(), targetName));
this->GetRecursiveMakeCall(tgtMakefileName, targetName));
}
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
......@@ -373,8 +373,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
// Build the target for this pass.
std::string makefile2 = cmake::GetCMakeFilesDirectoryPostSlash();
makefile2 += "Makefile2";
commands.push_back(
this->GetRecursiveMakeCall(makefile2.c_str(), localName));
commands.push_back(this->GetRecursiveMakeCall(makefile2, localName));
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream, "Convenience name for target.",
......@@ -399,7 +398,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
depends.clear();
commands.clear();
commands.push_back(
this->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
this->GetRecursiveMakeCall(makefileName, makeTargetName));
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream, "fast build rule for target.",
......@@ -415,7 +414,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
depends.clear();
commands.clear();
commands.push_back(
this->GetRecursiveMakeCall(makefile2.c_str(), makeTargetName));
this->GetRecursiveMakeCall(makefile2, makeTargetName));
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream,
......@@ -1254,9 +1253,8 @@ std::string cmLocalUnixMakefileGenerator3::CreateMakeVariable(
return ret;
}
bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
bool verbose,
bool color)
bool cmLocalUnixMakefileGenerator3::UpdateDependencies(
const std::string& tgtInfo, bool verbose, bool color)
{
// read in the target info file
if (!this->Makefile->ReadListFile(tgtInfo) ||
......@@ -1280,7 +1278,8 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
this->GlobalGenerator->GetCMakeInstance()->GetFileComparison();
{
int result;
if (!ftc->FileTimeCompare(internalDependFile.c_str(), tgtInfo, &result) ||
if (!ftc->FileTimeCompare(internalDependFile.c_str(), tgtInfo.c_str(),
&result) ||
result < 0) {
if (verbose) {
std::ostringstream msg;
......@@ -1611,8 +1610,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
}
std::string mf2Dir = cmake::GetCMakeFilesDirectoryPostSlash();
mf2Dir += "Makefile2";
commands.push_back(
this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget));
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
{
......@@ -1631,8 +1629,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
recursiveTarget += "/clean";
commands.clear();
depends.clear();
commands.push_back(
this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget));
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream, "The main clean target", "clean",
......@@ -1657,8 +1654,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
// At least make sure the build system is up to date.
depends.emplace_back("cmake_check_build_system");
}
commands.push_back(
this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget));
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream, "Prepare targets for installation.",
......@@ -1886,7 +1882,7 @@ void cmLocalUnixMakefileGenerator3::WriteDisclaimer(std::ostream& os)
}
std::string cmLocalUnixMakefileGenerator3::GetRecursiveMakeCall(
const char* makefile, const std::string& tgt)
const std::string& makefile, const std::string& tgt)
{
// Call make on the given file.
std::string cmd;
......@@ -1956,7 +1952,7 @@ void cmLocalUnixMakefileGenerator3::WriteCMakeArgument(std::ostream& os,
}
std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
const char* p, bool useWatcomQuote)
const std::string& p, bool useWatcomQuote)
{
// Split the path into its components.
std::vector<std::string> components;
......@@ -2040,8 +2036,8 @@ cmLocalUnixMakefileGenerator3::GetImplicitDepends(const cmGeneratorTarget* tgt)
}
void cmLocalUnixMakefileGenerator3::AddImplicitDepends(
const cmGeneratorTarget* tgt, const std::string& lang, const char* obj,
const char* src)
const cmGeneratorTarget* tgt, const std::string& lang,
const std::string& obj, const std::string& src)
{
this->ImplicitDepends[tgt->GetName()][lang][obj].push_back(src);
}
......
......@@ -83,7 +83,7 @@ public:
void WriteDivider(std::ostream& os);
/** used to create a recursive make call */
std::string GetRecursiveMakeCall(const char* makefile,
std::string GetRecursiveMakeCall(const std::string& makefile,
const std::string& tgt);
// append flags to a string
......@@ -120,7 +120,7 @@ public:
std::string const& targetDir,
std::string const& relDir);
static std::string ConvertToQuotedOutputPath(const char* p,
static std::string ConvertToQuotedOutputPath(const std::string& p,
bool useWatcomQuote);
std::string CreateMakeVariable(const std::string& sin,
......@@ -128,7 +128,7 @@ public:
/** Called from command-line hook to bring dependencies up to date
for a target. */
bool UpdateDependencies(const char* tgtInfo, bool verbose,
bool UpdateDependencies(const std::string& tgtInfo, bool verbose,
bool color) override;
/** Called from command-line hook to clear dependencies. */
......@@ -158,8 +158,8 @@ public:
cmGeneratorTarget const* tgt);
void AddImplicitDepends(cmGeneratorTarget const* tgt,
const std::string& lang, const char* obj,
const char* src);
const std::string& lang, const std::string& obj,
const std::string& src);
// write the target rules for the local Makefile into the stream
void WriteLocalAllRules(std::ostream& ruleFileStream);
......@@ -200,9 +200,6 @@ protected:
void WriteDependLanguageInfo(std::ostream& cmakefileStream,
cmGeneratorTarget* tgt);
// write the local help rule
void WriteHelpRule(std::ostream& ruleFileStream);
// this converts a file name that is relative to the StartOuputDirectory
// into a full path
std::string ConvertToFullPath(const std::string& localPath);
......@@ -211,15 +208,6 @@ protected:
const std::string& realTarget,
const std::string& helpTarget);
void WriteTargetDependRule(std::ostream& ruleFileStream,
cmGeneratorTarget* target);
void WriteTargetCleanRule(std::ostream& ruleFileStream,
cmGeneratorTarget* target,
const std::vector<std::string>& files);
void WriteTargetRequiresRule(std::ostream& ruleFileStream,
cmGeneratorTarget* target,
const std::vector<std::string>& objects);
void AppendRuleDepend(std::vector<std::string>& depends,
const char* ruleFileName);
void AppendRuleDepends(std::vector<std::string>& depends,
......@@ -284,7 +272,8 @@ private:
std::map<std::string, LocalObjectInfo>& localObjectFiles);
void WriteObjectConvenienceRule(std::ostream& ruleFileStream,
const char* comment, const char* output,
const char* comment,
const std::string& output,
LocalObjectInfo const& info);
std::vector<std::string> LocalHelp;
......
......@@ -435,8 +435,8 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
objFullPath = cmSystemTools::CollapseFullPath(objFullPath);
std::string srcFullPath =
cmSystemTools::CollapseFullPath(source.GetFullPath());
this->LocalGenerator->AddImplicitDepends(
this->GeneratorTarget, lang, objFullPath.c_str(), srcFullPath.c_str());
this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, lang,
objFullPath, srcFullPath);
}
void cmMakefileTargetGenerator::WriteObjectBuildFile(
......@@ -1213,8 +1213,7 @@ void cmMakefileTargetGenerator::GenerateCustomRuleFile(
std::string objFullPath = cmSystemTools::CollapseFullPath(outputs[0]);
std::string srcFullPath = cmSystemTools::CollapseFullPath(idi.second);
this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, idi.first,
objFullPath.c_str(),
srcFullPath.c_str());
objFullPath, srcFullPath);
}
}
......@@ -1249,7 +1248,7 @@ void cmMakefileTargetGenerator::WriteObjectsVariable(
*this->BuildFileStream << " " << lineContinue << "\n";
*this->BuildFileStream
<< cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
obj.c_str(), useWatcomQuote);
obj, useWatcomQuote);
}
*this->BuildFileStream << "\n";
......@@ -1272,7 +1271,7 @@ void cmMakefileTargetGenerator::WriteObjectsVariable(
*this->BuildFileStream << " " << lineContinue << "\n";
*this->BuildFileStream
<< cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
obj.c_str(), useWatcomQuote);
obj, useWatcomQuote);
}
*this->BuildFileStream << "\n"
<< "\n";
......
......@@ -964,8 +964,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
std::unique_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator(&mf));
// Actually scan dependencies.
return lgd->UpdateDependencies(depInfo.c_str(), verbose, color) ? 0
: 2;
return lgd->UpdateDependencies(depInfo, verbose, color) ? 0 : 2;
}
return 1;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment