summaryrefslogtreecommitdiff
path: root/src/buildtool/profile/profile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildtool/profile/profile.cpp')
-rw-r--r--src/buildtool/profile/profile.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/buildtool/profile/profile.cpp b/src/buildtool/profile/profile.cpp
index 225542e6..22d6d89e 100644
--- a/src/buildtool/profile/profile.cpp
+++ b/src/buildtool/profile/profile.cpp
@@ -18,6 +18,7 @@
#include "gsl/gsl"
#include "src/buildtool/common/artifact_digest.hpp"
+#include "src/buildtool/common/cli.hpp"
#include "src/utils/cpp/expected.hpp"
void Profile::Write(int exit_code) {
@@ -62,6 +63,42 @@ void Profile::SetConfiguration(nlohmann::json configuration) {
profile_["configuration"] = std::move(configuration);
}
+void Profile::SetCLI(CommandLineArguments const& cli) {
+ switch (cli.cmd) {
+ case SubCommand::kDescribe:
+ profile_["subcommand"] = "describe";
+ break;
+ case SubCommand::kAnalyse:
+ profile_["subcommand"] = "analyse";
+ break;
+ case SubCommand::kBuild:
+ profile_["subcommand"] = "build";
+ break;
+ case SubCommand::kInstall:
+ profile_["subcommand"] = "install";
+ break;
+ case SubCommand::kRebuild:
+ profile_["subcommand"] = "rebuild";
+ break;
+ default:
+ // We only log information on the commands that support profiling.
+ return;
+ }
+ if (cli.analysis.target) {
+ if (cli.analysis.target->is_array()) {
+ profile_["subcommand args"] = *cli.analysis.target;
+ }
+ else {
+ auto args = nlohmann::json::array();
+ args.push_back(*cli.analysis.target);
+ profile_["subcommand args"] = args;
+ }
+ }
+ else {
+ profile_["subcommand args"] = nlohmann::json::array();
+ }
+}
+
void Profile::NoteActionCompleted(std::string const& id,
IExecutionResponse::Ptr const& response) {
std::unique_lock lock{mutex_};