add_dependencies: Track backtraces internally
Record backtraces for "utility" dependencies created by `add_dependencies` calls.
This commit is contained in:
parent
a093b1a4f3
commit
a6e02f881d
@ -674,16 +674,13 @@ std::set<cmLinkItem> const& cmGeneratorTarget::GetUtilityItems() const
|
||||
{
|
||||
if (!this->UtilityItemsDone) {
|
||||
this->UtilityItemsDone = true;
|
||||
std::set<std::string> const& utilities = this->GetUtilities();
|
||||
for (std::string const& i : utilities) {
|
||||
cmListFileBacktrace const* bt = this->GetUtilityBacktrace(i);
|
||||
std::set<BT<std::string>> const& utilities = this->GetUtilities();
|
||||
for (BT<std::string> const& i : utilities) {
|
||||
if (cmGeneratorTarget* gt =
|
||||
this->LocalGenerator->FindGeneratorTargetToUse(i)) {
|
||||
this->UtilityItems.insert(
|
||||
cmLinkItem(gt, bt ? *bt : cmListFileBacktrace()));
|
||||
this->LocalGenerator->FindGeneratorTargetToUse(i.Value)) {
|
||||
this->UtilityItems.insert(cmLinkItem(gt, i.Backtrace));
|
||||
} else {
|
||||
this->UtilityItems.insert(
|
||||
cmLinkItem(i, bt ? *bt : cmListFileBacktrace()));
|
||||
this->UtilityItems.insert(cmLinkItem(i.Value, i.Backtrace));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1713,17 +1710,11 @@ cmListFileBacktrace cmGeneratorTarget::GetBacktrace() const
|
||||
return this->Target->GetBacktrace();
|
||||
}
|
||||
|
||||
const std::set<std::string>& cmGeneratorTarget::GetUtilities() const
|
||||
const std::set<BT<std::string>>& cmGeneratorTarget::GetUtilities() const
|
||||
{
|
||||
return this->Target->GetUtilities();
|
||||
}
|
||||
|
||||
const cmListFileBacktrace* cmGeneratorTarget::GetUtilityBacktrace(
|
||||
const std::string& u) const
|
||||
{
|
||||
return this->Target->GetUtilityBacktrace(u);
|
||||
}
|
||||
|
||||
bool cmGeneratorTarget::HaveWellDefinedOutputFiles() const
|
||||
{
|
||||
return this->GetType() == cmStateEnums::STATIC_LIBRARY ||
|
||||
|
@ -273,8 +273,7 @@ public:
|
||||
|
||||
cmListFileBacktrace GetBacktrace() const;
|
||||
|
||||
std::set<std::string> const& GetUtilities() const;
|
||||
cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
|
||||
std::set<BT<std::string>> const& GetUtilities() const;
|
||||
|
||||
bool LinkLanguagePropagatesToDependents() const
|
||||
{
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmGeneratorExpressionEvaluationFile.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmLocalGenerator.h"
|
||||
#include "cmLocalNinjaGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
@ -1008,10 +1009,11 @@ void cmGlobalNinjaGenerator::AppendTargetDepends(
|
||||
{
|
||||
if (target->GetType() == cmStateEnums::GLOBAL_TARGET) {
|
||||
// These depend only on other CMake-provided targets, e.g. "all".
|
||||
std::set<std::string> const& utils = target->GetUtilities();
|
||||
for (std::string const& util : utils) {
|
||||
std::set<BT<std::string>> const& utils = target->GetUtilities();
|
||||
for (BT<std::string> const& util : utils) {
|
||||
std::string d =
|
||||
target->GetLocalGenerator()->GetCurrentBinaryDirectory() + "/" + util;
|
||||
target->GetLocalGenerator()->GetCurrentBinaryDirectory() + "/" +
|
||||
util.Value;
|
||||
outputs.push_back(this->ConvertToNinjaPath(d));
|
||||
}
|
||||
} else {
|
||||
|
@ -159,7 +159,7 @@ void cmGlobalVisualStudio71Generator::WriteProjectDepends(
|
||||
// executables to the libraries it uses are also done here
|
||||
void cmGlobalVisualStudio71Generator::WriteExternalProject(
|
||||
std::ostream& fout, const std::string& name, const char* location,
|
||||
const char* typeGuid, const std::set<std::string>& depends)
|
||||
const char* typeGuid, const std::set<BT<std::string>>& depends)
|
||||
{
|
||||
fout << "Project(\"{"
|
||||
<< (typeGuid ? typeGuid : this->ExternalProjectType(location))
|
||||
@ -171,9 +171,10 @@ void cmGlobalVisualStudio71Generator::WriteExternalProject(
|
||||
// project instead of in the global section
|
||||
if (!depends.empty()) {
|
||||
fout << "\tProjectSection(ProjectDependencies) = postProject\n";
|
||||
for (std::string const& it : depends) {
|
||||
if (!it.empty()) {
|
||||
fout << "\t\t{" << this->GetGUID(it) << "} = {" << this->GetGUID(it)
|
||||
for (BT<std::string> const& it : depends) {
|
||||
std::string const& dep = it.Value;
|
||||
if (!dep.empty()) {
|
||||
fout << "\t\t{" << this->GetGUID(dep) << "} = {" << this->GetGUID(dep)
|
||||
<< "}\n";
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ protected:
|
||||
const std::string& platformMapping = "") override;
|
||||
void WriteExternalProject(std::ostream& fout, const std::string& name,
|
||||
const char* path, const char* typeGuid,
|
||||
const std::set<std::string>& depends) override;
|
||||
const std::set<BT<std::string>>& depends) override;
|
||||
void WriteSLNHeader(std::ostream& fout) override;
|
||||
|
||||
// Folders are not supported by VS 7.1.
|
||||
|
@ -145,7 +145,7 @@ protected:
|
||||
|
||||
virtual void WriteExternalProject(
|
||||
std::ostream& fout, const std::string& name, const char* path,
|
||||
const char* typeGuid, const std::set<std::string>& dependencies) = 0;
|
||||
const char* typeGuid, const std::set<BT<std::string>>& dependencies) = 0;
|
||||
|
||||
std::string ConvertToSolutionPath(const char* path);
|
||||
|
||||
|
@ -315,9 +315,9 @@ bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies(
|
||||
cmGeneratorTarget* target)
|
||||
{
|
||||
// Look for utility dependencies that magically link.
|
||||
for (std::string const& ui : target->GetUtilities()) {
|
||||
for (BT<std::string> const& ui : target->GetUtilities()) {
|
||||
if (cmGeneratorTarget* depTarget =
|
||||
target->GetLocalGenerator()->FindGeneratorTargetToUse(ui)) {
|
||||
target->GetLocalGenerator()->FindGeneratorTargetToUse(ui.Value)) {
|
||||
if (depTarget->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
|
||||
depTarget->GetProperty("EXTERNAL_MSPROJECT")) {
|
||||
// This utility dependency names an external .vcproj target.
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmGlobalUnixMakefileGenerator3.h"
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmLocalGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMakefileTargetGenerator.h"
|
||||
@ -1546,8 +1547,10 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
|
||||
if (!text) {
|
||||
text = "Running external command ...";
|
||||
}
|
||||
depends.insert(depends.end(), gt->GetUtilities().begin(),
|
||||
gt->GetUtilities().end());
|
||||
depends.reserve(gt->GetUtilities().size());
|
||||
for (BT<std::string> const& u : gt->GetUtilities()) {
|
||||
depends.push_back(u.Value);
|
||||
}
|
||||
this->AppendEcho(commands, text,
|
||||
cmLocalUnixMakefileGenerator3::EchoGlobal);
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmLinkItem.h"
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmLocalGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmOutputConverter.h"
|
||||
@ -940,8 +941,8 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
|
||||
new cmGeneratorTarget(autogenTarget, localGen));
|
||||
|
||||
// Forward origin utilities to autogen target
|
||||
for (std::string const& depName : this->Target->Target->GetUtilities()) {
|
||||
autogenTarget->AddUtility(depName, makefile);
|
||||
for (BT<std::string> const& depName : this->Target->GetUtilities()) {
|
||||
autogenTarget->AddUtility(depName.Value, makefile);
|
||||
}
|
||||
// Add additional autogen target dependencies to autogen target
|
||||
for (cmTarget* depTarget : this->AutogenTarget.DependTargets) {
|
||||
|
@ -486,24 +486,10 @@ cmGlobalGenerator* cmTarget::GetGlobalGenerator() const
|
||||
return this->GetMakefile()->GetGlobalGenerator();
|
||||
}
|
||||
|
||||
void cmTarget::AddUtility(const std::string& u, cmMakefile* makefile)
|
||||
void cmTarget::AddUtility(std::string const& u, cmMakefile* mf)
|
||||
{
|
||||
if (this->Utilities.insert(u).second && makefile) {
|
||||
this->UtilityBacktraces.insert(
|
||||
std::make_pair(u, makefile->GetBacktrace()));
|
||||
}
|
||||
}
|
||||
|
||||
cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(
|
||||
const std::string& u) const
|
||||
{
|
||||
std::map<std::string, cmListFileBacktrace>::const_iterator i =
|
||||
this->UtilityBacktraces.find(u);
|
||||
if (i == this->UtilityBacktraces.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &i->second;
|
||||
BT<std::string> util(u, mf ? mf->GetBacktrace() : cmListFileBacktrace());
|
||||
this->Utilities.insert(util);
|
||||
}
|
||||
|
||||
cmListFileBacktrace const& cmTarget::GetBacktrace() const
|
||||
|
@ -190,10 +190,12 @@ public:
|
||||
* name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE
|
||||
* commands. It is not a full path nor does it have an extension.
|
||||
*/
|
||||
void AddUtility(const std::string& u, cmMakefile* makefile = nullptr);
|
||||
void AddUtility(std::string const& u, cmMakefile* mf = nullptr);
|
||||
///! Get the utilities used by this target
|
||||
std::set<std::string> const& GetUtilities() const { return this->Utilities; }
|
||||
cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
|
||||
std::set<BT<std::string>> const& GetUtilities() const
|
||||
{
|
||||
return this->Utilities;
|
||||
}
|
||||
|
||||
///! Set/Get a property of this target file
|
||||
void SetProperty(const std::string& prop, const char* value);
|
||||
@ -307,8 +309,7 @@ private:
|
||||
bool IsGeneratorProvided;
|
||||
cmPropertyMap Properties;
|
||||
std::set<std::string> SystemIncludeDirectories;
|
||||
std::set<std::string> Utilities;
|
||||
std::map<std::string, cmListFileBacktrace> UtilityBacktraces;
|
||||
std::set<BT<std::string>> Utilities;
|
||||
cmPolicies::PolicyMap PolicyMap;
|
||||
std::string Name;
|
||||
std::string InstallPath;
|
||||
|
Loading…
Reference in New Issue
Block a user