diff options
author | elliott_c <ocielliottc@users.noreply.github.com> | 2003-09-10 13:08:26 +0000 |
---|---|---|
committer | elliott_c <ocielliottc@users.noreply.github.com> | 2003-09-10 13:08:26 +0000 |
commit | 760fc8387c7d477946b5693af23ae3b5f9567750 (patch) | |
tree | 323e9ae88e1e1c4889547ee4b930d7c24e466058 | |
parent | 363d867e309986a080713a16a39ec1852031655e (diff) | |
download | ATCD-760fc8387c7d477946b5693af23ae3b5f9567750.tar.gz |
ChangeLogTag: Wed Sep 10 08:04:25 2003 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | bin/MakeProjectCreator/modules/GNUACEWorkspaceCreator.pm | 6 | ||||
-rw-r--r-- | bin/MakeProjectCreator/modules/ProjectCreator.pm | 35 | ||||
-rw-r--r-- | bin/MakeProjectCreator/modules/WorkspaceCreator.pm | 123 |
4 files changed, 170 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog index 8d2e8eb5308..aa184dec69e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Wed Sep 10 08:04:25 2003 Chad Elliott <elliott_c@ociweb.com> + + * bin/MakeProjectCreator/modules/GNUACEWorkspaceCreator.pm: + * bin/MakeProjectCreator/modules/ProjectCreator.pm: + * bin/MakeProjectCreator/modules/WorkspaceCreator.pm: + + Added automatic parallel dependencies. If more than one project + in the same directory contains shared source files, then the + projects will become dependent upon each other. This will help + avoid files (both generated source and object) being overwritten + by multiple instances of make. This only has an effect on the + GNUACE workspaces. + Tue Sep 9 08:56:42 2003 Jeff Parsons <j.parsons@vanderbilt.edu> * ace/ace_dll.dsp: diff --git a/bin/MakeProjectCreator/modules/GNUACEWorkspaceCreator.pm b/bin/MakeProjectCreator/modules/GNUACEWorkspaceCreator.pm index 0fbed6ae03f..bd27942f92b 100644 --- a/bin/MakeProjectCreator/modules/GNUACEWorkspaceCreator.pm +++ b/bin/MakeProjectCreator/modules/GNUACEWorkspaceCreator.pm @@ -32,6 +32,12 @@ my(@targets) = ('all', 'debug', 'profile', 'optimize', # Subroutine Section # ************************************************************ +sub generate_implicit_project_dependencies { + #my($self) = shift; + return 1; +} + + sub workspace_file_name { my($self) = shift; return $self->get_modified_workspace_name('Makefile', ''); diff --git a/bin/MakeProjectCreator/modules/ProjectCreator.pm b/bin/MakeProjectCreator/modules/ProjectCreator.pm index 1254efda11b..384101debf8 100644 --- a/bin/MakeProjectCreator/modules/ProjectCreator.pm +++ b/bin/MakeProjectCreator/modules/ProjectCreator.pm @@ -175,6 +175,7 @@ sub new { $self->{'feature_parser'} = new FeatureParser($gfeature, $feature); $self->{'convert_slashes'} = $self->convert_slashes(); $self->{'sort_files'} = $self->sort_files(); + $self->{'source_callback'} = undef; $self->reset_generating_types(); return $self; @@ -2032,6 +2033,23 @@ sub write_output_file { ($status, $error) = $tp->parse_file($tfile); if ($status) { + if (defined $self->{'source_callback'}) { + my($cb) = $self->{'source_callback'}; + my($pjname) = $self->get_assignment('project_name'); + my(@list) = $self->get_component_list('source_files'); + if (UNIVERSAL::isa($cb, 'ARRAY')) { + my(@copy) = @$cb; + my($s) = shift(@copy); + &$s(@copy, $name, $pjname, @list); + } + elsif (UNIVERSAL::isa($cb, 'CODE')) { + &$cb($name, $pjname, @list); + } + else { + print "WARNING: Ignoring callback: $cb\n"; + } + } + if ($self->get_toplevel()) { my($fh) = new FileHandle(); my($dir) = dirname($name); @@ -2092,11 +2110,11 @@ sub write_output_file { sub write_project { - my($self) = shift; - my($status) = 1; - my($error) = ''; - my($file_name) = $self->transform_file_name($self->project_file_name()); - my($progress) = $self->get_progress_callback(); + my($self) = shift; + my($status) = 1; + my($error) = ''; + my($file_name) = $self->transform_file_name($self->project_file_name()); + my($progress) = $self->get_progress_callback(); if (defined $progress) { &$progress(); @@ -2166,6 +2184,13 @@ sub set_component_extensions { } +sub set_source_listing_callback { + my($self) = shift; + my($cb) = shift; + $self->{'source_callback'} = $cb; +} + + sub reset_values { my($self) = shift; $self->{'project_info'} = []; diff --git a/bin/MakeProjectCreator/modules/WorkspaceCreator.pm b/bin/MakeProjectCreator/modules/WorkspaceCreator.pm index 4137968bd63..d4c62c6a90c 100644 --- a/bin/MakeProjectCreator/modules/WorkspaceCreator.pm +++ b/bin/MakeProjectCreator/modules/WorkspaceCreator.pm @@ -84,6 +84,7 @@ sub new { $self->{'modified_count'} = 0; $self->{'global_feature_file'} = $gfeature; $self->{'coexistence'} = $makeco; + $self->{'project_file_list'} = {}; if (defined $$exclude[0]) { my($type) = $self->{'wctype'}; @@ -698,6 +699,9 @@ sub generate_project_files { ## Remove the address portion of the $self string $postkey =~ s/=.*//; + ## Set the source file callback on our project creator + $generator->set_source_listing_callback([\&source_listing_callback, $self]); + foreach my $ofile (@{$self->{'project_files'}}) { if (!$self->excluded($ofile)) { my($file) = $ofile; @@ -838,10 +842,95 @@ sub generate_project_files { $self->{'projects'} = \@projects; $self->{'project_info'} = \%pi; + ## Add implict project dependencies based on source files + ## that have been used by multiple projects + if ($status && $self->generate_implicit_project_dependencies()) { + $self->add_implicit_project_dependencies($generator, $cwd); + } + return $status, $generator; } +sub array_contains { + my($self) = shift; + my($left) = shift; + my($right) = shift; + my($over) = shift; + my($status) = 0; + my(%check) = (); + + ## Initialize the hash keys with the left side array + @check{@$left} = (); + + ## Check each element on the right against the left. + ## Store anything that isn't in the left side in the over array. + foreach my $r (@$right) { + if (exists $check{$r}) { + $status = 1; + } + elsif (defined $over) { + push(@$over, $r); + } + } + return $status; +} + + +sub add_implicit_project_dependencies { + my($self) = shift; + my($generator) = shift; + my($cwd) = shift; + my(%bidir) = (); + + ## Take the current working directory and regular expression'ize it. + $cwd = $self->escape_regex_special($cwd) . '/'; + + ## Look at each projects file list and check it against all of the + ## others. If any of the other projects file lists contains anothers + ## file, then they are dependent (due to build parallelism). So, we + ## append the dependency and remove the file in question from the + ## project so that the next time around the foreach, we don't find it + ## as a dependent on the one that we just modified. + foreach my $key (sort keys %{$self->{'project_file_list'}}) { + foreach my $ikey (keys %{$self->{'project_file_list'}}) { + if ($key ne $ikey && + (!defined $bidir{$ikey} || + !$self->array_contains($bidir{$ikey}, [$key])) && + ($self->{'project_file_list'}->{$key}->[1] eq + $self->{'project_file_list'}->{$ikey}->[1])) { + my(@over) = (); + if ($self->array_contains( + $self->{'project_file_list'}->{$key}->[2], + $self->{'project_file_list'}->{$ikey}->[2], + \@over)) { + $self->{'project_file_list'}->{$ikey}->[2] = \@over; + if (defined $bidir{$key}) { + push(@{$bidir{$key}}, $ikey); + } + else { + $bidir{$key} = [$ikey]; + } + my($append) = $generator->translate_value('after', $key); + my($file) = $self->{'project_file_list'}->{$ikey}->[0]; + my($dir) = $self->{'project_file_list'}->{$ikey}->[1]; + + ## Remove our starting directory from the projects directory + ## to get the right part of the directory to prepend. + $dir =~ s/^$cwd//; + if ($dir ne '') { + $file = "$dir/$file"; + } + + ## Append the dependency + $self->{'project_info'}->{$file}->[1] .= " $append"; + } + } + } + } +} + + sub get_projects { my($self) = shift; return $self->{'projects'}; @@ -873,6 +962,10 @@ sub sort_dependencies { %$prepref = %prepend; } + ## These will help us catch circular dependencies + my($start_project) = ''; + my($moved_project) = ''; + ## Put the projects in the order specified ## by the project dpendencies. for(my $i = 0; $i <= $#list; ++$i) { @@ -890,7 +983,15 @@ sub sort_dependencies { if ($project ne $full) { ## See if the dependency is listed after this project for(my $j = $i; $j <= $#list; ++$j) { - if ($list[$j] eq $full && $i != $j) { + if ($i != $j && $list[$j] eq $full && + $list[$i] ne $moved_project && + $list[$j] ne $start_project) { + ## Keep track of the one we started with and the + ## one we are going to move. If there is a circular + ## dependency, the next time through we will catch it. + $start_project = $list[$i]; + $moved_project = $list[$j]; + ## If so, move it in front of the current project. ## The original code, which had splices, didn't always ## work correctly (especially on AIX for some reason). @@ -1173,7 +1274,7 @@ sub get_validated_ordering { my($projects) = $self->get_projects(); foreach my $dep (@$darr) { my($found) = 0; - ## Avoid cirular dependencies + ## Avoid circular dependencies if ($dep ne $name && $dep ne basename($project)) { foreach my $p (@$projects) { if ($dep eq $$pjs{$p}->[0] || $dep eq basename($p)) { @@ -1198,15 +1299,33 @@ sub get_validated_ordering { return $deps; } + +sub source_listing_callback { + my($self) = shift; + my($project_file) = shift; + my($project_name) = shift; + my(@files) = @_; + my($cwd) = $self->getcwd(); + $self->{'project_file_list'}->{$project_name} = [ $project_file, + $cwd, \@files ]; +} + # ************************************************************ # Virtual Methods To Be Overridden # ************************************************************ +sub generate_implicit_project_dependencies { + #my($self) = shift; + return 0; +} + + sub allow_duplicates { #my($self) = shift; return 1; } + sub workspace_file_name { #my($self) = shift; return ''; |