From d53358c350898091d9cf2ba76ccdfa9e590275ee Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Wed, 26 Feb 2025 10:16:30 +0100 Subject: Make graph-dumping options cummulative If --dump-graph or --dump-plain-graph is given several times, the action graph wil also be written several times. In this way, regular use of those options will not be affected by adding them implicitly through invocation-logging options in the rc file. --- src/buildtool/common/cli.hpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/buildtool/common/cli.hpp') diff --git a/src/buildtool/common/cli.hpp b/src/buildtool/common/cli.hpp index ef6c043c..a8acea87 100644 --- a/src/buildtool/common/cli.hpp +++ b/src/buildtool/common/cli.hpp @@ -73,8 +73,8 @@ struct AnalysisArguments { std::optional target_root; std::optional rule_root; std::optional expression_root; - std::optional graph_file; - std::optional graph_file_plain; + std::vector graph_file; + std::vector graph_file_plain; std::optional artifacts_to_build_file; std::optional serve_errors_file; }; @@ -346,16 +346,22 @@ static inline auto SetupAnalysisArguments( "errors as json.") ->type_name("PATH"); if (with_graph) { - app->add_option( + app->add_option_function( "--dump-graph", - clargs->graph_file, + [clargs](auto const& file_) { + clargs->graph_file.emplace_back(file_); + }, "File path for writing the action graph description to.") - ->type_name("PATH"); - app->add_option("--dump-plain-graph", - clargs->graph_file_plain, - "File path for writing the action graph description " - "(without origins) to.") - ->type_name("PATH"); + ->type_name("PATH") + ->trigger_on_parse(); + app->add_option_function( + "--dump-plain-graph", + [clargs](auto const& file_) { + clargs->graph_file_plain.emplace_back(file_); + }, + "File path for writing the action graph description to.") + ->type_name("PATH") + ->trigger_on_parse(); app->add_option("--dump-artifacts-to-build", clargs->artifacts_to_build_file, "File path for writing the artifacts to build to.") -- cgit v1.2.3