X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fstaging%2Fwigyori.git;a=blobdiff_plain;f=scripts%2Fmetadata.pl;h=3d9d68a654b4fb5b8f3c4c2745ca42dd3d3ea2e2;hp=bee30201217b09302c24f5c74bfdded29ae30b2f;hb=510bdd3f0ee6b843120d68c68dfd648ec498a357;hpb=625b692c1f6ee3494d489ee8f254b77de7585f1d diff --git a/scripts/metadata.pl b/scripts/metadata.pl index bee3020121..3d9d68a654 100755 --- a/scripts/metadata.pl +++ b/scripts/metadata.pl @@ -52,6 +52,7 @@ sub parse_target_metadata() { /^Target-Features:\s*(.+)\s*$/ and $target->{features} = [ split(/\s+/, $1) ]; /^Target-Depends:\s*(.+)\s*$/ and $target->{depends} = [ split(/\s+/, $1) ]; /^Target-Description:/ and $target->{desc} = get_multiline(*FILE); + /^Target-Optimization:\s*(.+)\s*$/ and $target->{cflags} = $1; /^Linux-Version:\s*(.+)\s*$/ and $target->{version} = $1; /^Linux-Release:\s*(.+)\s*$/ and $target->{release} = $1; /^Linux-Kernel-Arch:\s*(.+)\s*$/ and $target->{karch} = $1; @@ -201,12 +202,20 @@ sub print_target($) { } my $v = kver($target->{version}); + if (@{$target->{subtargets}} == 0) { $confstr = <{conf} bool "$target->{name}" select LINUX_$kernel select LINUX_$v EOF + } + else { + $confstr = <{conf} + bool "$target->{name}" +EOF + } if ($target->{subtarget}) { $confstr .= "\tdepends TARGET_$target->{boardconf}\n"; } @@ -223,6 +232,7 @@ EOF $flags = $1; $name = $2; + next if $name =~ /:/; $flags =~ /-/ and $mode = "deselect"; $flags =~ /\+/ and $mode = "select"; $flags =~ /@/ and $confstr .= "\t$mode $name\n"; @@ -236,6 +246,7 @@ EOF sub gen_target_config() { my @target = parse_target_metadata(); + my %defaults; my @target_sort = sort { target_name($a) cmp target_name($b); @@ -289,8 +300,16 @@ EOF my @pkglist = merge_package_lists($target->{packages}, $profile->{packages}); foreach my $pkg (@pkglist) { print "\tselect DEFAULT_$pkg\n"; + $defaults{$pkg} = 1; } - print "\n"; + my $help = $profile->{desc}; + if ($help =~ /\w+/) { + $help =~ s/^\s*/\t /mg; + $help = "\thelp\n$help"; + } else { + undef $help; + } + print "$help\n"; } } @@ -307,6 +326,16 @@ EOF foreach my $target (@target) { $target->{subtarget} or print "\t\tdefault \"".$target->{board}."\" if TARGET_".$target->{conf}."\n"; } + print <{subtargets}} > 0; + print "\tdefault \"".$target->{cflags}."\" if TARGET_".$target->{conf}."\n"; + } + print "\tdefault \"-Os -pipe -funit-at-a-time\"\n"; my %kver; foreach my $target (@target) { @@ -314,10 +343,16 @@ EOF next if $kver{$v}; $kver{$v} = 1; print <{$depend}; + next if $package{$depend} and $package{$depend}->{buildonly}; + $seen->{$depend} = 1; if ($vdep = $package{$depend}->{vdepends}) { $depend = join("||", map { "PACKAGE_".$_ } @$vdep); } else { @@ -384,12 +437,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); + $package{$depend} and mconf_depends($pkgname, $package{$depend}->{depends}, 1, $dep, $seen, $condition); $m = "select"; next if $only_dep; }; $flags =~ /@/ or $depend = "PACKAGE_$depend"; + if ($condition) { + if ($m =~ /select/) { + $depend = "$depend if $condition"; + } else { + $depend = "!($condition) || $depend"; + } + } } $dep->{$depend} =~ /select/ or $dep->{$depend} = $m; } @@ -412,6 +472,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}; @@ -420,8 +481,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 { @@ -453,7 +512,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"; @@ -492,6 +551,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; @@ -515,6 +588,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"; } @@ -522,6 +596,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 { @@ -530,11 +608,61 @@ 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; @@ -553,19 +681,27 @@ sub gen_package_mk() { } undef $idx if $idx =~ /^(kernel)|(base-files)$/; if ($idx) { + my $depline; next if $pkg->{src} eq $pkg_dep->{src}; 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}) { - $depline .= " \$(if \$(CONFIG_PACKAGE_$dep),\$(curdir)/$idx/compile)"; + $depstr = "\$(if \$(CONFIG_PACKAGE_$dep),\$(curdir)/$idx$suffix/compile)"; $dep{$pkg->{src}."->($dep)".$idx} = 1; } else { - $depline .= " \$(curdir)/$idx/compile"; + $depstr = "\$(curdir)/$idx$suffix/compile"; $dep{$pkg->{src}."->".$idx} = 1; } + $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"; } @@ -596,6 +732,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; @@ -604,13 +750,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 <