metadata: replace %subdir hash with a path field in source packages

Every single reference to subdir was concatenated with the source package
name, so it makes sense to store the concatenated value instead.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
owl
Matthias Schiffer 2018-01-06 19:28:52 +01:00
parent 504cb913eb
commit f0c702f124
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
2 changed files with 15 additions and 22 deletions

View File

@ -2,13 +2,12 @@ package metadata;
use base 'Exporter'; use base 'Exporter';
use strict; use strict;
use warnings; use warnings;
our @EXPORT = qw(%package %srcpackage %category %subdir %preconfig %features %overrides clear_packages parse_package_metadata parse_target_metadata get_multiline @ignore %usernames %groupnames); our @EXPORT = qw(%package %srcpackage %category %preconfig %features %overrides clear_packages parse_package_metadata parse_target_metadata get_multiline @ignore %usernames %groupnames);
our %package; our %package;
our %preconfig; our %preconfig;
our %srcpackage; our %srcpackage;
our %category; our %category;
our %subdir;
our %features; our %features;
our %overrides; our %overrides;
our @ignore; our @ignore;
@ -178,7 +177,6 @@ sub parse_target_metadata($) {
} }
sub clear_packages() { sub clear_packages() {
%subdir = ();
%preconfig = (); %preconfig = ();
%package = (); %package = ();
%srcpackage = (); %srcpackage = ();
@ -204,12 +202,10 @@ sub parse_package_metadata($) {
}; };
while (<FILE>) { while (<FILE>) {
chomp; chomp;
/^Source-Makefile: \s*((?:package\/)?((?:.+\/)?)([^\/]+)\/Makefile)\s*$/ and do { /^Source-Makefile: \s*((?:package\/)?((?:.+\/)?([^\/]+))\/Makefile)\s*$/ and do {
$subdir{$3} = $2;
$src = { $src = {
makefile => $1, makefile => $1,
subdir => $2, path => $2,
name => $3, name => $3,
ignore => $ignore{$3}, ignore => $ignore{$3},
packages => [], packages => [],
@ -235,7 +231,6 @@ sub parse_package_metadata($) {
$pkg->{title} = ""; $pkg->{title} = "";
$pkg->{depends} = []; $pkg->{depends} = [];
$pkg->{mdepends} = []; $pkg->{mdepends} = [];
$pkg->{subdir} = $src->{subdir};
$pkg->{tristate} = 1; $pkg->{tristate} = 1;
$pkg->{override} = $override; $pkg->{override} = $override;
$package{$1} = $pkg; $package{$1} = $pkg;
@ -278,7 +273,6 @@ sub parse_package_metadata($) {
name => $vpkg, name => $vpkg,
vdepends => [], vdepends => [],
src => $src, src => $src,
subdir => $src->{subdir},
makefile => $src->{makefile}, makefile => $src->{makefile},
}; };
push @{$package{$vpkg}->{vdepends}}, $pkg->{name}; push @{$package{$vpkg}->{vdepends}}, $pkg->{name};

View File

@ -419,7 +419,6 @@ sub gen_package_mk() {
parse_package_metadata($ARGV[0]) or exit 1; parse_package_metadata($ARGV[0]) or exit 1;
foreach my $srcname (sort {uc($a) cmp uc($b)} keys %srcpackage) { foreach my $srcname (sort {uc($a) cmp uc($b)} keys %srcpackage) {
my $src = $srcpackage{$srcname}; my $src = $srcpackage{$srcname};
my $path = $subdir{$srcname}.$srcname;
my $variant_default; my $variant_default;
my @srcdeps; my @srcdeps;
@ -429,30 +428,30 @@ sub gen_package_mk() {
my $config = ''; my $config = '';
$config = "\$(CONFIG_PACKAGE_$pkg->{name})" unless $pkg->{buildonly}; $config = "\$(CONFIG_PACKAGE_$pkg->{name})" unless $pkg->{buildonly};
$pkg->{prereq} and print "prereq-$config += $path\n"; $pkg->{prereq} and print "prereq-$config += $src->{path}\n";
next if $pkg->{buildonly}; next if $pkg->{buildonly};
print "package-$config += $path\n"; print "package-$config += $src->{path}\n";
if ($pkg->{variant}) { if ($pkg->{variant}) {
if (!defined($variant_default) or $pkg->{variant_default}) { if (!defined($variant_default) or $pkg->{variant_default}) {
$variant_default = $pkg->{variant}; $variant_default = $pkg->{variant};
} }
print "\$(curdir)/$path/variants += \$(if $config,$pkg->{variant})\n"; print "\$(curdir)/$src->{path}/variants += \$(if $config,$pkg->{variant})\n";
} }
} }
if (defined($variant_default)) { if (defined($variant_default)) {
print "\$(curdir)/$path/default-variant := $variant_default\n"; print "\$(curdir)/$src->{path}/default-variant := $variant_default\n";
} }
unless (grep {!$_->{buildonly}} @{$src->{packages}}) { unless (grep {!$_->{buildonly}} @{$src->{packages}}) {
print "package- += $path\n"; print "package- += $src->{path}\n";
} }
if (@{$src->{buildtypes}} > 0) { if (@{$src->{buildtypes}} > 0) {
print "buildtypes-$path = ".join(' ', @{$src->{buildtypes}})."\n"; print "buildtypes-$src->{path} = ".join(' ', @{$src->{buildtypes}})."\n";
} }
foreach my $dep (@{$src->{builddepends}}, map { @{$_->{depends}} } @{$src->{packages}}) { foreach my $dep (@{$src->{builddepends}}, map { @{$_->{depends}} } @{$src->{packages}}) {
@ -489,9 +488,9 @@ sub gen_package_mk() {
$src->{makefile}, $type, $pkg_dep->{src}{name}, $deptype, $pkg_dep->{makefile}, $deptype; $src->{makefile}, $type, $pkg_dep->{src}{name}, $deptype, $pkg_dep->{makefile}, $deptype;
next; next;
} }
$idx = $pkg_dep->{subdir}.$pkg_dep->{src}{name}; $idx = $pkg_dep->{src}{path};
} elsif (defined($srcpackage{$dep})) { } elsif (defined($srcpackage{$dep})) {
$idx = $subdir{$dep}.$dep; $idx = $srcpackage{$dep}{path};
} else { } else {
next; next;
} }
@ -503,7 +502,7 @@ sub gen_package_mk() {
} }
my $depline = join(" ", sort keys %deplines); my $depline = join(" ", sort keys %deplines);
if ($depline) { if ($depline) {
$line .= "\$(curdir)/$path/$type/compile += $depline\n"; $line .= "\$(curdir)/$src->{path}/$type/compile += $depline\n";
} }
} }
@ -543,9 +542,9 @@ sub gen_package_mk() {
$src->{makefile}, $pkg_dep->{src}{name}, $deptype, $pkg_dep->{makefile}, $deptype; $src->{makefile}, $pkg_dep->{src}{name}, $deptype, $pkg_dep->{makefile}, $deptype;
next; next;
} }
$idx = $pkg_dep->{subdir}.$pkg_dep->{src}{name}; $idx = $pkg_dep->{src}{path};
} elsif (defined($srcpackage{$dep})) { } elsif (defined($srcpackage{$dep})) {
$idx = $subdir{$dep}.$dep; $idx = $srcpackage{$dep}{path};
} }
if ($idx) { if ($idx) {
@ -573,7 +572,7 @@ sub gen_package_mk() {
} }
my $depline = join(" ", sort keys %deplines); my $depline = join(" ", sort keys %deplines);
if ($depline) { if ($depline) {
$line .= "\$(curdir)/$path/compile += $depline\n"; $line .= "\$(curdir)/$src->{path}/compile += $depline\n";
} }
} }