initial gnumake module deps dumping.
This commit is contained in:
parent
7cd6f8f7ad
commit
d614ca7ebe
3 changed files with 91 additions and 0 deletions
|
@ -403,6 +403,9 @@ findunusedcode:
|
|||
|
||||
check: dev-install subsequentcheck
|
||||
|
||||
dump-deps:
|
||||
$(SRCDIR)/bin/module-deps.pl $(GNUMAKE) $(SRCDIR)/Makefile.gbuild
|
||||
|
||||
subsequentcheck :| $(if $(filter-out subsequentcheck,$(MAKECMDGOALS)),dev-install)
|
||||
$(GNUMAKE) -j $(CHECK_PARALLELISM) $(GMAKE_OPTIONS) -f $(SRCDIR)/Makefile.gbuild $@
|
||||
|
||||
|
|
79
bin/module-deps.pl
Executable file
79
bin/module-deps.pl
Executable file
|
@ -0,0 +1,79 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
|
||||
my $gnumake;
|
||||
my $makefile_build;
|
||||
|
||||
sub read_deps()
|
||||
{
|
||||
my $p;
|
||||
my $invalid_tolerance = 100;
|
||||
my $line_count = 0;
|
||||
my %deps;
|
||||
open ($p, "ENABLE_PRINT_DEPS=1 $gnumake -n -f $makefile_build all|") || die "can't launch make: $!";
|
||||
# open ($p, "/tmp/deps") || die "can't read deps: $!";
|
||||
$|=1;
|
||||
print STDERR "reading deps ";
|
||||
while (<$p>) {
|
||||
my $line = $_;
|
||||
$line_count++;
|
||||
print STDERR '.' if ($line_count % 10 == 0);
|
||||
# print STDERR $line;
|
||||
chomp ($line);
|
||||
if ($line =~ m/^LibraryDep:\s+(\S+) links against (.*)$/) {
|
||||
# if ($line =~ m/^LibraryDep:\s+(\S+)\s+links against/) {
|
||||
$deps{$1} = ' ' if (!defined $deps{$1});
|
||||
$deps{$1} = $deps{$1} . ' ' . $2;
|
||||
} elsif ($line =~ m/^LibraryDep:\s+links against/) {
|
||||
# these need fixing, we call gb_LinkTarget__use_$...
|
||||
# and get less than normal data back to gb_LinkTarget_use_libraries
|
||||
# print STDERR "ignoring unhelpful external dep\n";
|
||||
} elsif ($invalid_tolerance < 0) {
|
||||
# print "read all dependencies to: '$line'\n";
|
||||
last;
|
||||
} else {
|
||||
# print "no match '$line'\n";
|
||||
$invalid_tolerance--;
|
||||
}
|
||||
}
|
||||
close ($p);
|
||||
print STDERR " done\n";
|
||||
|
||||
return \%deps;
|
||||
}
|
||||
|
||||
# first create nodes for each entry
|
||||
sub build_tree($)
|
||||
{
|
||||
my $deps = shift;
|
||||
for my $name (sort keys %{$deps}) {
|
||||
my $need_str = $deps->{$name};
|
||||
$need_str =~ s/^\s+//g;
|
||||
$need_str =~ s/\s+$//g;
|
||||
my @needs = split /\s+/, $need_str;
|
||||
$name =~ m/^([^_]+)_(\S+)$/ || die "invalid target name: '$name'";
|
||||
my $type = $1;
|
||||
my $target = $2;
|
||||
$type eq 'Executable' || $type eq 'Library' ||
|
||||
$type eq 'CppunitTest' || die "Unknown type '$type'";
|
||||
print "$target ($type): " . join (',', @needs) . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
while (my $arg = shift @ARGV) {
|
||||
if (!defined $gnumake) {
|
||||
$gnumake = $arg;
|
||||
} elsif (!defined $makefile_build) {
|
||||
$makefile_build = $arg;
|
||||
} else {
|
||||
die "un-needed argument '$arg'";
|
||||
}
|
||||
}
|
||||
|
||||
$gnumake = 'make' if (!defined $gnumake);
|
||||
$makefile_build = 'Makefile.gbuild' if (!defined $makefile_build);
|
||||
|
||||
my $deps = read_deps();
|
||||
my $tree = build_tree($deps);
|
||||
|
|
@ -816,12 +816,21 @@ $$(call gb_Output_error,\
|
|||
gb_LinkTarget_add_linked_libs: use gb_LinkTarget_use_libraries instead.)
|
||||
endef
|
||||
|
||||
define gb_PrintDeps_info
|
||||
$(info LibraryDep: $(4) links against $(2))
|
||||
endef
|
||||
|
||||
define gb_LinkTarget_use_libraries
|
||||
ifneq (,$$(filter-out $(gb_Library_KNOWNLIBS),$(2)))
|
||||
$$(eval $$(call gb_Output_info,currently known libraries are: $(sort $(gb_Library_KNOWNLIBS)),ALL))
|
||||
$$(eval $$(call gb_Output_error,Cannot link against library/libraries $$(filter-out $(gb_Library_KNOWNLIBS),$(2)). Libraries must be registered in Repository.mk))
|
||||
endif
|
||||
|
||||
# used by bin/module-deps.pl
|
||||
ifneq ($(ENABLE_PRINT_DEPS),)
|
||||
$$(eval $$(call gb_PrintDeps_info,$(1),$(2),$(3),$(4)))
|
||||
endif
|
||||
|
||||
gb_LINKED_LIBS := $(if $(filter $(gb_MERGEDLIBS),$(2)), \
|
||||
$(if $(filter $(1),$(foreach lib,$(gb_MERGEDLIBS),$(call gb_Library_get_linktargetname,$(lib)))),, merged)) \
|
||||
$(filter-out $(gb_MERGEDLIBS),$(2))
|
||||
|
|
Loading…
Reference in a new issue