diff options
-rw-r--r-- | scripts/kconfig/streamline_config.pl | 115 |
1 files changed, 104 insertions, 11 deletions
diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index ab4985f7af79..fcfcb302b0d7 100644 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl | |||
@@ -420,7 +420,7 @@ my $repeat = 1; | |||
420 | # to keep on. If A was on in the original config, B would not have been | 420 | # to keep on. If A was on in the original config, B would not have been |
421 | # and B would not be turned on by this script. | 421 | # and B would not be turned on by this script. |
422 | # | 422 | # |
423 | sub parse_config_dep_select | 423 | sub parse_config_depends |
424 | { | 424 | { |
425 | my ($p) = @_; | 425 | my ($p) = @_; |
426 | 426 | ||
@@ -448,26 +448,119 @@ sub parse_config_dep_select | |||
448 | } | 448 | } |
449 | } | 449 | } |
450 | 450 | ||
451 | while ($repeat) { | 451 | # Select is treated a bit differently than depends. We call this |
452 | $repeat = 0; | 452 | # when a config has no prompt and requires another config to be |
453 | # selected. We use to just select all configs that selected this | ||
454 | # config, but found that that can balloon into enabling hundreds | ||
455 | # of configs that we do not care about. | ||
456 | # | ||
457 | # The idea is we look at all the configs that select it. If one | ||
458 | # is already in our list of configs to enable, then there's nothing | ||
459 | # else to do. If there isn't, we pick the first config that was | ||
460 | # enabled in the orignal config and use that. | ||
461 | sub parse_config_selects | ||
462 | { | ||
463 | my ($config, $p) = @_; | ||
453 | 464 | ||
454 | foreach my $config (keys %configs) { | 465 | my $next_config; |
455 | $config =~ s/^CONFIG_//; | 466 | |
467 | while ($p =~ /[$valid]/) { | ||
468 | |||
469 | if ($p =~ /^[^$valid]*([$valid]+)/) { | ||
470 | my $conf = "CONFIG_" . $1; | ||
471 | |||
472 | $p =~ s/^[^$valid]*[$valid]+//; | ||
456 | 473 | ||
457 | if (defined($depends{$config})) { | 474 | # Make sure that this config exists in the current .config file |
458 | # This config has dependencies. Make sure they are also included | 475 | if (!defined($orig_configs{$conf})) { |
459 | parse_config_dep_select $depends{$config}; | 476 | next; |
477 | } | ||
478 | |||
479 | # Check if something other than a module selects this config | ||
480 | if (defined($orig_configs{$conf}) && $orig_configs{$conf} ne "m") { | ||
481 | # we are good with this | ||
482 | return; | ||
483 | } | ||
484 | if (defined($configs{$conf})) { | ||
485 | # A set config selects this config, we are good | ||
486 | return; | ||
487 | } | ||
488 | # Set this config to be selected | ||
489 | if (!defined($next_config)) { | ||
490 | $next_config = $conf; | ||
491 | } | ||
492 | } else { | ||
493 | die "this should never happen"; | ||
460 | } | 494 | } |
495 | } | ||
461 | 496 | ||
462 | if (defined($prompts{$config}) || !defined($selects{$config})) { | 497 | # If no possible config selected this, then something happened. |
463 | next; | 498 | if (!defined($next_config)) { |
499 | print STDERR "WARNING: $config is required, but nothing in the\n"; | ||
500 | print STDERR " current config selects it.\n"; | ||
501 | return; | ||
502 | } | ||
503 | |||
504 | # If we are here, then we found no config that is set and | ||
505 | # selects this config. Repeat. | ||
506 | $repeat = 1; | ||
507 | # Make this config need to be selected | ||
508 | $configs{$next_config} = 1; | ||
509 | } | ||
510 | |||
511 | my %process_selects; | ||
512 | |||
513 | # loop through all configs, select their dependencies. | ||
514 | sub loop_depend { | ||
515 | $repeat = 1; | ||
516 | |||
517 | while ($repeat) { | ||
518 | $repeat = 0; | ||
519 | |||
520 | forloop: | ||
521 | foreach my $config (keys %configs) { | ||
522 | |||
523 | # If this config is not a module, we do not need to process it | ||
524 | if (defined($orig_configs{$config}) && $orig_configs{$config} ne "m") { | ||
525 | next forloop; | ||
526 | } | ||
527 | |||
528 | $config =~ s/^CONFIG_//; | ||
529 | |||
530 | if (defined($depends{$config})) { | ||
531 | # This config has dependencies. Make sure they are also included | ||
532 | parse_config_depends $depends{$config}; | ||
533 | } | ||
534 | |||
535 | # If the config has no prompt, then we need to check if a config | ||
536 | # that is enabled selected it. Or if we need to enable one. | ||
537 | if (!defined($prompts{$config}) && defined($selects{$config})) { | ||
538 | $process_selects{$config} = 1; | ||
539 | } | ||
464 | } | 540 | } |
541 | } | ||
542 | } | ||
543 | |||
544 | sub loop_select { | ||
545 | |||
546 | foreach my $config (keys %process_selects) { | ||
547 | $config =~ s/^CONFIG_//; | ||
465 | 548 | ||
466 | # config has no prompt and must be selected. | 549 | # config has no prompt and must be selected. |
467 | parse_config_dep_select $selects{$config}; | 550 | parse_config_selects $config, $selects{$config}; |
468 | } | 551 | } |
469 | } | 552 | } |
470 | 553 | ||
554 | while ($repeat) { | ||
555 | # Get the first set of configs and their dependencies. | ||
556 | loop_depend; | ||
557 | |||
558 | $repeat = 0; | ||
559 | |||
560 | # Now we need to see if we have to check selects; | ||
561 | loop_select; | ||
562 | } | ||
563 | |||
471 | my %setconfigs; | 564 | my %setconfigs; |
472 | 565 | ||
473 | # Finally, read the .config file and turn off any module enabled that | 566 | # Finally, read the .config file and turn off any module enabled that |