gen_config: respect dependencies (fixes out-of-tree builds)

This commit is contained in:
Daniel Hermann 2014-04-03 09:58:26 +02:00
parent bb072f7d90
commit 7091127e31

View File

@ -15,6 +15,8 @@ my $DEBUG = 0;
my $option;
my $type;
my $depends;
my $value;
my @default;
my %setByEnv;
@ -23,18 +25,30 @@ while (my $line = <STDIN>) {
$option = $1;
$setByEnv{$option} = $ENV{$option} if exists $ENV{$option};
printf STDERR "OPTION: %s\n", $option if $DEBUG;
printf STDERR "ENV: %s='%s'\n", $option, $setByEnv{$option} if $DEBUG && exists $ENV{$option};
printf STDERR "--> ENV: %s='%s'\n", $option, $setByEnv{$option} if $DEBUG && exists $ENV{$option};
}
elsif ($line =~ /^\s+(tristate|bool|int|string)\s+.*$/) {
$type = $1;
printf STDERR "TYPE: %s\n", $type if $DEBUG;
printf STDERR "--> TYPE: %s\n", $type if $DEBUG;
}
elsif ($line =~/^\s+depends\s+on\s+(.*)$/) {
$depends = ($option ne 'MARS') ? $1 : '';
printf STDERR "--> DEPENDS: %s\n", $depends if $DEBUG;
}
elsif ($line =~ /^\s+default\s+(.*)$/) {
printf STDERR "DEFAULT: %s\n", $1 if $DEBUG;
if ($option eq 'MARS') {
$value = 'y';
printf STDERR "--> DEFAULT: y (OVERRIDDEN by script)\n" if $DEBUG;
}
else {
$value = $1;
printf STDERR "--> DEFAULT: %s\n", $value if $DEBUG;
}
push @default, {
option => $option,
type => $type,
value => $1,
depends => $depends,
value => $value,
} if $option;
}
elsif ($line =~ /^\s+---help---\s+$/) {
@ -45,7 +59,7 @@ while (my $line = <STDIN>) {
}
}
print STDERR Dumper(\@default) if $DEBUG;
print STDERR Dumper(\@default) if $DEBUG >= 2;
##
@ -94,6 +108,16 @@ foreach my $opt (@default) {
next;
}
if ($opt->{depends}) {
my @deps = grep { $_->{option} eq $opt->{depends} } @default;
if (scalar @deps && $deps[0]->{value} eq 'n') {
print qq%
/* CONFIG_$optname is unset (depends on $deps[0]->{option}, which is unset) */
%;
next;
}
}
given ($opt->{type}) {
when ('tristate') {