diff options
author | nbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2006-10-17 17:45:14 +0000 |
---|---|---|
committer | nbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2006-10-17 17:45:14 +0000 |
commit | 2c5be9bc38a67b26aa3fe92218a80da9a732d102 (patch) | |
tree | 42d045c8bfffe56a2fbcf99c5141b0dc1025d6e5 /scripts/gen_menuconfig.pl | |
parent | 346b56b086916db47db5418f73f5114ccb8e8b68 (diff) |
menuconfig: include dependency checking in submenu sorting function
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@5193 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'scripts/gen_menuconfig.pl')
-rwxr-xr-x | scripts/gen_menuconfig.pl | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/scripts/gen_menuconfig.pl b/scripts/gen_menuconfig.pl index c0279d5452..fe0dc27636 100755 --- a/scripts/gen_menuconfig.pl +++ b/scripts/gen_menuconfig.pl @@ -11,6 +11,7 @@ use strict; my $src; my $makefile; my $pkg; +my %package; my %category; my $cur_menu; my $cur_menu_dep; @@ -26,6 +27,35 @@ sub close_submenu { } } +sub find_dep($$) { + my $pkg = shift; + my $name = shift; + + return 0 unless defined $pkg->{depends}; + foreach my $dep (@{$pkg->{depends}}) { + return 1 if $dep eq $name; + return 1 if ($package{$dep} and (find_dep($package{$dep},$name) == 1)); + } + return 0; +} + +sub depends($$) { + my $a = shift; + my $b = shift; + my $ret; + + if (find_dep($a, $b->{name}) == 1) { + $ret = 1; + } elsif (find_dep($b, $a->{name}) == 1) { + $ret = -1; + } else { + $ret = 0; + } +# print STDERR "depends($a->{name}, $b->{name}) == $ret\n"; + return $ret; +} + + sub print_category($) { my $cat = shift; @@ -35,6 +65,7 @@ sub print_category($) { my %spkg = %{$category{$cat}}; foreach my $spkg (sort {uc($a) cmp uc($b)} keys %spkg) { my @pkgs = sort { + depends($a, $b) or $a->{submenu}."->".$a->{name} cmp $b->{submenu}."->".$b->{name} } @{$spkg{$spkg}}; foreach my $pkg (@pkgs) { @@ -93,6 +124,7 @@ while ($line = <>) { $pkg->{makefile} = $makefile; $pkg->{name} = $1; $pkg->{default} = "m if ALL"; + $package{$1} = $pkg; }; $line =~ /^Version: \s*(.+)\s*$/ and $pkg->{version} = $1; $line =~ /^Title: \s*(.+)\s*$/ and $pkg->{title} = $1; |