b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | #!/usr/bin/env perl |
| 2 | use strict; |
| 3 | |
| 4 | while (<>) { |
| 5 | my $match; |
| 6 | my $var; |
| 7 | my $val; |
| 8 | my $type; |
| 9 | chomp; |
| 10 | next if /^CONFIG_SIGNED_PACKAGES/; |
| 11 | |
| 12 | if (/^CONFIG_((BINARY)|(DOWNLOAD))_FOLDER=(.*)$/) { |
| 13 | # We don't want to preserve the build setting of |
| 14 | # BINARY_FOLDER and DOWNLOAD_FOLDER. |
| 15 | $var = "$1_FOLDER"; |
| 16 | $val = '""'; |
| 17 | $type = "string"; |
| 18 | } elsif (/^CONFIG_([^=]+)=(.*)$/) { |
| 19 | $var = $1; |
| 20 | $val = $2; |
| 21 | |
| 22 | next if $var eq 'ALL'; |
| 23 | |
| 24 | if ($val eq 'y') { |
| 25 | $type = "bool"; |
| 26 | } elsif ($val eq 'm') { |
| 27 | $type = "tristate"; |
| 28 | } elsif ($val =~ /^".*"$/) { |
| 29 | $type = "string"; |
| 30 | } elsif ($val =~ /^\d+$/) { |
| 31 | $type = "int"; |
| 32 | } else { |
| 33 | warn "WARNING: no type found for symbol CONFIG_$var=$val\n"; |
| 34 | next; |
| 35 | } |
| 36 | } elsif (/^# CONFIG_BUSYBOX_(.*) is not set/) { |
| 37 | $var = "BUSYBOX_$1"; |
| 38 | $val = 'n'; |
| 39 | $type = "bool"; |
| 40 | } else { |
| 41 | # We don't want to preserve a record of deselecting |
| 42 | # packages because we may want build them in the SDK. |
| 43 | # non-package configs however may be important to preserve |
| 44 | # the same compilation settings for packages that get |
| 45 | # recompiled in the SDK. |
| 46 | # Also we want avoid preserving image generation settings |
| 47 | # because we set those while in ImageBuilder |
| 48 | next if /^(# )?CONFIG_PACKAGE/; |
| 49 | next if /^(# )?CONFIG_TARGET/; |
| 50 | if (/^# CONFIG_(.*) is not set/) { |
| 51 | $var = $1; |
| 52 | $val = 'n'; |
| 53 | $type = "bool"; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | if (($var ne '') && ($type ne '') && ($val ne '')) { |
| 58 | print <<EOF; |
| 59 | config $var |
| 60 | $type |
| 61 | default $val |
| 62 | |
| 63 | EOF |
| 64 | } |
| 65 | } |