diff options
author | elliott_c <ocielliottc@users.noreply.github.com> | 2003-05-15 12:12:05 +0000 |
---|---|---|
committer | elliott_c <ocielliottc@users.noreply.github.com> | 2003-05-15 12:12:05 +0000 |
commit | bd3ed29bcac1daba684b389041d6eabd9482b236 (patch) | |
tree | 34d9b137823b1ad2e5330138dd892071a84dff76 | |
parent | 9061081f309836fde4dc217b561b8993a20c3986 (diff) | |
download | MPC-bd3ed29bcac1daba684b389041d6eabd9482b236.tar.gz |
ChangeLogTag: Thu May 15 07:08:39 2003 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r-- | modules/ProjectCreator.pm | 11 | ||||
-rw-r--r-- | modules/WorkspaceCreator.pm | 38 | ||||
-rw-r--r-- | templates/em3.mpd | 2 | ||||
-rw-r--r-- | templates/em3vcp.mpd | 2 | ||||
-rw-r--r-- | templates/make.mpd | 2 | ||||
-rw-r--r-- | templates/nmake.mpd | 2 | ||||
-rw-r--r-- | templates/vc6.mpd | 2 | ||||
-rw-r--r-- | templates/vc6dsp.mpd | 2 | ||||
-rw-r--r-- | templates/vc7.mpd | 2 |
9 files changed, 54 insertions, 9 deletions
diff --git a/modules/ProjectCreator.pm b/modules/ProjectCreator.pm index 1700cb6d..1b631b4d 100644 --- a/modules/ProjectCreator.pm +++ b/modules/ProjectCreator.pm @@ -936,10 +936,11 @@ sub generate_default_target_names { ## If it's neither an exe or library target, we will search ## through the source files for a main() + my(@sources) = $self->get_component_list('source_files'); if (!$self->lib_target()) { my($fh) = new FileHandle(); my($exename) = undef; - foreach my $file ($self->get_component_list('source_files')) { + foreach my $file (@sources) { if (open($fh, $file)) { while(<$fh>) { ## Remove c++ comments (ignore c style comments for now) @@ -965,8 +966,8 @@ sub generate_default_target_names { } ## If we still don't have a project type, then we will - ## default to a library - if (!$self->exe_target()) { + ## default to a library if there are source files + if (!$self->exe_target() && $#sources >= 0) { my($base) = $self->get_assignment('project_name'); $self->process_assignment('sharedname', $base); $self->process_assignment('staticname', $base); @@ -1645,7 +1646,9 @@ sub check_custom_output { } my($re) = $self->escape_regex_special(basename($base)); foreach my $c (@$comps) { - if ($c =~ /$re$/) { + ## We only match if the built file name matches from + ## beginning to end or from a slash to the end. + if ($c =~ /^$re$/ || $c =~ /\/$re$/) { push(@outputs, $built); last; } diff --git a/modules/WorkspaceCreator.pm b/modules/WorkspaceCreator.pm index 332d93c6..bccc84d4 100644 --- a/modules/WorkspaceCreator.pm +++ b/modules/WorkspaceCreator.pm @@ -13,6 +13,7 @@ package WorkspaceCreator; use strict; use FileHandle; use File::Path; +use File::Compare; use File::Basename; use Creator; @@ -484,21 +485,48 @@ sub write_workspace { if ($dir ne '.') { mkpath($dir, 0, 0777); } - if (open($fh, ">$name")) { + + ## First write the output to a temporary file + my($tmp) = "MWC$>.$$"; + my($different) = 1; + if (open($fh, ">$tmp")) { $self->pre_workspace($fh); $self->write_comps($fh, $generator); $self->post_workspace($fh); close($fh); - if ($addfile) { - $self->add_file_written($name); + if (-r $name && + -s $tmp == -s $name && compare($tmp, $name) == 0) { + $different = 0; } } else { - $error = 'ERROR: Unable to open ' . $self->getcwd() . - "/$name for output"; + $error = "ERROR: Unable to open $tmp for output."; $status = 0; } + + if ($status) { + if ($different) { + unlink($name); + if (rename($tmp, $name)) { + if ($addfile) { + $self->add_file_written($name); + } + } + else { + $error = 'ERROR: Unable to open ' . $self->getcwd() . + "/$name for output"; + $status = 0; + } + } + else { + ## We will pretend that we wrote the file + unlink($tmp); + if ($addfile) { + $self->add_file_written($name); + } + } + } } else { print "WARNING: No projects were created.\n" . diff --git a/templates/em3.mpd b/templates/em3.mpd index 206553df..fea85e0a 100644 --- a/templates/em3.mpd +++ b/templates/em3.mpd @@ -232,6 +232,7 @@ BuildCmds= \ # PROP Default_Filter "<%foreach(custom_type->inputexts)%><%custom_type->inputext%><%fornotlast(";")%><%endfor%>" <%foreach(custom_type->input_files)%> +<%if(custom_type->input_file->output_files)%> # Begin Source File SOURCE=.\<%custom_type->input_file%> @@ -269,6 +270,7 @@ BuildCmds= \ !ENDIF # End Source File +<%endif%> <%endfor%> # End Group <%endfor%> diff --git a/templates/em3vcp.mpd b/templates/em3vcp.mpd index 206553df..fea85e0a 100644 --- a/templates/em3vcp.mpd +++ b/templates/em3vcp.mpd @@ -232,6 +232,7 @@ BuildCmds= \ # PROP Default_Filter "<%foreach(custom_type->inputexts)%><%custom_type->inputext%><%fornotlast(";")%><%endfor%>" <%foreach(custom_type->input_files)%> +<%if(custom_type->input_file->output_files)%> # Begin Source File SOURCE=.\<%custom_type->input_file%> @@ -269,6 +270,7 @@ BuildCmds= \ !ENDIF # End Source File +<%endif%> <%endfor%> # End Group <%endfor%> diff --git a/templates/make.mpd b/templates/make.mpd index 099cf8df..1424f26f 100644 --- a/templates/make.mpd +++ b/templates/make.mpd @@ -71,12 +71,14 @@ OUTPUT_OPTION = -o $@ <%if(custom_types)%> <%foreach(custom_types)%> <%foreach(custom_type->input_files)%> +<%if(custom_type->input_file->output_files)%> GENERATED_DIRTY +=<%foreach(custom_type->input_file->output_files)%> <%if(flag_overrides(custom_type->input_file, gendir))%><%flag_overrides(custom_type->input_file, gendir)%>/<%basename(custom_type->input_file->output_file)%><%else%><%custom_type->input_file->output_file%><%endif%><%endfor%> <%foreach(custom_type->input_file->output_files)%> <%if(flag_overrides(custom_type->input_file, gendir))%><%flag_overrides(custom_type->input_file, gendir)%>/<%basename(custom_type->input_file->output_file)%><%else%><%custom_type->input_file->output_file%><%endif%>: <%custom_type->input_file%> <%custom_type->command%> <%if(flag_overrides(custom_type->input_file, commandflags))%><%flag_overrides(custom_type->input_file, commandflags)%><%else%><%custom_type->commandflags%><%endif%> $^ <%if(custom_type->output_option)%><%custom_type->output_option%> $@<%endif%> <%endfor%> +<%endif%> <%endfor%> <%endfor%> .PRECIOUS: $(GENERATED_DIRTY) diff --git a/templates/nmake.mpd b/templates/nmake.mpd index d169f64a..b015dc49 100644 --- a/templates/nmake.mpd +++ b/templates/nmake.mpd @@ -248,6 +248,7 @@ InputDir=<%dirname(idl_file)%> <%endfor%> <%foreach(custom_types)%> <%foreach(custom_type->input_files)%> +<%if(custom_type->input_file->output_files)%> SOURCE=<%custom_type->input_file%> <%foreach(platforms)%> @@ -274,6 +275,7 @@ InputDir=<%dirname(custom_type->input_file)%> !ENDIF <%endfor%> +<%endif%> <%endfor%> <%endfor%> <%foreach(resource_files)%> diff --git a/templates/vc6.mpd b/templates/vc6.mpd index 5224e74e..52d51c58 100644 --- a/templates/vc6.mpd +++ b/templates/vc6.mpd @@ -218,6 +218,7 @@ BuildCmds= \ # PROP Default_Filter "<%foreach(custom_type->inputexts)%><%custom_type->inputext%><%fornotlast(";")%><%endfor%>" <%foreach(custom_type->input_files)%> +<%if(custom_type->input_file->output_files)%> # Begin Source File SOURCE=.\<%custom_type->input_file%> @@ -253,6 +254,7 @@ BuildCmds= \ !ENDIF # End Source File +<%endif%> <%endfor%> # End Group <%endfor%> diff --git a/templates/vc6dsp.mpd b/templates/vc6dsp.mpd index 5224e74e..52d51c58 100644 --- a/templates/vc6dsp.mpd +++ b/templates/vc6dsp.mpd @@ -218,6 +218,7 @@ BuildCmds= \ # PROP Default_Filter "<%foreach(custom_type->inputexts)%><%custom_type->inputext%><%fornotlast(";")%><%endfor%>" <%foreach(custom_type->input_files)%> +<%if(custom_type->input_file->output_files)%> # Begin Source File SOURCE=.\<%custom_type->input_file%> @@ -253,6 +254,7 @@ BuildCmds= \ !ENDIF # End Source File +<%endif%> <%endfor%> # End Group <%endfor%> diff --git a/templates/vc7.mpd b/templates/vc7.mpd index 33c75ed0..03228b1a 100644 --- a/templates/vc7.mpd +++ b/templates/vc7.mpd @@ -181,6 +181,7 @@ Name="<%custom_type%>" Filter="<%foreach(custom_type->inputexts)%><%custom_type->inputext%><%fornotlast(";")%><%endfor%>"> <%foreach(custom_type->input_files)%> +<%if(custom_type->input_file->output_files)%> <File RelativePath=".\<%custom_type->input_file%>"> <%foreach(configurations)%> @@ -194,6 +195,7 @@ </FileConfiguration> <%endfor%> </File> +<%endif%> <%endfor%> </Filter> <%endfor%> |