X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=scripts%2Fmetadata.pl;h=fdf5886ec0fafbbed9e7b1d0e16667b2af1ce802;hb=6b466d91911f35e5eca3115e7ae09a357ca9344f;hp=9c10f9554ca01c7e8c4d9ca44c6bad04ecb64488;hpb=7cea040c4d095e95ffb795d604273ca053a6e435;p=openwrt%2Fsvn-archive%2Farchive.git diff --git a/scripts/metadata.pl b/scripts/metadata.pl index 9c10f9554c..fdf5886ec0 100755 --- a/scripts/metadata.pl +++ b/scripts/metadata.pl @@ -237,6 +237,7 @@ EOF sub gen_target_config() { my @target = parse_target_metadata(); + my %defaults; my @target_sort = sort { target_name($a) cmp target_name($b); @@ -290,6 +291,7 @@ EOF my @pkglist = merge_package_lists($target->{packages}, $profile->{packages}); foreach my $pkg (@pkglist) { print "\tselect DEFAULT_$pkg\n"; + $defaults{$pkg} = 1; } print "\n"; } @@ -319,6 +321,10 @@ config LINUX_$v bool EOF } + foreach my $def (sort keys %defaults) { + print "\tconfig DEFAULT_".$def."\n"; + print "\t\tbool\n\n"; + } } my %dep_check; @@ -362,12 +368,14 @@ sub package_depends($$) { return $ret; } -sub mconf_depends($$) { +sub mconf_depends { + my $pkgname = shift; my $depends = shift; my $only_dep = shift; my $res; my $dep = shift; my $seen = shift; + my $parent_condition = shift; $dep or $dep = {}; $seen or $seen = {}; @@ -377,14 +385,21 @@ sub mconf_depends($$) { my $m = "depends"; $depend =~ s/^([@\+]+)//; my $flags = $1; - my $condition; my $vdep; + my $condition = $parent_condition; if ($depend =~ /^(.+):(.+)$/) { - $condition = $1; + if ($1 ne "PACKAGE_$pkgname") { + if ($condition) { + $condition = "$condition && $1"; + } else { + $condition = $1; + } + } $depend = $2; } next if $seen->{$depend}; + next if $package{$depend} and $package{$depend}->{buildonly}; $seen->{$depend} = 1; if ($vdep = $package{$depend}->{vdepends}) { $depend = join("||", map { "PACKAGE_".$_ } @$vdep); @@ -394,13 +409,19 @@ sub mconf_depends($$) { # thus if FOO depends on other config options, these dependencies # will not be checked. To fix this, we simply emit all of FOO's # depends here as well. - $package{$depend} and mconf_depends($package{$depend}->{depends}, 1, $dep, $seen); + $package{$depend} and mconf_depends($pkgname, $package{$depend}->{depends}, 1, $dep, $seen, $condition); $m = "select"; next if $only_dep; }; $flags =~ /@/ or $depend = "PACKAGE_$depend"; - $condition and $depend = "$depend if $condition"; + if ($condition) { + if ($m =~ /select/) { + $depend = "$depend if $condition"; + } else { + $depend = "!($condition) || $depend"; + } + } } $dep->{$depend} =~ /select/ or $dep->{$depend} = $m; } @@ -423,6 +444,7 @@ sub print_package_config_category($) { foreach my $spkg (sort {uc($a) cmp uc($b)} keys %spkg) { foreach my $pkg (@{$spkg{$spkg}}) { + next if $pkg->{buildonly}; my $menu = $pkg->{submenu}; if ($menu) { $menu_dep{$menu} or $menu_dep{$menu} = $pkg->{submenudep}; @@ -431,8 +453,6 @@ sub print_package_config_category($) { } $menus{$menu} or $menus{$menu} = []; push @{$menus{$menu}}, $pkg; - print "\tconfig DEFAULT_".$pkg->{name}."\n"; - print "\t\tbool\n\n"; } } my @menus = sort { @@ -464,7 +484,7 @@ sub print_package_config_category($) { foreach my $default (split /\s*,\s*/, $pkg->{default}) { print "\t\tdefault $default\n"; } - print mconf_depends($pkg->{depends}, 0); + print mconf_depends($pkg->{name}, $pkg->{depends}, 0); print "\t\thelp\n"; print $pkg->{description}; print "\n"; @@ -503,6 +523,20 @@ EOF } } +sub get_conditional_dep($$) { + my $condition = shift; + my $depstr = shift; + if ($condition) { + if ($condition =~ /^!(.+)/) { + return "\$(if \$(CONFIG_$1),,$depstr)"; + } else { + return "\$(if \$(CONFIG_$condition),$depstr)"; + } + } else { + return $depstr; + } +} + sub gen_package_mk() { my %conf; my %dep; @@ -526,6 +560,7 @@ sub gen_package_mk() { $config = "\$(CONFIG_PACKAGE_$name)" } if ($config) { + $pkg->{buildonly} and $config = ""; print "package-$config += $pkg->{subdir}$pkg->{src}\n"; $pkg->{prereq} and print "prereq-$config += $pkg->{subdir}$pkg->{src}\n"; } @@ -533,6 +568,10 @@ sub gen_package_mk() { next if $done{$pkg->{src}}; $done{$pkg->{src}} = 1; + if (@{$pkg->{buildtypes}} > 0) { + print "buildtypes-$pkg->{subdir}$pkg->{src} = ".join(' ', @{$pkg->{buildtypes}})."\n"; + } + foreach my $spkg (@{$srcpackage{$pkg->{src}}}) { foreach my $dep (@{$spkg->{depends}}, @{$spkg->{builddepends}}) { $dep =~ /@/ or do { @@ -541,17 +580,60 @@ sub gen_package_mk() { }; } } + foreach my $type (@{$pkg->{buildtypes}}) { + my @extra_deps; + my %deplines; + + next unless $pkg->{"builddepends/$type"}; + foreach my $dep (@{$pkg->{"builddepends/$type"}}) { + my $suffix = ""; + my $condition; + + if ($dep =~ /^(.+):(.+)/) { + $condition = $1; + $dep = $2; + } + if ($dep =~ /^(.+)(\/.+)/) { + $dep = $1; + $suffix = $2; + } + my $pkg_dep = $package{$dep}; + next unless $pkg_dep; + + my $idx = ""; + if (defined $pkg_dep->{src}) { + $idx = $pkg_dep->{subdir}.$pkg_dep->{src}; + } elsif (defined($srcpackage{$dep})) { + $idx = $subdir{$dep}.$dep; + } + my $depstr = "\$(curdir)/$idx$suffix/compile"; + my $depline = get_conditional_dep($condition, $depstr); + if ($depline) { + $deplines{$dep} = $depline; + } + } + my $depline = join(" ", values %deplines); + if ($depline) { + $line .= "\$(curdir)/".$pkg->{subdir}."$pkg->{src}/$type/compile += $depline\n"; + } + } my $hasdeps = 0; - my $depline = ""; + my %deplines; foreach my $deps (@srcdeps) { my $idx; my $condition; + my $prefix = ""; + my $suffix = ""; if ($deps =~ /^(.+):(.+)/) { $condition = $1; $deps = $2; } + if ($deps =~ /^(.+)(\/.+)/) { + $deps = $1; + $suffix = $2; + } my $pkg_dep = $package{$deps}; my @deps; @@ -565,15 +647,17 @@ sub gen_package_mk() { foreach my $dep (@deps) { $pkg_dep = $package{$deps}; if (defined $pkg_dep->{src}) { - ($pkg->{src} ne $pkg_dep->{src}) and $idx = $pkg_dep->{subdir}.$pkg_dep->{src}; + ($pkg->{src} ne $pkg_dep->{src}.$suffix) and $idx = $pkg_dep->{subdir}.$pkg_dep->{src}; } elsif (defined($srcpackage{$dep})) { $idx = $subdir{$dep}.$dep; } + $idx .= $suffix; undef $idx if $idx =~ /^(kernel)|(base-files)$/; if ($idx) { - next if $pkg->{src} eq $pkg_dep->{src}; + my $depline; + next if $pkg->{src} eq $pkg_dep->{src}.$suffix; next if $dep{$pkg->{src}."->".$idx}; - next if $dep{$pkg->{src}."->($dep)".$idx}; + next if $dep{$pkg->{src}."->($dep)".$idx} and $pkg_dep->{vdepends}; my $depstr; if ($pkg_dep->{vdepends}) { @@ -583,14 +667,14 @@ sub gen_package_mk() { $depstr = "\$(curdir)/$idx/compile"; $dep{$pkg->{src}."->".$idx} = 1; } - if ($condition) { - $depline .= " \$(if \$(CONFIG_$condition),$depstr)"; - } else { - $depline .= " $depstr"; + $depline = get_conditional_dep($condition, $depstr); + if ($depline) { + $deplines{$idx.$dep} = $depline; } } } } + my $depline = join(" ", values %deplines); if ($depline) { $line .= "\$(curdir)/".$pkg->{subdir}."$pkg->{src}/compile += $depline\n"; } @@ -621,6 +705,16 @@ EOF } } +sub gen_package_source() { + parse_package_metadata($ARGV[0]) or exit 1; + foreach my $name (sort {uc($a) cmp uc($b)} keys %package) { + my $pkg = $package{$name}; + if ($pkg->{name} && $pkg->{source}) { + print "$pkg->{name}: "; + print "$pkg->{source}\n"; + } + } +} sub parse_command() { my $cmd = shift @ARGV; @@ -629,13 +723,15 @@ sub parse_command() { /^package_mk$/ and return gen_package_mk(); /^package_config$/ and return gen_package_config(); /^kconfig/ and return gen_kconfig_overrides(); + /^package_source$/ and return gen_package_source(); } print <