metadata: handle target build depends together with host build depends

Target build depends are similar to host build depends in that they refer
to source packages rather than binary packages. Therefore, it makes sense
to handle them together, rather than putting them in a list together with
runtime depends and trying to figure out if the entries refer to source or
to binary packages afterwards.

This does lead to PKG_BUILD_DEPENDS entries referring to binary package
names not working anymore, which requires some fixes in the package
repositories.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
This commit is contained in:
Matthias Schiffer 2018-01-07 23:11:11 +01:00
parent 37cf77d946
commit 5b479f7dcf
No known key found for this signature in database
GPG key ID: 16EF3F64CB201D9C

View file

@ -408,6 +408,7 @@ sub gen_package_mk() {
my $src = $srcpackage{$srcname}; my $src = $srcpackage{$srcname};
my $variant_default; my $variant_default;
my @srcdeps; my @srcdeps;
my %deplines = ('' => {});
foreach my $pkg (@{$src->{packages}}) { foreach my $pkg (@{$src->{packages}}) {
next if defined $pkg->{vdepends}; next if defined $pkg->{vdepends};
@ -441,19 +442,23 @@ sub gen_package_mk() {
print "buildtypes-$src->{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 (map { @{$_->{depends}} } @{$src->{packages}}) {
$dep =~ /@/ or do { $dep =~ /@/ or do {
$dep =~ s/\+//g; $dep =~ s/\+//g;
push @srcdeps, $dep; push @srcdeps, $dep;
}; };
} }
foreach my $type (@{$src->{buildtypes}}) { foreach my $type ('', @{$src->{buildtypes}}) {
my @extra_deps; my $suffix = '';
my %deplines;
next unless $src->{"builddepends/$type"}; $suffix = "/$type" if $type;
foreach my $dep (@{$src->{"builddepends/$type"}}) {
my $suffix = ""; next unless $src->{"builddepends$suffix"};
defined $deplines{$suffix} or $deplines{$suffix} = {};
foreach my $dep (@{$src->{"builddepends$suffix"}}) {
my $depsuffix = "";
my $deptype = ""; my $deptype = "";
my $condition; my $condition;
@ -464,37 +469,26 @@ sub gen_package_mk() {
if ($dep =~ /^(.+)\/(.+)/) { if ($dep =~ /^(.+)\/(.+)/) {
$dep = $1; $dep = $1;
$deptype = $2; $deptype = $2;
$suffix = "/$2"; $depsuffix = "/$2";
} }
my $idx = ""; next if $srcname.$suffix eq $dep.$depsuffix;
my $pkg_dep = $package{$dep};
if (defined($pkg_dep) && defined($pkg_dep->{src})) { my $src_dep = $srcpackage{$dep};
unless (!$deptype || grep { $_ eq $deptype } @{$pkg_dep->{src}{buildtypes}}) { unless (defined($src_dep) && (!$deptype || grep { $_ eq $deptype } @{$src_dep->{buildtypes}})) {
warn sprintf "WARNING: Makefile '%s' has a %s build dependency on '%s/%s' but '%s' does not implement a '%s' build type\n", warn sprintf "WARNING: Makefile '%s' has a build dependency on '%s%s', which does not exist\n",
$src->{makefile}, $type, $pkg_dep->{src}{name}, $deptype, $pkg_dep->{src}{makefile}, $deptype; $src->{makefile}, $dep, $depsuffix;
next; next;
} }
$idx = $pkg_dep->{src}{path};
} elsif (defined($srcpackage{$dep})) { my $depstr = "\$(curdir)/$src_dep->{path}$depsuffix/compile";
$idx = $srcpackage{$dep}{path};
} else {
next;
}
my $depstr = "\$(curdir)/$idx$suffix/compile";
my $depline = get_conditional_dep($condition, $depstr); my $depline = get_conditional_dep($condition, $depstr);
if ($depline) { if ($depline) {
$deplines{$depline}++; $deplines{$suffix}{$depline}++;
} }
} }
my $depline = join(" ", sort keys %deplines);
if ($depline) {
$line .= "\$(curdir)/$src->{path}/$type/compile += $depline\n";
}
} }
my $hasdeps = 0;
my %deplines;
foreach my $deps (@srcdeps) { foreach my $deps (@srcdeps) {
my $idx; my $idx;
my $condition; my $condition;
@ -552,14 +546,16 @@ sub gen_package_mk() {
} }
$depline = get_conditional_dep($condition, $depstr); $depline = get_conditional_dep($condition, $depstr);
if ($depline) { if ($depline) {
$deplines{$depline}++; $deplines{''}{$depline}++;
} }
} }
} }
} }
my $depline = join(" ", sort keys %deplines); foreach my $suffix (sort keys %deplines) {
my $depline = join(" ", sort keys %{$deplines{$suffix}});
if ($depline) { if ($depline) {
$line .= "\$(curdir)/$src->{path}/compile += $depline\n"; $line .= "\$(curdir)/$src->{path}$suffix/compile += $depline\n";
}
} }
} }