diff options
-rw-r--r-- | share/man/just-profile.5.md | 5 | ||||
-rw-r--r-- | src/buildtool/main/main.cpp | 1 | ||||
-rw-r--r-- | src/buildtool/profile/TARGETS | 2 | ||||
-rw-r--r-- | src/buildtool/profile/profile.cpp | 37 | ||||
-rw-r--r-- | src/buildtool/profile/profile.hpp | 2 |
5 files changed, 47 insertions, 0 deletions
diff --git a/share/man/just-profile.5.md b/share/man/just-profile.5.md index c04712af..a7da6d25 100644 --- a/share/man/just-profile.5.md +++ b/share/man/just-profile.5.md @@ -34,6 +34,11 @@ Profile file The profile file contains the following information. +- For the key *`"subcommand"`* the subcommand that was executed. + +- For the key *`"subcommand args"`* the positional arguments that were + provided for that subcommand. + - For the key *`"target"`* the target that was analysed/built/installed, as full qualified name. diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index 75c7ca73..7a7dc3f4 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -917,6 +917,7 @@ auto main(int argc, char* argv[]) -> int { Profile profile_data(arguments.analysis.profile); if (arguments.analysis.profile) { profile = &profile_data; + (*profile)->SetCLI(arguments); } // If no execution endpoint was given, the client should default to the diff --git a/src/buildtool/profile/TARGETS b/src/buildtool/profile/TARGETS index 9f4db4d8..318ed075 100644 --- a/src/buildtool/profile/TARGETS +++ b/src/buildtool/profile/TARGETS @@ -6,9 +6,11 @@ , "deps": [ ["@", "json", "", "json"] , ["src/buildtool/execution_api/common", "common"] + , ["src/buildtool/main", "cli"] ] , "private-deps": [ ["@", "gsl", "", "gsl"] + , ["src/buildtool/common", "cli"] , ["src/buildtool/common", "common"] , ["src/utils/cpp", "expected"] ] 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_}; diff --git a/src/buildtool/profile/profile.hpp b/src/buildtool/profile/profile.hpp index d90ad2a5..20360d3f 100644 --- a/src/buildtool/profile/profile.hpp +++ b/src/buildtool/profile/profile.hpp @@ -24,6 +24,7 @@ #include "nlohmann/json.hpp" #include "src/buildtool/execution_api/common/execution_response.hpp" +#include "src/buildtool/main/cli.hpp" class Profile { public: @@ -33,6 +34,7 @@ class Profile { } void Write(int exit_code); + void SetCLI(CommandLineArguments const& cli); void SetTarget(nlohmann::json target); void SetConfiguration(nlohmann::json configuration); void NoteActionCompleted(std::string const& id, |