diff options
-rw-r--r-- | share/man/just.1.org | 9 | ||||
-rw-r--r-- | src/buildtool/common/cli.hpp | 6 | ||||
-rw-r--r-- | src/buildtool/main/main.cpp | 26 |
3 files changed, 41 insertions, 0 deletions
diff --git a/share/man/just.1.org b/share/man/just.1.org index 4e0fd284..c9008763 100644 --- a/share/man/just.1.org +++ b/share/man/just.1.org @@ -448,6 +448,15 @@ well-defined graph file. See *just-graph-file(5)* for more details. Dump nodes of only the given target to file. ~-~ is treated as stdout. Output is a JSON map between node id and its description. + *--dump-vars* PATH\\ + Dump configuration variables to file. ~-~ is treated as + stdout. The output is a JSON list of those variable names (in + lexicographic order) at which the configuration influenced the + analysis of this target. This might contain variables unset + in the configuraiton if the fact that they were unset (and + hence treated as the default ~null~) was relevant for the + analysis of that target. + *--dump-targets* PATH\\ Dump all transitive targets to file for the given target. ~-~ is treated as stdout. Output is a JSON map of all targets encoded as diff --git a/src/buildtool/common/cli.hpp b/src/buildtool/common/cli.hpp index 593d0a7c..f7ed66db 100644 --- a/src/buildtool/common/cli.hpp +++ b/src/buildtool/common/cli.hpp @@ -75,6 +75,7 @@ struct DiagnosticArguments { std::optional<std::string> dump_actions{std::nullopt}; std::optional<std::string> dump_blobs{std::nullopt}; std::optional<std::string> dump_trees{std::nullopt}; + std::optional<std::string> dump_vars{std::nullopt}; std::optional<std::string> dump_targets{std::nullopt}; std::optional<std::string> dump_targets_graph{std::nullopt}; std::optional<std::string> dump_anonymous{std::nullopt}; @@ -267,6 +268,11 @@ static inline auto SetupDiagnosticArguments( clargs->dump_blobs, "Dump blobs to file (use - for stdout).") ->type_name("PATH"); + app->add_option("--dump-vars", + clargs->dump_vars, + "Dump domain of the effective configuraiton to file (use - " + "for stdout).") + ->type_name("PATH"); app->add_option("--dump-targets", clargs->dump_targets, "Dump targets to file (use - for stdout).") diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index ac74fdce..ded21591 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -746,6 +746,29 @@ void DumpBlobs(std::string const& file_path, AnalysisResult const& result) { } } +void DumpVars(std::string const& file_path, AnalysisResult const& result) { + auto vars = std::vector<std::string>{}; + vars.reserve(result.target->Vars().size()); + for (auto const& x : result.target->Vars()) { + vars.push_back(x); + } + std::sort(vars.begin(), vars.end()); + auto const dump_string = nlohmann::json(vars).dump(); + if (file_path == "-") { + Logger::Log( + LogLevel::Info, "Variables for target {}:", result.id.ToString()); + std::cout << dump_string << std::endl; + } + else { + Logger::Log(LogLevel::Info, + "Dumping varables for target {} to file '{}'.", + result.id.ToString(), + file_path); + std::ofstream os(file_path); + os << dump_string << std::endl; + } +} + void DumpTrees(std::string const& file_path, AnalysisResult const& result) { auto const dump_string = TreesToJson(result.target).dump(2); if (file_path == "-") { @@ -912,6 +935,9 @@ void DumpNodes(std::string const& file_path, AnalysisResult const& result) { if (clargs.dump_trees) { DumpTrees(*clargs.dump_trees, result); } + if (clargs.dump_vars) { + DumpVars(*clargs.dump_vars, result); + } if (clargs.dump_targets) { DumpTargets(*clargs.dump_targets, result_map.ConfiguredTargets()); } |