Author: jkeenan
Date: Thu Jan 17 16:33:00 2008
New Revision: 24957

Added:
   branches/revision/lib/Parrot/Revision/Utils.pm   (contents, props changed)
Modified:
   branches/revision/MANIFEST
   branches/revision/tools/build/revision_c.pl

Log:
Extract code from tools/build/revision_c.pl, place it in subroutines, move 
those subroutines to Parrot::Revision::Utils, import them back into the build 
tool and prepare to test them.

Modified: branches/revision/MANIFEST
==============================================================================
--- branches/revision/MANIFEST  (original)
+++ branches/revision/MANIFEST  Thu Jan 17 16:33:00 2008
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Wed Jan 16 03:33:54 2008 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Fri Jan 18 00:32:01 2008 UT
 #
 # See tools/dev/install_files.pl for documentation on the
 # format of this file.
@@ -2556,6 +2556,7 @@
 lib/Parrot/Pmc2c/UtilFunctions.pm                           [devel]
 lib/Parrot/Pmc2c/VTable.pm                                  [devel]
 lib/Parrot/Revision.pm                                      [devel]
+lib/Parrot/Revision/Utils.pm                                [devel]
 lib/Parrot/Test.pm                                          [devel]
 lib/Parrot/Test/APL.pm                                      [devel]
 lib/Parrot/Test/Cardinal.pm                                 [devel]

Added: branches/revision/lib/Parrot/Revision/Utils.pm
==============================================================================
--- (empty file)
+++ branches/revision/lib/Parrot/Revision/Utils.pm      Thu Jan 17 16:33:00 2008
@@ -0,0 +1,197 @@
+# Copyright (C) 2001-2006, The Perl Foundation.
+# $Id$
+package Parrot::Revision::Utils;
+use strict;
+use warnings;
+use lib qw( lib );
+use Parrot::Revision;
+use base qw( Exporter );
+our @EXPORT_OK = qw( 
+    get_revision_numbers
+    print_src_revision_c
+);
+
+sub get_revision_numbers {
+    my $current = 0;
+    my $config = 0;
+    if (-e 'DEVELOPING') {
+        $current = $Parrot::Revision::current;
+        eval 'use Parrot::Config; $config = $PConfig{revision};';
+    }
+    return ($current, $config);
+}
+
+sub print_src_revision_c {
+    my ($current, $config, $script) = @_;
+    print <<"EOF";
+/* ex: set ro:
+ * !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!!
+ *
+ * This file is generated automatically by $script.
+ *
+ * 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
+    return 1;
+}
+
+1;
+
+#################### DOCUMENTATION ####################
+
+=head1 NAME
+
+Parrot::Revision::Utils - Subroutines used in
+F<tools/build/revision_c.pl>.
+
+=head1 SYNOPSIS
+
+    use Parrot::Revision::Utils qw( 
+        get_revision_numbers
+        print_src_revision_c
+    );
+
+    ($current, $config) = get_revision_numbers();
+
+    print_src_revision_c($current, $config, $script);
+
+=head1 DESCRIPTION
+
+Parrot::Revision::Utils exports on demand two subroutines,
+C<get_revision_numbers()> and C<print_src_revision_c()> which are used
+in F<tools/build/revision_c.pl>, a Perl 5 program invoked by Parrot's
+F<make> program to generate file F<src/revision.c>.  That file, in turn,
+provides C function C<Parrot_revision()>.
+
+=head1 SUBROUTINES
+
+=head2 C<get_revision_numbers()>
+
+    ($current, $config) = get_revision_numbers();
+
+=over 4
+
+=item * Purpose
+
+Provide two Parrot repository revision numbers:  the first being the
+revision number the last time the user made a commit or an update; the
+second being the revision number at which the user last ran
+F<Configure.pl>.
+
+=item * Arguments
+
+None.
+
+=item * Return Values
+
+Two-argument list:
+
+=over 4
+
+=item 1 C<current>
+
+The Parrot repository revision number at which the user last made a
+commit or an update.
+
+=item 2 C<config>
+
+The Parrot repository revision number prevailing when the user last ran
+F<Configure.pl>.
+
+=back
+
+=item * Comment
+
+If the user follows this sequence:
+
+    svn update
+    perl Configure.pl
+    make
+
+... then, the values for C<current> and C<config> at the point at which
+F<make> invokes F<tools/build/revision_c.pl> will be identical.
+
+If, however, the user follows a sequence like this:
+
+    svn update
+    perl Configure.pl
+    # some time passes and the repository revision number increases
+    svn update
+    make
+
+... then, the values for C<current> and C<config> at the point at which
+F<make> invokes F<tools/build/revision_c.pl> will differ.
+
+=back
+
+=head2 C<print_src_revision_c()>
+
+    print_src_revision_c($current, $config, $0);
+
+=over 4
+
+=item * Purpose
+
+Prints the text for F<src/revision.c>.
+
+=item * Arguments
+
+Three-argument list:  C<current> and C<config> as returned by
+C<get_revision_numbers()> (above) and the name of the current script
+(typically supplied by C<$0>).
+
+=item * Return Values
+
+True value.
+
+=item * Comment
+
+Output goes to C<STDOUT>.  F<make> redirects this to F<src/revision.c>.
+
+=back
+
+=head1 NOTES
+
+The functionality in this package was transferred from
+F<tools/build/revision_c.pl> by James E Keenan.
+
+=head1 SEE ALSO
+
+F<lib/Parrot/Revision.pm>, F<tools/build/revision_c.pl>.
+
+=cut
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:

Modified: branches/revision/tools/build/revision_c.pl
==============================================================================
--- branches/revision/tools/build/revision_c.pl (original)
+++ branches/revision/tools/build/revision_c.pl Thu Jan 17 16:33:00 2008
@@ -22,54 +22,59 @@
 use warnings;
 use strict;
 use lib qw{lib . ../lib ../../ lib};
-use Parrot::Revision;
-use Parrot::Config;
-
-my $current = 0;
-my $config = 0;
-if (-e 'DEVELOPING') {
-    $current = ${Parrot::Revision::current};
-    eval 'use Parrot::Config; $config = $PConfig{revision};';
-}
+use Parrot::Revision::Utils qw(
+    get_revision_numbers
+    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 <<"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;
-}
+print_src_revision_c($current, $config, $0);
 
-/*
- * Local variables:
- *   c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */
-EOF
+#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

Reply via email to