Thursday, September 22, 2011

release_update_version

diff --git a/MANIFEST b/MANIFEST
index 8f85f91..2b3b835 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -929,6 +929,7 @@ include/parrot/pobj.h [main]include
include/parrot/pointer_array.h [main]include
include/parrot/runcore_api.h [main]include
include/parrot/runcore_profiling.h [main]include
+include/parrot/runcore_subprof.h [main]include
include/parrot/runcore_trace.h [main]include
include/parrot/scheduler.h [main]include
include/parrot/scheduler_private.h [main]include
@@ -1018,6 +1019,7 @@ lib/Parrot/Pmc2c/Parser.pm [devel]lib
lib/Parrot/Pmc2c/Pmc2cMain.pm [devel]lib
lib/Parrot/Pmc2c/UtilFunctions.pm [devel]lib
lib/Parrot/Pmc2c/VTable.pm [devel]lib
+lib/Parrot/Release/Functions.pm [devel]lib
lib/Parrot/Revision.pm [devel]lib
lib/Parrot/SHA1.pm [devel]lib
lib/Parrot/SearchOps.pm [devel]lib
@@ -1422,6 +1424,7 @@ src/pointer_array.c []
src/runcore/cores.c []
src/runcore/main.c []
src/runcore/profiling.c []
+src/runcore/subprof.c []
src/runcore/trace.c []
src/scheduler.c []
src/spf_render.c []
@@ -2195,7 +2198,6 @@ tools/release/release.json []
tools/release/releasecheck.pl []
tools/release/sha256sum.pl []
tools/release/templates.json []
-tools/release/update_version.pl []
# Local variables:
# mode: text
# buffer-read-only: t
diff --git a/lib/Parrot/Release/Functions.pm b/lib/Parrot/Release/Functions.pm
new file mode 100644
index 0000000..825b376
--- /dev/null
+++ b/lib/Parrot/Release/Functions.pm
@@ -0,0 +1,222 @@
+package Parrot::Release::Functions;
+# Copyright (C) 2011, Parrot Foundation.
+use strict;
+use warnings;
+use Carp;
+use autodie;
+use base qw( Exporter );
+our @EXPORT_OK = qw(
+ get_old_and_new_versions
+ get_simple_files
+ bump_gen_code_version
+ get_generated_files
+ simple_update_version
+);
+
+#################### DOCUMENTATION ####################
+
+=head1 NAME
+
+Parrot::Release::Functions - Functions used during the Parrot release process
+
+=head1 SYNOPSIS
+
+ use Parrot::Release::Functions qw(
+ bump_gen_code_version
+ );
+
+=head1 DESCRIPTION
+
+This package exports, on demand only, non-object-oriented subroutines used
+during the release process.
+
+=head1 SUBROUTINES
+
+=cut
+
+=head2 C<get_old_and_new_versions()>
+
+=over 4
+
+=item * Purpose
+
+Get the current version number from F<VERSION> and validate the format of the
+new version number.
+
+=item * Arguments
+
+ ($old_version, $new_version) =
+ get_old_and_new_versions('new.version.number');
+
+=item * Return Value
+
+Implicitly returns true value upon success.
+
+=back
+
+=cut
+
+sub get_old_and_new_versions {
+ croak "get_old_and_new_versions(): Must supply a single argument: new version number"
+ unless @_ == 1;
+ croak "Cannot locate VERSION file" unless (-f 'VERSION');
+
+ my $new_version = shift(@_);
+ open my $version_fh, '<', 'VERSION';
+ my $old_version = <$version_fh>;
+ chomp $old_version;
+ close $version_fh;
+
+ croak "'$new_version' is not a proper version number; must be n.n.n"
+ unless $new_version =~ m/^\d+\.\d+\.\d+$/;
+ return ( $old_version, $new_version );
+}
+
+=head2 C<get_simple_files()>
+
+=over 4
+
+=item * Purpose
+
+Get a list of source code files in which the version number must be
+incremented.
+
+=item * Arguments
+
+None.
+
+=item * Purpose
+
+Returns a list of source code files in which the version number must be
+incremented.
+
+=back
+
+=cut
+
+sub get_simple_files {
+ return (
+ 'VERSION',
+ 'MANIFEST.generated',
+ 'README',
+ );
+}
+
+=head2 C<simple_update_version()>
+
+=over 4
+
+=item * Purpose
+
+Increments the version number within a given file.
+
+=item * Arguments
+
+ simple_update_version($filename, $old_version, $new_version);
+
+=item * Return Value
+
+Implicitly returns true value upon success.
+
+=back
+
+=cut
+
+sub simple_update_version {
+ my ($f, $old_version, $new_version) = @_;
+ my $new = "$f.tmp";
+ open my $IN, '<', $f or croak "Unable to open $f for reading";
+ open my $OUT, '>', $new or croak "Unable to open $new for writing";
+ while (<$IN>) {
+ chomp;
+ s/$old_version/$new_version/g;
+ print $OUT "$_\n";
+ }
+ close $OUT or croak "Unable to close $new after writing";
+ close $IN or croak "Unable to close $f after reading";
+ rename $new => $f or croak "Unable to rename $new to $f";
+}
+
+=head2 C<get_generated_files()>
+
+=over 4
+
+=item * Purpose
+
+Get a list of files generated during configuration or build in which the
+version number must be incremented.
+
+=item * Arguments
+
+None.
+
+=item * Purpose
+
+Returns a list of files generated during configuration or build in which the
+version number must be incremented.
+
+=back
+
+=cut
+
+sub get_generated_files {
+ return (
+ 'include/parrot/oplib/core_ops.h',
+ 'src/ops/core_ops.c',
+ );
+}
+
+=head2 C<bump_gen_code_version()>
+
+=over 4
+
+=item * Purpose
+
+Increments the version number within a given file. This function is used for
+files generated during configuration or build.
+
+=item * Arguments
+
+ bump_gen_code_version($filename, $old_version, $new_version);
+
+=item * Return Value
+
+Implicitly returns true value upon success.
+
+=back
+
+=cut
+
+sub bump_gen_code_version {
+
+ my ($filename, $old_version, $new_version) = @_;
+ my $old_h_version = join("_", split(/\./, $old_version));
+ my @new_version = split(/\./, $new_version);
+ my $new_h_version = join("_", @new_version);
+
+ open my $gen_c_in, '<', "$filename";
+ open my $gen_c_out, '>', "$filename.tmp";
+ while(<$gen_c_in>) {
+ s/$old_h_version/$new_h_version/g;
+ s?\d+, /\* major_version \*/?$new_version[0], /* major_version */?;
+ s?\d+, /\* minor_version \*/?$new_version[1], /* minor_version */?;
+ s?\d+, /\* patch_version \*/?$new_version[2], /* patch_version */?;
+ print $gen_c_out $_;
+ }
+ close $gen_c_in;
+ close $gen_c_out;
+ rename "$filename.tmp", $filename;
+}
+
+1;
+
+=head1 SEE ALSO
+
+=cut
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
diff --git a/tools/release/auto_release.pl b/tools/release/auto_release.pl
index b08b82c..1d03adc 100644
--- a/tools/release/auto_release.pl
+++ b/tools/release/auto_release.pl
@@ -1,5 +1,4 @@
#! perl
-
# Copyright (C) 2011, Parrot Foundation.

