diff --git a/libexec/trick/make_makefile_src b/libexec/trick/make_makefile_src index 674cebcf..59b9233e 100755 --- a/libexec/trick/make_makefile_src +++ b/libexec/trick/make_makefile_src @@ -40,14 +40,16 @@ sub read_lib_deps($@) { read_lib_deps($indent + 1 , @resolved_files) ; } } + } elsif ( exists $ENV{TRICK_VERBOSE_BUILD} ) { + print "Previously processed " , " " x $indent, "$l\n" ; } } } # Update any possibly out of date lib_dep files if ( scalar @ARGV ) { - # Arguments to the executable are rescanned. New makefile is made if any library dependencies - # changed + # Arguments are all files (headers and source) that are newer than the makefile. + # Keep track if any dependencies changed for my $f ( @ARGV ) { my $deps_changed ; my @resolved_files ; @@ -66,7 +68,9 @@ if ( $any_deps_changed == 0 ) { exit ; } -# Start the top level files which are all of the header files and S_define +# If we are here dependencies have changed, or we're running for the first time. +# Read in dependency tree starting at the roots. The dependency tree starts with all of the +# header files ICG processed and the lib deps listed in the S_define file. open FILE, "build/ICG_processed" or die 'cannot open build/ICG_processed' ; my (@top_file_names) = ; close FILE ; @@ -84,8 +88,6 @@ read_lib_deps(0, @top_file_names) ; my ($n , $f , $k , $i , $m); my $num_inc_objs ; -my %all_mis_depends ; -my %temp_hash ; my @all_cfly_files ; my @all_read_only_libs ; my @all_compile_libs ; @@ -149,6 +151,7 @@ foreach $n ( @all_compile_libs ) { # sort and weed out duplicate files foreach $k ( keys %files_by_dir ) { + my %temp_hash ; foreach $n ( qw{ c f l y h C cc cxx cpp c++} ) { undef %temp_hash ; @{$files_by_dir{$k}{$n}} = sort grep ++$temp_hash{$_} < 2, @{$files_by_dir{$k}{$n}} ; diff --git a/libexec/trick/pm/get_lib_deps.pm b/libexec/trick/pm/get_lib_deps.pm index 20ba4241..d8a1e0db 100644 --- a/libexec/trick/pm/get_lib_deps.pm +++ b/libexec/trick/pm/get_lib_deps.pm @@ -37,6 +37,7 @@ sub get_lib_deps ($$) { $file_path_dir =~ s/\/include$// ; my %resolved_files ; + my @ordered_resolved_files ; foreach my $l (@lib_list) { my $found = 0 ; $l =~ s/\(|\)|\s+//g ; @@ -48,7 +49,10 @@ sub get_lib_deps ($$) { foreach my $inc ( dirname($source_file_name) , @inc_paths) { if ( -e "$inc/$rel_dir" ) { my $f = abs_path("$inc/$rel_dir") . "/" . basename($l) ; - $resolved_files{$f} = 1 ; + if ( ! exists $resolved_files{$f} ) { + $resolved_files{$f} = 1 ; + push @ordered_resolved_files , $f ; + } $found = 1 ; last ; } @@ -58,7 +62,10 @@ sub get_lib_deps ($$) { if ( -e "$inc/$l" ) { #print "found $inc/$l$ext\n" ; my $f = abs_path(dirname("$inc/$l")) . "/" . basename("$inc/$l") ; - $resolved_files{$f} = 1 ; + if ( ! exists $resolved_files{$f} ) { + $resolved_files{$f} = 1 ; + push @ordered_resolved_files , $f ; + } $found = 1 ; last ; } @@ -72,27 +79,38 @@ sub get_lib_deps ($$) { if ( -e "$inc/$rel_dir/$base$ext" ) { #print "found $inc/$l$ext\n" ; my $f = abs_path("$inc/$rel_dir") . "/$base$ext" ; - $resolved_files{$f} = 1 ; + if ( ! exists $resolved_files{$f} ) { + $resolved_files{$f} = 1 ; + push @ordered_resolved_files , $f ; + } $found = 1 ; last ; } elsif ( -e "$inc/$rel_dir/src/$base$ext" ) { #print "found $inc/src/$l$ext\n" ; my $f = abs_path("$inc/$rel_dir/src") . "/$base$ext" ; - $resolved_files{$f} = 1 ; + if ( ! exists $resolved_files{$f} ) { + $resolved_files{$f} = 1 ; + push @ordered_resolved_files , $f ; + } $found = 1 ; last ; } } last if ( $found == 1 ) ; } + # file not found, append the "o" we stripped for the error message + $l .= "o" ; } - if ( $found == 0 ) { - print STDERR "Warning: Could not find dependency $l\n" ; + if ( $l =~ /^(sim_services)/ or $l =~ /^(er7_utils)/ ) { + print STDERR "Warning: Not necessary to list $1 dependencies $l\n" ; + } else { + print STDERR "Warning: Could not find dependency $l\n" ; + } } } - return (sort keys %resolved_files) ; + return (@ordered_resolved_files) ; } sub write_lib_deps($) { @@ -100,14 +118,18 @@ sub write_lib_deps($) { my ($source_file_name) = @_ ; my $contents ; { - # read file in slurp mode. Keep the scope of undefining $/ to just this read + # read source file in slurp mode. Keep the scope of undefining $/ (slurp) to this read local $/ = undef ; open SOURCE, $source_file_name or warn 'cannot read $source_file_name' ; $contents = ; close SOURCE ; } + # Get the library dependencies my (@resolved_files) = get_lib_deps($contents, $source_file_name) ; + # Remove a self dependency if it exists + @resolved_files = grep { $_ ne $source_file_name } @resolved_files ; + # Build the library dependencies file name to store results my ( $file, $dir, $suffix) = fileparse($source_file_name, qr/\.[^.]*/) ; my ($lib_dep_file_name) = "build$dir${file}.lib_deps" ; if ( ! -e "build$dir" ) { @@ -115,6 +137,8 @@ sub write_lib_deps($) { } if ( -e $lib_dep_file_name ) { + # If the library dependeny file exists open the old lib dep file + # and compare the new and old lists. open OLDLIBDEP, "$lib_dep_file_name" ; my @old_resolved = ; close OLDLIBDEP ; @@ -127,15 +151,18 @@ sub write_lib_deps($) { $deps_changed = 1 ; } } else { + # If the library dependeny does not exist, the deps changed. $deps_changed = 1 ; } + # if the library dependencies changed, write out the new dependency list if ( $deps_changed ) { open LIBDEP, ">$lib_dep_file_name" ; print LIBDEP map {"$_\n"} @resolved_files ; close LIBDEP ; } + # return the deps changed flag and the list of dependencies return $deps_changed , @resolved_files ; }