mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-21 06:33:41 +00:00
metadata: interate over source packages when generating Makefile
All build dependencies are between source packages. Interating over source rather than binary packages simplifies parts of the code and prepares further improvement. As a side effect, this changes the implicit default variant of a few packages (the first defined is used now instead of the lexicographically first). Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
This commit is contained in:
parent
b2ab9c9d33
commit
47f292ff78
@ -213,6 +213,7 @@ sub parse_package_metadata($) {
|
|||||||
$subdir =~ s/^package\///;
|
$subdir =~ s/^package\///;
|
||||||
$subdir{$src} = $subdir;
|
$subdir{$src} = $subdir;
|
||||||
$srcpackage{$src} = {
|
$srcpackage{$src} = {
|
||||||
|
makefile => $makefile,
|
||||||
packages => [],
|
packages => [],
|
||||||
buildtypes => [],
|
buildtypes => [],
|
||||||
builddepends => [],
|
builddepends => [],
|
||||||
|
@ -414,36 +414,45 @@ sub get_conditional_dep($$) {
|
|||||||
sub gen_package_mk() {
|
sub gen_package_mk() {
|
||||||
my %conf;
|
my %conf;
|
||||||
my %dep;
|
my %dep;
|
||||||
my %done;
|
|
||||||
my $line;
|
my $line;
|
||||||
|
|
||||||
parse_package_metadata($ARGV[0]) or exit 1;
|
parse_package_metadata($ARGV[0]) or exit 1;
|
||||||
foreach my $name (sort {uc($a) cmp uc($b)} keys %package) {
|
foreach my $srcname (sort {uc($a) cmp uc($b)} keys %srcpackage) {
|
||||||
my $config;
|
my $src = $srcpackage{$srcname};
|
||||||
my $pkg = $package{$name};
|
my $path = $subdir{$srcname}.$srcname;
|
||||||
my $src = $srcpackage{$pkg->{src}};
|
my $variant_default;
|
||||||
my @srcdeps;
|
my @srcdeps;
|
||||||
|
|
||||||
|
foreach my $pkg (@{$src->{packages}}) {
|
||||||
next if defined $pkg->{vdepends};
|
next if defined $pkg->{vdepends};
|
||||||
|
|
||||||
$config = "\$(CONFIG_PACKAGE_$name)";
|
my $config = '';
|
||||||
if ($config) {
|
$config = "\$(CONFIG_PACKAGE_$pkg->{name})" unless $pkg->{buildonly};
|
||||||
$pkg->{buildonly} and $config = "";
|
|
||||||
print "package-$config += $pkg->{subdir}$pkg->{src}\n";
|
$pkg->{prereq} and print "prereq-$config += $path\n";
|
||||||
|
|
||||||
|
next if $pkg->{buildonly};
|
||||||
|
|
||||||
|
print "package-$config += $path\n";
|
||||||
|
|
||||||
if ($pkg->{variant}) {
|
if ($pkg->{variant}) {
|
||||||
if (!defined($done{$pkg->{src}}) or $pkg->{variant_default}) {
|
if (!defined($variant_default) or $pkg->{variant_default}) {
|
||||||
print "\$(curdir)/$pkg->{subdir}$pkg->{src}/default-variant := $pkg->{variant}\n";
|
$variant_default = $pkg->{variant};
|
||||||
}
|
}
|
||||||
print "\$(curdir)/$pkg->{subdir}$pkg->{src}/variants += \$(if $config,$pkg->{variant})\n"
|
print "\$(curdir)/$path/variants += \$(if $config,$pkg->{variant})\n";
|
||||||
}
|
}
|
||||||
$pkg->{prereq} and print "prereq-$config += $pkg->{subdir}$pkg->{src}\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
next if $done{$pkg->{src}};
|
if (defined($variant_default)) {
|
||||||
$done{$pkg->{src}} = 1;
|
print "\$(curdir)/$path/default-variant := $variant_default\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
unless (grep {!$_->{buildonly}} @{$src->{packages}}) {
|
||||||
|
print "package- += $path\n";
|
||||||
|
}
|
||||||
|
|
||||||
if (@{$src->{buildtypes}} > 0) {
|
if (@{$src->{buildtypes}} > 0) {
|
||||||
print "buildtypes-$pkg->{subdir}$pkg->{src} = ".join(' ', @{$src->{buildtypes}})."\n";
|
print "buildtypes-$path = ".join(' ', @{$src->{buildtypes}})."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $dep (@{$src->{builddepends}}, map { @{$_->{depends}} } @{$src->{packages}}) {
|
foreach my $dep (@{$src->{builddepends}}, map { @{$_->{depends}} } @{$src->{packages}}) {
|
||||||
@ -477,7 +486,7 @@ sub gen_package_mk() {
|
|||||||
if (defined($pkg_dep) && defined($pkg_dep->{src})) {
|
if (defined($pkg_dep) && defined($pkg_dep->{src})) {
|
||||||
unless (!$deptype || grep { $_ eq $deptype } @{$srcpackage{$pkg_dep->{src}}{buildtypes}}) {
|
unless (!$deptype || grep { $_ eq $deptype } @{$srcpackage{$pkg_dep->{src}}{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 %s build dependency on '%s/%s' but '%s' does not implement a '%s' build type\n",
|
||||||
$pkg->{makefile}, $type, $pkg_dep->{src}, $deptype, $pkg_dep->{makefile}, $deptype;
|
$src->{makefile}, $type, $pkg_dep->{src}, $deptype, $pkg_dep->{makefile}, $deptype;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
$idx = $pkg_dep->{subdir}.$pkg_dep->{src};
|
$idx = $pkg_dep->{subdir}.$pkg_dep->{src};
|
||||||
@ -494,7 +503,7 @@ sub gen_package_mk() {
|
|||||||
}
|
}
|
||||||
my $depline = join(" ", sort keys %deplines);
|
my $depline = join(" ", sort keys %deplines);
|
||||||
if ($depline) {
|
if ($depline) {
|
||||||
$line .= "\$(curdir)/".$pkg->{subdir}."$pkg->{src}/$type/compile += $depline\n";
|
$line .= "\$(curdir)/$path/$type/compile += $depline\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,7 +540,7 @@ sub gen_package_mk() {
|
|||||||
if (defined $pkg_dep->{src}) {
|
if (defined $pkg_dep->{src}) {
|
||||||
unless (!$deptype || grep { $_ eq $deptype } @{$srcpackage{$pkg_dep->{src}}{buildtypes}}) {
|
unless (!$deptype || grep { $_ eq $deptype } @{$srcpackage{$pkg_dep->{src}}{buildtypes}}) {
|
||||||
warn sprintf "WARNING: Makefile '%s' has a 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' but '%s' does not implement a '%s' build type\n",
|
||||||
$pkg->{makefile}, $pkg_dep->{src}, $deptype, $pkg_dep->{makefile}, $deptype;
|
$src->{makefile}, $pkg_dep->{src}, $deptype, $pkg_dep->{makefile}, $deptype;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
$idx = $pkg_dep->{subdir}.$pkg_dep->{src};
|
$idx = $pkg_dep->{subdir}.$pkg_dep->{src};
|
||||||
@ -543,17 +552,17 @@ sub gen_package_mk() {
|
|||||||
$idx .= $suffix;
|
$idx .= $suffix;
|
||||||
|
|
||||||
my $depline;
|
my $depline;
|
||||||
next if $pkg->{src} eq $pkg_dep->{src}.$suffix;
|
next if $srcname eq $pkg_dep->{src}.$suffix;
|
||||||
next if $dep{$condition.":".$pkg->{src}."->".$idx};
|
next if $dep{$condition.":".$srcname."->".$idx};
|
||||||
next if $dep{$pkg->{src}."->($dep)".$idx} and $pkg_dep->{vdepends};
|
next if $dep{$srcname."->($dep)".$idx} and $pkg_dep->{vdepends};
|
||||||
my $depstr;
|
my $depstr;
|
||||||
|
|
||||||
if ($pkg_dep->{vdepends}) {
|
if ($pkg_dep->{vdepends}) {
|
||||||
$depstr = "\$(if \$(CONFIG_PACKAGE_$dep),\$(curdir)/$idx/compile)";
|
$depstr = "\$(if \$(CONFIG_PACKAGE_$dep),\$(curdir)/$idx/compile)";
|
||||||
$dep{$pkg->{src}."->($dep)".$idx} = 1;
|
$dep{$srcname."->($dep)".$idx} = 1;
|
||||||
} else {
|
} else {
|
||||||
$depstr = "\$(curdir)/$idx/compile";
|
$depstr = "\$(curdir)/$idx/compile";
|
||||||
$dep{$pkg->{src}."->".$idx} = 1;
|
$dep{$srcname."->".$idx} = 1;
|
||||||
}
|
}
|
||||||
$depline = get_conditional_dep($condition, $depstr);
|
$depline = get_conditional_dep($condition, $depstr);
|
||||||
if ($depline) {
|
if ($depline) {
|
||||||
@ -564,7 +573,7 @@ sub gen_package_mk() {
|
|||||||
}
|
}
|
||||||
my $depline = join(" ", sort keys %deplines);
|
my $depline = join(" ", sort keys %deplines);
|
||||||
if ($depline) {
|
if ($depline) {
|
||||||
$line .= "\$(curdir)/".$pkg->{subdir}."$pkg->{src}/compile += $depline\n";
|
$line .= "\$(curdir)/$path/compile += $depline\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user