Author: jkeenan Date: Fri Jan 18 04:36:37 2008 New Revision: 24970 Modified: branches/revision/config/gen/makefiles/root.in branches/revision/lib/Parrot/Revision.pm branches/revision/tools/build/revision_c.pl
Log: Parrot::Revision: Add capacity to cache revision number on disk first time it is learned. Add cache file to realclean target. Delete commented-out code in revision_c.pl. Modified: branches/revision/config/gen/makefiles/root.in ============================================================================== --- branches/revision/config/gen/makefiles/root.in (original) +++ branches/revision/config/gen/makefiles/root.in Fri Jan 18 04:36:37 2008 @@ -328,7 +328,8 @@ FLUID_FILES_2 = \ $(GEN_LIBRARY) \ runtime/parrot/include/parrotlib.pbc \ - .configure_trace.sto + .configure_trace.sto \ + .parrot_current_rev ############################################################################### Modified: branches/revision/lib/Parrot/Revision.pm ============================================================================== --- branches/revision/lib/Parrot/Revision.pm (original) +++ branches/revision/lib/Parrot/Revision.pm Fri Jan 18 04:36:37 2008 @@ -23,9 +23,19 @@ use warnings; use File::Spec; +my $cache = q{.parrot_current_rev}; + sub _get_revision { my $revision; + if (-f $cache) { + eval { + open my $FH, "<", $cache; + chomp($revision = <$FH>); + close $FH; + }; + return $revision unless $@; + } # code taken from pugs/util/version_h.pl rev 14410 my $nul = File::Spec->devnull; @@ -56,11 +66,18 @@ } } } - return ( $revision || 0 ); + $revision ||= 0; + unless (-f $cache) { + eval { + open my $FH, ">", $cache; + print $FH "$revision\n"; + close $FH; + }; + } + return $revision; } our $current = _get_revision(); -# our $config = $current; 1; Modified: branches/revision/tools/build/revision_c.pl ============================================================================== --- branches/revision/tools/build/revision_c.pl (original) +++ branches/revision/tools/build/revision_c.pl Fri Jan 18 04:36:37 2008 @@ -27,55 +27,11 @@ print_src_revision_c ); -#my $current = 0; -#my $config = 0; -#if (-e 'DEVELOPING') { -# $current = $Parrot::Revision::current; -# eval 'use Parrot::Config; $config = $PConfig{revision};'; -#} my ($current, $config) = get_revision_numbers(); exit 1 unless ( $current == $config ); print_src_revision_c($current, $config, $0); -#print <<"EOF"; -#/* ex: set ro: -# * !!!!!!! DO NOT EDIT THIS FILE !!!!!!! -# * -# * This file is generated automatically by $0. -# * -# * Any changes made here will be lost! -# * -# */ -# -#/* HEADERIZER HFILE: none */ -#/* HEADERIZER STOP */ -# -##include "parrot/config.h" -# -#/* also in "parrot/embed.h" */ -#PARROT_API int Parrot_revision(void); -#/* also in "parrot/misc.h" */ -#PARROT_API int Parrot_config_revision(void); -# -#int Parrot_revision(void) -#{ -# return $current; -#} -# -#int Parrot_config_revision(void) -#{ -# return $config; -#} -# -#/* -# * Local variables: -# * c-file-style: "parrot" -# * End: -# * vim: expandtab shiftwidth=4: -# */ -#EOF - # Local Variables: # mode: cperl # cperl-indent-level: 4