|
|
@@ -23,8 +23,7 @@
|
|
|
#include "cmSystemTools.h"
|
|
|
#include "cmTimestamp.h"
|
|
|
|
|
|
-cmInstrumentation::cmInstrumentation(std::string const& binary_dir,
|
|
|
- bool clear_generated)
|
|
|
+cmInstrumentation::cmInstrumentation(std::string const& binary_dir)
|
|
|
{
|
|
|
std::string const uuid =
|
|
|
cmExperimental::DataForFeature(cmExperimental::Feature::Instrumentation)
|
|
|
@@ -32,9 +31,6 @@ cmInstrumentation::cmInstrumentation(std::string const& binary_dir,
|
|
|
this->binaryDir = binary_dir;
|
|
|
this->timingDirv1 =
|
|
|
cmStrCat(this->binaryDir, "/.cmake/instrumentation-", uuid, "/v1");
|
|
|
- if (clear_generated) {
|
|
|
- this->ClearGeneratedQueries();
|
|
|
- }
|
|
|
if (cm::optional<std::string> configDir =
|
|
|
cmSystemTools::GetCMakeConfigDirectory()) {
|
|
|
this->userTimingDirv1 =
|
|
|
@@ -57,24 +53,6 @@ void cmInstrumentation::LoadQueries()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-cmInstrumentation::cmInstrumentation(
|
|
|
- std::string const& binary_dir,
|
|
|
- std::set<cmInstrumentationQuery::Query>& queries_,
|
|
|
- std::set<cmInstrumentationQuery::Hook>& hooks_, std::string& callback)
|
|
|
-{
|
|
|
- this->binaryDir = binary_dir;
|
|
|
- this->timingDirv1 = cmStrCat(
|
|
|
- this->binaryDir, "/.cmake/instrumentation-",
|
|
|
- cmExperimental::DataForFeature(cmExperimental::Feature::Instrumentation)
|
|
|
- .Uuid,
|
|
|
- "/v1");
|
|
|
- this->queries = queries_;
|
|
|
- this->hooks = hooks_;
|
|
|
- if (!callback.empty()) {
|
|
|
- this->callbacks.push_back(callback);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
bool cmInstrumentation::ReadJSONQueries(std::string const& directory)
|
|
|
{
|
|
|
cmsys::Directory d;
|
|
|
@@ -99,20 +77,22 @@ void cmInstrumentation::ReadJSONQuery(std::string const& file)
|
|
|
this->callbacks);
|
|
|
}
|
|
|
|
|
|
-void cmInstrumentation::WriteJSONQuery()
|
|
|
+void cmInstrumentation::WriteJSONQuery(
|
|
|
+ std::set<cmInstrumentationQuery::Query>& queries_,
|
|
|
+ std::set<cmInstrumentationQuery::Hook>& hooks_, std::string& callback)
|
|
|
{
|
|
|
Json::Value root;
|
|
|
root["version"] = 1;
|
|
|
root["queries"] = Json::arrayValue;
|
|
|
- for (auto const& query : this->queries) {
|
|
|
+ for (auto const& query : queries_) {
|
|
|
root["queries"].append(cmInstrumentationQuery::QueryString[query]);
|
|
|
}
|
|
|
root["hooks"] = Json::arrayValue;
|
|
|
- for (auto const& hook : this->hooks) {
|
|
|
+ for (auto const& hook : hooks_) {
|
|
|
root["hooks"].append(cmInstrumentationQuery::HookString[hook]);
|
|
|
}
|
|
|
root["callbacks"] = Json::arrayValue;
|
|
|
- for (auto const& callback : this->callbacks) {
|
|
|
+ if (!callback.empty()) {
|
|
|
root["callbacks"].append(callback);
|
|
|
}
|
|
|
cmsys::Directory d;
|
|
|
@@ -132,16 +112,27 @@ void cmInstrumentation::ClearGeneratedQueries()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-bool cmInstrumentation::HasQuery()
|
|
|
+bool cmInstrumentation::HasQuery() const
|
|
|
{
|
|
|
return this->hasQuery;
|
|
|
}
|
|
|
|
|
|
-bool cmInstrumentation::HasQuery(cmInstrumentationQuery::Query query)
|
|
|
+bool cmInstrumentation::HasQuery(cmInstrumentationQuery::Query query) const
|
|
|
{
|
|
|
return (this->queries.find(query) != this->queries.end());
|
|
|
}
|
|
|
|
|
|
+bool cmInstrumentation::HasHook(cmInstrumentationQuery::Hook hook) const
|
|
|
+{
|
|
|
+ return (this->hooks.find(hook) != this->hooks.end());
|
|
|
+}
|
|
|
+
|
|
|
+bool cmInstrumentation::HasPreOrPostBuildHook() const
|
|
|
+{
|
|
|
+ return (this->HasHook(cmInstrumentationQuery::Hook::PreBuild) ||
|
|
|
+ this->HasHook(cmInstrumentationQuery::Hook::PostBuild));
|
|
|
+}
|
|
|
+
|
|
|
int cmInstrumentation::CollectTimingData(cmInstrumentationQuery::Hook hook)
|
|
|
{
|
|
|
// Don't run collection if hook is disabled
|