summaryrefslogtreecommitdiff
path: root/src/buildtool/profile/profile.cpp
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2025-04-15 13:29:31 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2025-04-16 13:09:11 +0200
commit112ff1861873de1eb2c40b521346ddb3db8b2fd3 (patch)
treed6ed02e3c31419a11136f38beb6a2cffe2794024 /src/buildtool/profile/profile.cpp
parentbed0e82c24b123799764309a2468ccfe7eee8adc (diff)
downloadjustbuild-112ff1861873de1eb2c40b521346ddb3db8b2fd3.tar.gz
just profile: include subcommand and its arguments
As parsing the the command-line is non-trivial, we include all the relevant information about the command line in the profile. This should also include the subcommand. For sake of completeness, we also include the non-option arguments of the subcommand.
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_};