[Box Backup-dev] COMMIT r692 - in box/chris/general: infrastructure lib/common lib/server
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Wed, 26 Jul 2006 19:10:19 +0000 (GMT)
Author: chris
Date: 2006-07-26 19:10:10 +0000 (Wed, 26 Jul 2006)
New Revision: 692
Modified:
box/chris/general/infrastructure/BoxPlatform.pm.in
box/chris/general/infrastructure/makebuildenv.pl.in
box/chris/general/lib/common/makeexception.pl.in
box/chris/general/lib/server/makeprotocol.pl.in
Log:
* infrastructure/BoxPlatform.pm.in
* infrastructure/makebuildenv.pl.in
* lib/server/makeprotocol.pl.in
* lib/common/makeexception.pl.in
- Don't rewrite auto-generated files unless they have changed, to prevent
unnecessary rebuilds
Modified: box/chris/general/infrastructure/BoxPlatform.pm.in
===================================================================
--- box/chris/general/infrastructure/BoxPlatform.pm.in 2006-07-26 19:09:05 UTC (rev 691)
+++ box/chris/general/infrastructure/BoxPlatform.pm.in 2006-07-26 19:10:10 UTC (rev 692)
@@ -1,7 +1,7 @@
package BoxPlatform;
use Exporter;
@ISA = qw/Exporter/;
-@EXPORT = qw/$build_os $build_cpu $target_os $make_command $bsd_make $platform_define $platform_cpu $gcc_v3 $product_version $product_name $install_into_dir $sub_make_options $platform_compile_line_extra $platform_link_line_extra $platform_lib_files $platform_exe_ext $target_windows/;
+@EXPORT = qw/$build_os $build_cpu $target_os $make_command $bsd_make $platform_define $platform_cpu $gcc_v3 $product_version $product_name $install_into_dir $sub_make_options $platform_compile_line_extra $platform_link_line_extra $platform_lib_files $platform_exe_ext $target_windows update_if_changed/;
BEGIN
{
@@ -110,5 +110,34 @@
return $_[0].'=1';
}
+sub update_if_changed ($)
+{
+ my ($file) = @_;
+ die "$file.new: not found" unless -r "$file.new";
+
+ if (-r $file)
+ {
+ die "$file.new: not found" unless -r "$file.new";
+ if (system("diff -u $file $file.new") == 0)
+ {
+ unlink "$file.new";
+ return;
+ }
+ }
+
+ if (system("cp $file.new $file") != 0)
+ {
+ die "failed to copy $file.new to $file";
+ }
+
+ if (system("diff --brief $file $file.new") != 0)
+ {
+ die "$file and $file.new are still different";
+ }
+
+ unlink "$file.new";
+ return;
+}
+
1;
Modified: box/chris/general/infrastructure/makebuildenv.pl.in
===================================================================
--- box/chris/general/infrastructure/makebuildenv.pl.in 2006-07-26 19:09:05 UTC (rev 691)
+++ box/chris/general/infrastructure/makebuildenv.pl.in 2006-07-26 19:10:10 UTC (rev 692)
@@ -114,7 +114,7 @@
print "done\n\n";
-# open test mail program template file
+# open test main program template file
my $test_template_file = 'infrastructure/buildenv-testmain-template.cpp';
open FL,$test_template_file or die "Can't open test template file\n";
my $test_template;
@@ -296,7 +296,8 @@
}
# write a list of all the modules we've configured to use
-open CONFIGURED_MODS,'>local/modules.h' or die "Can't write configured modules list";
+open CONFIGURED_MODS,'>local/modules.h.new' or die
+ "Can't write configured modules list";
print CONFIGURED_MODS <<__E;
// automatically generated file, do not edit
#ifndef _CONFIGURED_MODULES__H
@@ -312,8 +313,8 @@
#endif // _CONFIGURED_MODULES__H
__E
close CONFIGURED_MODS;
+update_if_changed("local/modules.h");
-
# now make a list of all the .h files we can find, recording which module they're in
my %hfiles;
for my $mod (@modules, @implicit_deps)
@@ -393,15 +394,19 @@
{
my $testmain = $test_template;
$testmain =~ s/TEST_NAME/$name/g;
- open TESTMAIN,">$mod/_main.cpp" or die "Can't open test main file for $mod for writing\n";
+ open TESTMAIN,">$mod/_main.cpp.new" or die
+ "Can't open test main file for $mod for writing\n";
print TESTMAIN $testmain;
close TESTMAIN;
+ update_if_changed("$mod/_main.cpp");
# test file...
sub writetestfile
{
my ($filename,$runcmd,$module) = @_;
- open TESTFILE,">$filename" or die "Can't open test script file for $module for writing\n";
+ open TESTFILE,">$filename.new" or die
+ "Can't open test script file for $module " .
+ "for writing\n";
print TESTFILE "#!/bin/sh\necho TEST: $module\n";
if(-d "$module/testfiles")
{
@@ -420,6 +425,7 @@
}
print TESTFILE "$runcmd\n";
close TESTFILE;
+ update_if_changed($filename);
}
writetestfile("$mod/_t",
@@ -487,7 +493,8 @@
# start the makefile
my $mk_name_extra = ($bsd_make)?'':'X';
- open MAKE,">$mod/Makefile".$mk_name_extra or die "Can't open Makefile for $mod\n";
+ open MAKE,">$mod/Makefile".$mk_name_extra.".new" or die
+ "Can't open Makefile for $mod\n";
my $debug_link_extra = ($target_is_library)?'':'../../debug/lib/debug/debug.a';
my $release_flags = "-O2";
@@ -785,8 +792,8 @@
if(!$bsd_make)
{
# need to post process this into a GNU makefile
- open MAKE,">$mod/Makefile";
- open MAKEB,"$mod/MakefileX";
+ open MAKE,">$mod/Makefile.new" or die $!;
+ open MAKEB,"$mod/MakefileX.new" or die $!;
while(<MAKEB>)
{
@@ -798,8 +805,10 @@
close MAKEB;
close MAKE;
- unlink "$mod/MakefileX";
+ unlink "$mod/MakefileX.new";
}
+
+ update_if_changed("$mod/Makefile");
}
print "\nType 'cd <module_dir>; $make_command' to build a module\n\n";
Modified: box/chris/general/lib/common/makeexception.pl.in
===================================================================
--- box/chris/general/lib/common/makeexception.pl.in 2006-07-26 19:09:05 UTC (rev 691)
+++ box/chris/general/lib/common/makeexception.pl.in 2006-07-26 19:10:10 UTC (rev 692)
@@ -1,9 +1,11 @@
#!@PERL@
+use lib "../../infrastructure";
+use BoxPlatform;
+
# global exception list file
my $global_list = '../../ExceptionCodes.txt';
-
my @exception;
my @exception_desc;
my $class;
@@ -46,8 +48,8 @@
# write the code
print "Generating $class exception...\n";
-open CPP,">autogen_${class}Exception.cpp" or die "Can't open cpp file for writing";
-open H,">autogen_${class}Exception.h" or die "Can't open h file for writing";
+open CPP,">autogen_${class}Exception.cpp.new" or die "Can't open cpp file for writing";
+open H,">autogen_${class}Exception.h.new" or die "Can't open h file for writing";
# write header file
my $guardname = uc 'AUTOGEN_'.$class.'EXCEPTION_H';
@@ -200,6 +202,9 @@
close H;
close CPP;
+update_if_changed("autogen_${class}Exception.cpp");
+update_if_changed("autogen_${class}Exception.h");
+
# update the global exception list
my $list_before;
my $list_after;
Modified: box/chris/general/lib/server/makeprotocol.pl.in
===================================================================
--- box/chris/general/lib/server/makeprotocol.pl.in 2006-07-26 19:09:05 UTC (rev 691)
+++ box/chris/general/lib/server/makeprotocol.pl.in 2006-07-26 19:10:10 UTC (rev 692)
@@ -170,8 +170,8 @@
# open files
my $h_filename = 'autogen_'.$protocol_name.'Protocol'.$type.'.h';
-open CPP,'>autogen_'.$protocol_name.'Protocol'.$type.'.cpp';
-open H,">$h_filename";
+open CPP,'>autogen_'.$protocol_name.'Protocol'.$type.'.cpp.new';
+open H,">$h_filename.new";
print CPP <<__E;
@@ -915,6 +915,8 @@
close H;
close CPP;
+update_if_changed('autogen_'.$protocol_name.'Protocol'.$type.'.cpp');
+update_if_changed($h_filename);
sub obj_is_type
{