X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fopenwrt.git;a=blobdiff_plain;f=scripts%2Fmetadata.pl;h=250a85ed84e2e343678bf9c44221bab7cec143e7;hp=4fa7be0412dba3d86737ab024d01bba6be06e2e8;hb=b24897ee5c53b6488d1b984b63ab65220e486ed7;hpb=80b7ff39f9d2dca5a411610f78d7f093368a484f diff --git a/scripts/metadata.pl b/scripts/metadata.pl index 4fa7be0412..250a85ed84 100755 --- a/scripts/metadata.pl +++ b/scripts/metadata.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin"; use strict; @@ -15,6 +15,8 @@ sub confstr($) { sub parse_target_metadata() { my $file = shift @ARGV; my ($target, @target, $profile); + my %target; + open FILE, "<$file" or do { warn "Can't open file '$file': $!\n"; return; @@ -22,29 +24,40 @@ sub parse_target_metadata() { while () { chomp; /^Target:\s*(.+)\s*$/ and do { + my $name = $1; $target = { - id => $1, - conf => confstr($1), + id => $name, + board => $name, + boardconf => confstr($name), + conf => confstr($name), profiles => [], features => [], - depends => [] + depends => [], + subtargets => [] }; push @target, $target; + $target{$name} = $target; + if ($name =~ /([^\/]+)\/([^\/]+)/) { + push @{$target{$1}->{subtargets}}, $2; + $target->{board} = $1; + $target->{boardconf} = confstr($1); + $target->{subtarget} = 1; + $target->{parent} = $target{$1}; + } }; - /^Target-Board:\s*(.+)\s*$/ and do { - $target->{board} = $1; - $target->{boardconf} = confstr($1); - }; - /^Target-Kernel:\s*(\d+\.\d+)\s*$/ and $target->{kernel} = $1; /^Target-Name:\s*(.+)\s*$/ and $target->{name} = $1; /^Target-Path:\s*(.+)\s*$/ and $target->{path} = $1; /^Target-Arch:\s*(.+)\s*$/ and $target->{arch} = $1; + /^Target-Arch-Packages:\s*(.+)\s*$/ and $target->{arch_packages} = $1; /^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; + /^CPU-Type:\s*(.+)\s*$/ and $target->{cputype} = $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; + /^Default-Subtarget:\s*(.+)\s*$/ and $target->{def_subtarget} = $1; /^Default-Packages:\s*(.+)\s*$/ and $target->{packages} = [ split(/\s+/, $1) ]; /^Target-Profile:\s*(.+)\s*$/ and do { $profile = { @@ -62,6 +75,10 @@ sub parse_target_metadata() { } close FILE; foreach my $target (@target) { + if (@{$target->{subtargets}} > 0) { + $target->{profiles} = []; + next; + } @{$target->{profiles}} > 0 or $target->{profiles} = [ { id => 'Default', @@ -102,6 +119,7 @@ sub gen_kconfig_overrides() { $val = $2; } if ($config{"CONFIG_PACKAGE_$package"} and ($config ne 'n')) { + next if $kconfig{$config} eq 'y'; $kconfig{$config} = $val; } elsif (!$override) { $kconfig{$config} or $kconfig{$config} = 'n'; @@ -139,121 +157,254 @@ sub target_config_features(@) { my $ret; while ($_ = shift @_) { - /broken/ and $ret .= "\tdepends BROKEN\n"; + /arm_v(\w+)/ and $ret .= "\tselect arm_v$1\n"; + /broken/ and $ret .= "\tdepends on BROKEN\n"; + /audio/ and $ret .= "\tselect AUDIO_SUPPORT\n"; + /display/ and $ret .= "\tselect DISPLAY_SUPPORT\n"; + /dt/ and $ret .= "\tselect USES_DEVICETREE\n"; + /gpio/ and $ret .= "\tselect GPIO_SUPPORT\n"; /pci/ and $ret .= "\tselect PCI_SUPPORT\n"; + /pcie/ and $ret .= "\tselect PCIE_SUPPORT\n"; /usb/ and $ret .= "\tselect USB_SUPPORT\n"; + /usbgadget/ and $ret .= "\tselect USB_GADGET_SUPPORT\n"; /pcmcia/ and $ret .= "\tselect PCMCIA_SUPPORT\n"; + /rtc/ and $ret .= "\tselect RTC_SUPPORT\n"; /squashfs/ and $ret .= "\tselect USES_SQUASHFS\n"; - /jffs2/ and $ret .= "\tselect USES_JFFS2\n"; - /ext2/ and $ret .= "\tselect USES_EXT2\n"; - /tgz/ and $ret .= "\tselect USES_TGZ\n"; + /jffs2$/ and $ret .= "\tselect USES_JFFS2\n"; + /jffs2_nand/ and $ret .= "\tselect USES_JFFS2_NAND\n"; + /ext4/ and $ret .= "\tselect USES_EXT4\n"; + /targz/ and $ret .= "\tselect USES_TARGZ\n"; + /cpiogz/ and $ret .= "\tselect USES_CPIOGZ\n"; + /ubifs/ and $ret .= "\tselect USES_UBIFS\n"; + /fpu/ and $ret .= "\tselect HAS_FPU\n"; + /spe_fpu/ and $ret .= "\tselect HAS_SPE_FPU\n"; + /ramdisk/ and $ret .= "\tselect USES_INITRAMFS\n"; + /powerpc64/ and $ret .= "\tselect powerpc64\n"; + /nommu/ and $ret .= "\tselect NOMMU\n"; + /mips16/ and $ret .= "\tselect HAS_MIPS16\n"; + /rfkill/ and $ret .= "\tselect RFKILL_SUPPORT\n"; + /low_mem/ and $ret .= "\tselect LOW_MEMORY_FOOTPRINT\n"; } return $ret; } +sub target_name($) { + my $target = shift; + my $parent = $target->{parent}; + if ($parent) { + return $target->{parent}->{name}." - ".$target->{name}; + } else { + return $target->{name}; + } +} + +sub kver($) { + my $v = shift; + $v =~ tr/\./_/; + if (substr($v,0,2) eq "2_") { + $v =~ /(\d+_\d+_\d+)(_\d+)?/ and $v = $1; + } else { + $v =~ /(\d+_\d+)(_\d+)?/ and $v = $1; + } + return $v; +} + +sub print_target($) { + my $target = shift; + my $features = target_config_features(@{$target->{features}}); + my $help = $target->{desc}; + my $confstr; + + chomp $features; + $features .= "\n"; + if ($help =~ /\w+/) { + $help =~ s/^\s*/\t /mg; + $help = "\thelp\n$help"; + } else { + undef $help; + } + + my $v = kver($target->{version}); + if (@{$target->{subtargets}} == 0) { + $confstr = <{conf} + bool "$target->{name}" + select LINUX_$v +EOF + } + else { + $confstr = <{conf} + bool "$target->{name}" +EOF + } + if ($target->{subtarget}) { + $confstr .= "\tdepends on TARGET_$target->{boardconf}\n"; + } + if (@{$target->{subtargets}} > 0) { + $confstr .= "\tselect HAS_SUBTARGETS\n"; + grep { /broken/ } @{$target->{features}} and $confstr .= "\tdepends on BROKEN\n"; + } else { + $confstr .= $features; + } + + if ($target->{arch} =~ /\w/) { + $confstr .= "\tselect $target->{arch}\n"; + } + foreach my $dep (@{$target->{depends}}) { + my $mode = "depends on"; + my $flags; + my $name; + + $dep =~ /^([@\+\-]+)(.+)$/; + $flags = $1; + $name = $2; + + next if $name =~ /:/; + $flags =~ /-/ and $mode = "deselect"; + $flags =~ /\+/ and $mode = "select"; + $flags =~ /@/ and $confstr .= "\t$mode $name\n"; + } + $confstr .= "$help\n\n"; + print $confstr; +} sub gen_target_config() { my @target = parse_target_metadata(); + my %defaults; - @target = sort { - $a->{name} cmp $b->{name} + my @target_sort = sort { + target_name($a) cmp target_name($b); } @target; - - + + print <{features}}); - my $help = $target->{desc}; - my $kernel = $target->{kernel}; - $kernel =~ tr/./_/; - - chomp $features; - $features .= "\n"; - if ($help =~ /\w+/) { - $help =~ s/^\s*/\t /mg; - $help = "\thelp\n$help"; - } else { - undef $help; - } - - print <{conf} - bool "$target->{name}" - select $target->{arch} - select LINUX_$kernel -EOF - if ($target->{id} ne $target->{board}) { - print "\tselect TARGET_".$target->{boardconf}."\n"; - } - foreach my $dep (@{$target->{depends}}) { - my $mode = "depends"; - my $flags; - my $name; - - $dep =~ /^([@\+\-]+)(.+)$/; - $flags = $1; - $name = $2; - - $flags =~ /-/ and $mode = "deselect"; - $flags =~ /\+/ and $mode = "select"; - $flags =~ /@/ and print "\t$mode $name\n"; - } - - print "$features$help\n\n" + foreach my $target (@target_sort) { + next if $target->{subtarget}; + print_target($target); } print <{board}."\" if TARGET_".$target->{conf}."\n"; + next unless $target->{def_subtarget}; + print <{conf}_$target->{def_subtarget} if TARGET_$target->{conf} +EOF } + print <