summaryrefslogtreecommitdiff
path: root/source4/build/smb_build
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-04-26 16:31:40 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:05:02 -0500
commite28c03aeecef54fb0488c868a86177994788969e (patch)
treee8fe94cad86ef42dc1f728c7a07f2d85b8204879 /source4/build/smb_build
parentbd556984f4bc984cef096a0d8e31311fa901ecfe (diff)
downloadsamba-e28c03aeecef54fb0488c868a86177994788969e.tar.gz
samba-e28c03aeecef54fb0488c868a86177994788969e.tar.bz2
samba-e28c03aeecef54fb0488c868a86177994788969e.zip
r15287: Simplify dependency detection code
(This used to be commit 28a1919ed37f47337f8a53c39b9261a74c5c1bfc)
Diffstat (limited to 'source4/build/smb_build')
-rwxr-xr-xsource4/build/smb_build/dot.pl3
-rw-r--r--source4/build/smb_build/input.pm72
-rw-r--r--source4/build/smb_build/output.pm6
3 files changed, 39 insertions, 42 deletions
diff --git a/source4/build/smb_build/dot.pl b/source4/build/smb_build/dot.pl
index 6abb5bdb43..898d2cd0ff 100755
--- a/source4/build/smb_build/dot.pl
+++ b/source4/build/smb_build/dot.pl
@@ -13,7 +13,8 @@ sub generate($)
my $res = "digraph samba4 {\n";
foreach my $part (values %{$depend}) {
- foreach my $elem (@{$part->{REQUIRED_SUBSYSTEMS}}) {
+ foreach my $elem (@{$part->{PUBLIC_DEPENDENCIES}},
+ @{$part->{PRIVATE_DEPENDENCIES}}) {
$res .= "\t\"$part->{NAME}\" -> \"$elem\";\n";
}
}
diff --git a/source4/build/smb_build/input.pm b/source4/build/smb_build/input.pm
index bb664f8635..a4640df962 100644
--- a/source4/build/smb_build/input.pm
+++ b/source4/build/smb_build/input.pm
@@ -118,29 +118,35 @@ sub check_binary($$)
$bin->{OUTPUT_TYPE} = "BINARY";
}
-my $level = "";
-
-sub calc_unique_deps($$$$)
+sub calc_unique_deps($$$$$$)
{
- sub calc_unique_deps($$$$);
- my ($name, $deps, $udeps, $withlibs) = @_;
-
- print "$level-> $name\n" if ($ENV{SMB_BUILD_VERBOSE});
- $level.=" ";
+ sub calc_unique_deps($$$$$$);
+ my ($name, $INPUT, $deps, $udeps, $withlibs, $busy) = @_;
- foreach my $dep (@{$deps}) {
- next if defined($udeps->{$$dep->{NAME}});
-
- if (defined ($$dep->{OUTPUT_TYPE}) &&
- ($withlibs or ($$dep->{OUTPUT_TYPE} eq "OBJ_LIST") or ($$dep->{OUTPUT_TYPE} eq "MERGEDOBJ") or ($$dep->{OUTPUT_TYPE} eq "STATIC_LIBRARY"))) {
- $udeps->{$$dep->{NAME}} = "BUSY";
- calc_unique_deps($$dep->{NAME}, $$dep->{DEPENDENCIES}, $udeps, $withlibs);
+ foreach my $n (@$deps) {
+ if (grep (/^$n$/, @$busy)) {
+ print "($name) BUSY: $n, list: " . join(',', @$busy) . "\n";
+ # die("Recursive dependency for $dep->{NAME}");
+ next;
+ }
+ next if (grep /^$n$/, @$udeps);
+ my $dep = $INPUT->{$n};
+
+ if (defined ($dep->{OUTPUT_TYPE}) &&
+ ($withlibs or
+ ($dep->{OUTPUT_TYPE} eq "OBJ_LIST") or
+ ($dep->{OUTPUT_TYPE} eq "MERGEDOBJ") or
+ ($dep->{OUTPUT_TYPE} eq "STATIC_LIBRARY"))) {
+ push (@$busy, $dep->{NAME});
+ calc_unique_deps($dep->{NAME}, $INPUT, $dep->{PUBLIC_DEPENDENCIES}, $udeps, $withlibs, $busy);
+ calc_unique_deps($dep->{NAME}, $INPUT, $dep->{PRIVATE_DEPENDENCIES}, $udeps, $withlibs, $busy);
+ pop (@$busy);
}
- $udeps->{$$dep->{NAME}} = $$dep;
+ # FIXME: Insert at the right position
+ push (@{$udeps}, $dep->{NAME});
+
}
-
- $level = substr($level, 1);
}
sub check($$$$$)
@@ -191,31 +197,19 @@ sub check($$$$$)
check_binary($INPUT, $part) if ($part->{TYPE} eq "BINARY");
}
- my %depend = %$INPUT;
-
- foreach my $part (values %depend) {
-
- # Generate list of dependencies
- $part->{DEPENDENCIES} = [];
-
- foreach my $key (@{$part->{PUBLIC_DEPENDENCIES}},
- @{$part->{PRIVATE_DEPENDENCIES}}) {
- die("$part->{NAME} has undefined dependency $key\n") if not defined($depend{$key});
- push (@{$part->{DEPENDENCIES}}, \$depend{$key});
- }
- }
-
- foreach my $part (values %depend) {
- $part->{UNIQUE_DEPENDENCIES} = {};
- calc_unique_deps($part->{NAME}, $part->{DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES}, 0);
+ foreach my $part (values %$INPUT) {
+ $part->{UNIQUE_DEPENDENCIES} = [];
+ calc_unique_deps($part->{NAME}, $INPUT, $part->{PUBLIC_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES}, 0, []);
+ calc_unique_deps($part->{NAME}, $INPUT, $part->{PRIVATE_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES}, 0, []);
}
- foreach my $part (values %depend) {
- $part->{UNIQUE_DEPENDENCIES_ALL} = {};
- calc_unique_deps($part->{NAME}, $part->{DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES_ALL}, 1);
+ foreach my $part (values %$INPUT) {
+ $part->{UNIQUE_DEPENDENCIES_ALL} = [];
+ calc_unique_deps($part->{NAME}, $INPUT, $part->{PUBLIC_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES_ALL}, 1, []);
+ calc_unique_deps($part->{NAME}, $INPUT, $part->{PRIVATE_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES_ALL}, 1, []);
}
- return \%depend;
+ return $INPUT;
}
1;
diff --git a/source4/build/smb_build/output.pm b/source4/build/smb_build/output.pm
index a53a9263f9..de122ee9a0 100644
--- a/source4/build/smb_build/output.pm
+++ b/source4/build/smb_build/output.pm
@@ -147,7 +147,8 @@ sub create_output($$)
foreach $part (values %{$depend}) {
next if not defined($part->{OUTPUT_TYPE});
- foreach my $elem (values %{$part->{UNIQUE_DEPENDENCIES_ALL}}) {
+ foreach (@{$part->{UNIQUE_DEPENDENCIES_ALL}}) {
+ my $elem = $depend->{$_};
next if $elem == $part;
push(@{$part->{PUBLIC_CFLAGS}}, @{$elem->{CPPFLAGS}}) if defined(@{$elem->{CPPFLAGS}});
@@ -156,7 +157,8 @@ sub create_output($$)
# Always import the CFLAGS and CPPFLAGS of the unique dependencies
- foreach my $elem (values %{$part->{UNIQUE_DEPENDENCIES}}) {
+ foreach (@{$part->{UNIQUE_DEPENDENCIES}}) {
+ my $elem = $depend->{$_};
next if $elem == $part;
push(@{$part->{LINK_LIST}}, $elem->{OUTPUT}) if defined($elem->{OUTPUT});