=head1 NAME
@@ -55,9 +54,16 @@ use warnings;

use Getopt::Long;
use System::Command;
+use lib qw ( ./lib );
+use Parrot::Release::Functions qw(
+ get_old_and_new_versions
+ get_simple_files
+ bump_gen_code_version
+ get_generated_files
+ simple_update_version
+);

# TODO Be more verbose in perldoc
-# TODO Migrate code from update_version.pl
# TODO Edit '== ==' strings so that newlines are on top and bottom

my $version; # Version number
@@ -412,7 +418,14 @@ sub update_version {

print "== UPDATING VERSION INFORMATION ==\n";

- system('perl', 'tools/release/update_version.pl', "$ver") == 0 or stop();
+ my ($old_version, $new_version) = get_old_and_new_versions($ver);
+ foreach my $f ( get_simple_files() ) {
+ simple_update_version( $f, $old_version, $new_version );
+ }
+ foreach my $f ( get_generated_files() ) {
+ bump_gen_code_version(
+ $f, $old_version, $new_version);
+ }

_edit('docs/parrothist.pod');
_edit('docs/project/release_manager_guide.pod');
diff --git a/tools/release/update_version.pl b/tools/release/update_version.pl
deleted file mode 100644
index 4398fd1..0000000
--- a/tools/release/update_version.pl
+++ /dev/null
@@ -1,111 +0,0 @@
-#! perl
-# Copyright (C) 2011, Parrot Foundation.
-use strict;
-use warnings;
-use Carp;
-use autodie;
-
-=head1 NAME
-
-tools/release/update_version.pl - Update version numbers in a few files
-
-=head1 SYNOPSIS
-
- perl tools/release/update_version.pl <new_version>
-
-=head1 DESCRIPTION
-
-This program is meant to be used by the Parrot release manager. It will
-change the version numbers found in B<these 5 files only>:
-
- VERSION
- MANIFEST.generated
- README
- include/parrot/oplib/core_ops.h
- src/ops/core_ops.c
-
-During the release process, the Parrot version number must be updated in
-several files, but this program only operates on the three files above. You
-will have to revise the other files manually.
-
-The version numbers must be of the form C<n.n.n.> where C<n> is one or more
-digits. Supply the old version first. No error-checking is performed to
-ensure, I<e.g.,> that the newer number properly increments the older.
-
-The programm concludes by calling out C<git diff> so that you may review the
-changes.
-
-=head1 AUTHOR
-
-James E Keenan
-
-=cut
-
-croak "Must supply a version number as a command-line argument"
- unless @ARGV == 1;
-
-my $new_version = $ARGV[0];
-open my $version_fh, '<', 'VERSION';
-my $old_version = <$version_fh>;
-chomp $old_version;
-close $version_fh;
-
-croak "'$new_version' is not a proper version number; must be n.n.n"
- unless $new_version =~ m/^\d+\.\d+\.\d+$/;
-
-my @simple_files = (
- 'VERSION',
- 'MANIFEST.generated',
- 'README',
-);
-
-foreach my $f ( @simple_files ) {
- my $new = "$f.tmp";
- open my $IN, '<', $f or croak "Unable to open $f for reading";
- open my $OUT, '>', $new or croak "Unable to open $new for writing";
- while (<$IN>) {
- chomp;
- s/$old_version/$new_version/g;
- print $OUT "$_\n";
- }
- close $OUT or croak "Unable to close $new after writing";
- close $IN or croak "Unable to close $f after reading";
- rename $new => $f or croak "Unable to rename $new to $f";
-}
-
-
-my $filename = "include/parrot/oplib/core_ops.h";
-bump_gen_code_version($filename, $old_version, $new_version);
-$filename = "src/ops/core_ops.c";
-bump_gen_code_version($filename, $old_version, $new_version);
-
-
-
-sub bump_gen_code_version {
-
- my ($filename, $old_version, $new_version) = @_;
- my $old_h_version = join("_", split(/\./, $old_version));
- my @new_version = split(/\./, $new_version);
- my $new_h_version = join("_", @new_version);
-
- open my $gen_c_in, '<', "$filename";
- open my $gen_c_out, '>', "$filename.tmp";
- while(<$gen_c_in>) {
- s/$old_h_version/$new_h_version/g;
- s?\d+, /\* major_version \*/?$new_version[0], /* major_version */?;
- s?\d+, /\* minor_version \*/?$new_version[1], /* minor_version */?;
- s?\d+, /\* patch_version \*/?$new_version[2], /* patch_version */?;
- print $gen_c_out $_;
- }
- close $gen_c_in;
- close $gen_c_out;
- rename "$filename.tmp", $filename;
-}
-
-
-# Local Variables:
-# mode: cperl
-# cperl-indent-level: 4
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4:
In soh_cah_toa's new tools/release/auto_release.pl, I observed this comment:

# TODO Migrate code from update_version.pl

This should mostly be accomplished in the kid51/release_update_version
branch. diff attached. However, I have not written unit tests for the
functions or attempted an end-to-end run of tools/release/auto_release.pl.

Thank you very much.
Jim Keenan

No comments:

Post a Comment