mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: David Hunter <david.hunter.linux@gmail.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>,
	linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	shuah@kernel.org, javier.carrasco.cruz@gmail.com
Subject: Re: [PATCH v2 5/7] streamline_config.pl: fix: implement choice for kconfigs
Date: Thu, 17 Oct 2024 18:32:35 -0400	[thread overview]
Message-ID: <20241017183235.2d8930a2@gandalf.local.home> (raw)
In-Reply-To: <20241014141345.5680-6-david.hunter.linux@gmail.com>

On Mon, 14 Oct 2024 10:13:35 -0400
David Hunter <david.hunter.linux@gmail.com> wrote:

> Properly implement the config entries that are within the choice keyword
> for kconfig. Currently, the script only stops the previous config entry
> when a choice keyword is encountered.
> 
> When the keyword "choice" is encountered, do the following:
>         - distribute the lines immediately following the "choice"
>           keyword to each config entry inside the "choice" section.
>         - process the config entries with the distributed lines.
> 
> Signed-off-by: David Hunter <david.hunter.linux@gmail.com>
> ---
> V1 https://lore.kernel.org/all/20240913171205.22126-6-david.hunter.linux@gmail.com/
> 
> V2 
> 	- changed the subject prefix
> 	- changed the method for storing and distributing the choice
> 	  block. No longer using temp file. 
> ---
>  scripts/kconfig/streamline_config.pl | 47 ++++++++++++++++++++++++++--
>  1 file changed, 45 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
> index b7ed79c5e070..4149c4b344db 100755
> --- a/scripts/kconfig/streamline_config.pl
> +++ b/scripts/kconfig/streamline_config.pl
> @@ -149,6 +149,34 @@ my $var;
>  my $iflevel = 0;
>  my @ifdeps;
>  
> +# distributes choice entries to different config options
> +sub set_hash_value {
> +    my %htable = %{$_[0]};
> +    my $tmp_config = $_[1];
> +    my $current_config = $_[2];

The other functions usually make this a single line. Also, we should give
names for all parameters.

  sub set_hash_value {
      my ($phtable, $tmp_config, $current_config) = @_;
      my %htable = %{$phtable};
      if (defined($htable{$tmp_config})) {
          ${$phtable}{$current_config} = $htable{$tmp_config};
      }
  }

Names make it a bit easier to read. Perl is already know as being very
cryptic, we don't need to make it worse.

> +    if (defined($htable{$tmp_config})) {
> +	${$_[0]}{$current_config} = $htable{$tmp_config};
> +    }
> +}
> +
> +# distribute choice config entries
> +sub copy_configs {
> +    my $tmp_config = "TMP_CONFIG";
> +    my $choice_config = $_[0];

And this as:

  sub copy_configs {
     my ($choice_config) = $@;
     my $tmp_config = "TMP_CONFIG"

As parameters should always be first, which is how the rest of the file
does it. Consistency would be good.

-- Steve

> +    set_hash_value (\%depends, $tmp_config, $choice_config);
> +    set_hash_value (\%selects, $tmp_config, $choice_config);
> +    set_hash_value (\%prompts, $tmp_config, $choice_config);
> +    set_hash_value (\%defaults, $tmp_config, $choice_config);
> +}
> +
> +sub delete_temp_config {
> +    my $tmp_config = "TMP_CONFIG";
> +    $depends{$tmp_config} = undef;
> +    $selects{$tmp_config} = undef;
> +    $prompts{$tmp_config} = undef;
> +    $defaults{$tmp_config} = undef;
> +}
> +
>  # prevent recursion
>  my %read_kconfigs;
>  
> @@ -163,6 +191,7 @@ sub read_kconfig {
>  
>      my $source = "$ksource/$kconfig";
>      my $last_source = "";
> +    my $choice_activated = 0;
>  
>      # Check for any environment variables used
>      while ($source =~ /\$\((\w+)\)/ && $last_source ne $source) {
> @@ -205,9 +234,13 @@ sub read_kconfig {
>  	    $config = $2;
>  	    $config2kfile{"CONFIG_$config"} = $kconfig;
>  
> +	    if ($choice_activated) {
> +		copy_configs $config;
> +	    }
> +
>  	    # Add depends for 'if' nesting
>  	    for (my $i = 0; $i < $iflevel; $i++) {
> -		if ($i) {
> +		if (defined($depends{$config})) {
>  		    $depends{$config} .= " " . $ifdeps[$i];
>  		} else {
>  		    $depends{$config} = $ifdeps[$i];
> @@ -260,8 +293,18 @@ sub read_kconfig {
>  	    $iflevel-- if ($iflevel);
>  
>  	# stop on "help" and keywords that end a menu entry
> -	} elsif (/^\s*(---)?help(---)?\s*$/ ||
> /^(comment|choice|menu)\b/) {
> +	} elsif (/^\s*(---)?help(---)?\s*$/ || /^(comment|menu)\b/) {
>  	    $state = "NONE";
> +
> +	# for choice, distribute the lines before each config entry to
> +	# each config entry
> +	} elsif (/^\s*choice\b/) {
> +	    $choice_activated = 1;
> +	    $config = "TMP_CONFIG";
> +	    $state = "NEW";
> +	} elsif (/^\s*endchoice/) {
> +	    delete_temp_config;
> +	    $choice_activated = 0;
>  	}
>      }
>      close($kinfile);


  reply	other threads:[~2024-10-17 22:32 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-14 14:13 [PATCH v3 0/7] streamline_config.pl: fix: process configs set to "y" David Hunter
2024-10-14 14:13 ` [PATCH v2 1/7] streamline_config.pl: fix missing variable operator in debug print David Hunter
2024-11-05 23:05   ` Masahiro Yamada
2024-10-14 14:13 ` [PATCH v2 2/7] streamline_config.pl: ensure all defaults are tracked David Hunter
2024-10-15 23:09   ` Steven Rostedt
2024-11-05 23:05     ` Masahiro Yamada
2024-11-26 23:48       ` David Hunter
2024-11-27  1:09         ` Steven Rostedt
2024-11-05 23:05   ` Masahiro Yamada
2024-10-14 14:13 ` [PATCH v2 3/7] streamline_config.pl: remove prompt warnings for configs with defaults David Hunter
2024-11-05 23:13   ` Masahiro Yamada
2024-10-14 14:13 ` [PATCH v1 4/7] streamline_config.pl: include tool to learn about a config option David Hunter
2024-11-05 23:15   ` Masahiro Yamada
2024-10-14 14:13 ` [PATCH v2 5/7] streamline_config.pl: fix: implement choice for kconfigs David Hunter
2024-10-17 22:32   ` Steven Rostedt [this message]
2024-11-05 23:33   ` Masahiro Yamada
2024-11-27 13:18     ` David Hunter
2024-11-30  9:41       ` Masahiro Yamada
2024-10-14 14:13 ` [PATCH v2 6/7] streamline_config.pl: process config options set to "y" David Hunter
2024-10-15 23:20   ` Steven Rostedt
2024-11-05 23:44     ` Masahiro Yamada
2024-10-14 14:13 ` [PATCH v2 7/7] streamline_config.pl: check prompt for bool options David Hunter
2024-11-05 23:45   ` Masahiro Yamada
2024-11-27 13:26     ` David Hunter
2024-11-27 22:50       ` Masahiro Yamada
2024-11-28 15:04         ` David Hunter
2024-10-17 22:37 ` [PATCH v3 0/7] streamline_config.pl: fix: process configs set to "y" Steven Rostedt
2024-10-18 14:30   ` Steven Rostedt
2024-11-27 23:05     ` David Hunter
2024-11-27 23:26       ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241017183235.2d8930a2@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=david.hunter.linux@gmail.com \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®