From: Yousong Zhou Date: Wed, 28 Feb 2018 03:27:42 +0000 (+0800) Subject: metadata: compile dependencies only when the package is selected X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=26ce50f3ca5a97dcab3c30205c9210ce3b04d43c;p=openwrt%2Fstaging%2Fyousong.git metadata: compile dependencies only when the package is selected This is intended to reduce build time for situations like the following where python and python-six and their dependencies could still be built as long as any subpackage within the srcpackage was selected regardless of the selection state of openvswitch-python define Package/openvswitch-python ... DEPENDS:=+python +python-six endef Previously we work around this by specifying the dependency as +PACKAGE_openvswitch-python:python, which is unintuitive Signed-off-by: Yousong Zhou --- diff --git a/scripts/package-metadata.pl b/scripts/package-metadata.pl index 53bb45a62c..b82715441b 100755 --- a/scripts/package-metadata.pl +++ b/scripts/package-metadata.pl @@ -382,6 +382,7 @@ sub gen_package_mk() { my %deplines = ('' => {}); foreach my $pkg (@{$src->{packages}}) { + my @pkgdeplines; foreach my $dep (@{$pkg->{depends}}) { next if ($dep =~ /@/); @@ -410,10 +411,17 @@ sub gen_package_mk() { } my $depline = get_conditional_dep($condition, $depstr); if ($depline) { - $deplines{''}{$depline}++; + push @pkgdeplines, $depline; } } } + if (@pkgdeplines) { + my $depstr = join(' ', @pkgdeplines); + if ($depstr) { + my $depline = get_conditional_dep('PACKAGE_'.$pkg->{name}, $depstr); + $deplines{''}{$depline}++; + } + } my $config = ''; $config = sprintf '$(CONFIG_PACKAGE_%s)', $pkg->{name} unless $pkg->{buildonly}; @@ -486,8 +494,7 @@ sub gen_package_mk() { } foreach my $suffix (sort keys %deplines) { - my $depline = join(" ", sort keys %{$deplines{$suffix}}); - if ($depline) { + for my $depline (sort keys %{$deplines{$suffix}}) { $line .= sprintf "\$(curdir)/%s/compile += %s\n", $src->{path}.$suffix, $depline; } }