Skip to content

Commit

Permalink
Added support for reporting locations of target and target-related st…
Browse files Browse the repository at this point in the history
…atements
  • Loading branch information
sysprogs committed Jun 17, 2017
1 parent 0d5a225 commit 774def2
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions Source/cmServerProtocol.cxx
Expand Up @@ -727,6 +727,43 @@ static Json::Value DumpSourceFilesList(
return result;
}

static const std::string kTARGET_CROSS_REFERENCES_KEY = "crossReferences";
static const std::string kLINE_NUMBER_KEY = "lineNumber";
static const std::string kBACKTRACE_KEY = "backtrace";
static const std::string kSTATEMENT_TYPE_KEY = "statementType";
static const std::string kSTATEMENT_VALUE_KEY = "statementValue";

static const std::string kRELATED_STATEMENTS_KEY = "relatedStatements";

static Json::Value DumpBacktrace(const cmListFileBacktrace &backtrace)
{
Json::Value result = Json::arrayValue;

cmListFileBacktrace backtraceCopy = backtrace;
while (!backtraceCopy.Top().FilePath.empty())
{
Json::Value entry = Json::objectValue;
entry[kPATH_KEY] = backtraceCopy.Top().FilePath;
entry[kLINE_NUMBER_KEY] = backtraceCopy.Top().Line;
entry[kNAME_KEY] = backtraceCopy.Top().Name;
result.append(std::move(entry));
backtraceCopy = backtraceCopy.Pop();
}
return std::move(result);
}

static void DumpBacktraceRange(Json::Value &result, const std::string &type, const cmBacktraceRange &range)
{
for (const auto &bt : range)
{
Json::Value obj = Json::objectValue;
obj[kSTATEMENT_TYPE_KEY] = type;
obj[kBACKTRACE_KEY] = DumpBacktrace(bt);
result.append(obj);
}
}


static Json::Value DumpTarget(cmGeneratorTarget* target,
const std::string& config)
{
Expand Down Expand Up @@ -761,6 +798,21 @@ static Json::Value DumpTarget(cmGeneratorTarget* target,

result[kFULL_NAME_KEY] = target->GetFullName(config);

if (true)
{
Json::Value crossRefs = Json::objectValue;
crossRefs[kBACKTRACE_KEY] = DumpBacktrace(target->Target->GetBacktrace());

Json::Value statements = Json::arrayValue;
DumpBacktraceRange(statements, "target_compile_definitions", target->Target->GetCompileDefinitionsBacktraces());
DumpBacktraceRange(statements, "target_include_directories", target->Target->GetIncludeDirectoriesBacktraces());
DumpBacktraceRange(statements, "target_compile_options", target->Target->GetCompileOptionsBacktraces());
DumpBacktraceRange(statements, "target_link_libraries", target->Target->GetLinkImplementationBacktraces());

crossRefs[kRELATED_STATEMENTS_KEY] = std::move(statements);
result[kTARGET_CROSS_REFERENCES_KEY] = std::move(crossRefs);
}

if (target->HaveWellDefinedOutputFiles()) {
Json::Value artifacts = Json::arrayValue;
artifacts.append(target->GetFullPath(config, false));
Expand Down

0 comments on commit 774def2

Please sign in to comment.