From 88d9d059941c59e269cd699372e72dd10539128b Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Thu, 4 Sep 2008 14:19:21 +0300 Subject: [PATCH] dummy-select: Support dependencies for XML entries CFLAGS and sound files seem to use a different logic than one used for Asterisk modules: They are not included unless otherwise stated. And printing them means that they are to be included. This commit supports e.g. one CFLAG depending on another. It does that by adding a "Want" entry to each item. BUG: Want can be set (and not properly reset later) by a module whose dependency test will later fail. --- menuselect/menuselect | 54 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/menuselect/menuselect b/menuselect/menuselect index 1fe2cfbd5..c0b64c15f 100755 --- a/menuselect/menuselect +++ b/menuselect/menuselect @@ -197,6 +197,7 @@ sub parse_menuselect_xml_file($) { Module => $1, DisplayName => $2, Avail => 1, + Want => 0, }; } elsif ($tag eq '/member') { @@ -332,6 +333,7 @@ sub apply_excluded_patterns() { my @excluded = grep {/^$pattern$/i} (keys %ModInfo); foreach (@excluded) { $ModInfo{$_}{Avail} = 0; + $ModInfo{$_}{Want} = 0; } } } @@ -343,6 +345,7 @@ sub apply_included_patterns() { my @included = grep {/^$pattern$/i} (keys %ModInfo); foreach (@included) { $ModInfo{$_}{Avail} = 1; + $ModInfo{$_}{Want} = 1; } } } @@ -389,10 +392,17 @@ sub check_required_patterns() { # information as disabled for building by default. sub apply_default_enabled() { foreach my $mod (keys %ModInfo) { - if ((exists $ModInfo{$mod}{Defaultenabled}) && - $ModInfo{$mod}{Defaultenabled}[0] eq 'no') - { + next unless ( exists $ModInfo{$mod}{Defaultenabled}); + my $val = $ModInfo{$mod}{Defaultenabled}[0]; + + if ($val eq 'no') { $ModInfo{$mod}{Avail} = 0; + $ModInfo{$mod}{Want} = 0; + } elsif ($val eq 'yes') { + $ModInfo{$mod}{Avail} = 1; + $ModInfo{$mod}{Want} = 1; + } else { + warning "Invalid 'defaultenabled' value '$val' for $mod"; } } } @@ -404,9 +414,10 @@ sub apply_default_enabled() { # # We can only use a module or library marked as Avail => 1 (library # available or module not excluded). -sub check_module($); -sub check_module($) { +sub check_module($$); +sub check_module($$) { my $mod = shift; + my $want = shift; # we checked it: if (exists $ModInfo{$mod}{Checked}) { @@ -424,18 +435,27 @@ sub check_module($) { # And we need to actually print enabled ones, rather than disabled # ones. if ($ModInfo{$mod}{Type} eq 'XML') { - my $res = ((not exists $ModInfo{$mod}{Defaultenabled}) || - ($ModInfo{$mod}{Defaultenabled}[0] ne 'yes') ); - $ModInfo{$mod}{Checked} = $res; - return $res; + # Nobody wants the module (recursively) and the moudle itself + # does not have Want set from e.g. include. + # Do nothing now, in case someone else will want it. + if (!$want && ( (not exists $ModInfo{$mod}{Want}) || + (! $ModInfo{$mod}{Want})) ) + { + return 0; + } + } # no dependencies to check: if (! exists $ModInfo{$mod}{Depend}) { $ModInfo{$mod}{Checked} = 1; + $ModInfo{$mod}{Want} ||= $want; return 1; } my $deps_checked = 1; # may be reset below on failures: + if (exists $ModInfo{$mod}{Want}) { + $want ||= $ModInfo{$mod}{Want}; + } if (exists $ModInfo{$mod}{Tested}) { # this probably means a circular dependency of some sort. @@ -449,7 +469,7 @@ sub check_module($) { warning "module $mod depends on $dep_mod that does not exist."; next; } - $deps_checked &= check_module($dep_mod); + $deps_checked &= check_module($dep_mod, $want); last if(!$deps_checked) # no point testing further if we failed. } @@ -464,7 +484,7 @@ sub resolve_deps() { apply_included_patterns(); foreach my $mod (keys %ModInfo) { - check_module($mod); + check_module($mod, 0); } } @@ -476,8 +496,13 @@ sub gen_makeopts() { my %Subdirs; foreach my $mod (sort keys %ModInfo) { - next unless ($ModInfo{$mod}{Type} =~ /^(module|XML)$/); - next if ($ModInfo{$mod}{Checked}); + if ($ModInfo{$mod}{Type} eq 'module') { + next if ((exists $ModInfo{$mod}{Checked}) && $ModInfo{$mod}{Checked}); + } elsif ($ModInfo{$mod}{Type} eq 'XML') { + next unless ($ModInfo{$mod}{Want} && $ModInfo{$mod}{Checked}); + } else { + next; + } my $dir = $ModInfo{$mod}{Dir}; if (! exists $Subdirs{$dir}) { $Subdirs{$dir} = []; @@ -501,6 +526,9 @@ read_conf(); extract_subdirs(@Subdirs); parse_menuselect_xml_file('build_tools/cflags.xml'); +# We're only supposed to enable those if dev mode is enabled. +# but for that I need to parse makeopts . +parse_menuselect_xml_file('build_tools/cflags-devmode.xml'); parse_menuselect_xml_file('sounds/sounds.xml'); apply_random_drop(); -- 2.11.4.GIT