From ea6650131119339276bfd006929462d31199173f Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 22 Feb 2022 15:46:19 -0500 Subject: [PATCH] Show variants in -T output --- lib/rscons/application.rb | 11 ++++++++++- spec/build_tests_spec.rb | 31 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/lib/rscons/application.rb b/lib/rscons/application.rb index 9b3d817..b8cdf0d 100644 --- a/lib/rscons/application.rb +++ b/lib/rscons/application.rb @@ -69,12 +69,12 @@ module Rscons end @script = Script.new @script.load(rsconscript) + enable_variants if show_tasks show_script_tasks return 0 end apply_task_params(tasks_and_params) - enable_variants if tasks_and_params.empty? check_process_environments if Task.tasks["default"] @@ -354,6 +354,15 @@ module Rscons end end end + + unless @variant_groups.empty? + @variant_groups.each do |variant_group| + puts "\nVariant group#{variant_group[:name] ? " '#{variant_group[:name]}'" : ""}:" + variant_group[:variants].each do |variant| + puts " #{variant[:name]}#{variant[:enabled] ? " (enabled)" : ""}" + end + end + end end def apply_task_params(tasks_and_params) diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index 6f23e3a..8c7b3ee 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -3185,6 +3185,37 @@ EOF expect(result.stdout).to match %r{two enabled} expect(result.stdout).to_not match %r{three enabled} end + + it "shows available variants with -T" do + test_dir "variants" + + result = run_rscons(args: %w[-f multiple_groups.rb -T]) + expect(result.stderr).to eq "" + expect(result.status).to eq 0 + verify_lines(lines(result.stdout), [ + "Variant group 'desktop-environment':", + " kde (enabled)", + " gnome (enabled)", + "Variant group 'debug':", + " debug (enabled)", + " release (enabled)", + ]) + + result = run_rscons(args: %w[-f multiple_groups.rb -e gnome,release configure]) + expect(result.stderr).to eq "" + expect(result.status).to eq 0 + result = run_rscons(args: %w[-f multiple_groups.rb -T]) + expect(result.stderr).to eq "" + expect(result.status).to eq 0 + verify_lines(lines(result.stdout), [ + "Variant group 'desktop-environment':", + " kde", + " gnome (enabled)", + "Variant group 'debug':", + " debug", + " release (enabled)", + ]) + end end context "build_dir method" do