Author: jrieks
Date: Tue Apr 12 10:17:23 2005
New Revision: 7815
Added:
trunk/build_tools/revision_c.pl
trunk/config/gen/revision.pl
trunk/lib/Parrot/Revision.pm
Modified:
trunk/MANIFEST
Log:
added PARROT_REVISION
(added files)
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST (original)
+++ trunk/MANIFEST Tue Apr 12 10:17:23 2005
@@ -37,6 +37,7 @@
build_tools/ops2pm.pl [devel]
build_tools/parrot_config_c.pl []
build_tools/pbc2c.pl [devel]
+build_tools/revision.pl [devel]
build_tools/vtable_h.pl []
charset/ascii.c []
charset/ascii.h []
@@ -268,6 +269,7 @@
config/gen/platform/win32/stat.h []
config/gen/platform/win32/stat.c []
config/gen/platform/win32/time.c []
+config/gen/revision.c []
config/init/data.pl []
config/init/headers.pl []
config/init/hints.pl []
@@ -1457,6 +1459,7 @@
lib/Parrot/PakFile2.xs [devel]
lib/Parrot/Pmc2c.pm [devel]
lib/Parrot/Pmc2c/Library.pm [devel]
+lib/Parrot/Revision.pm [devel]
lib/Parrot/String.pm [devel]
lib/Parrot/Test.pm [devel]
lib/Parrot/Test/PGE.pm [devel]
Added: trunk/build_tools/revision_c.pl
==============================================================================
--- (empty file)
+++ trunk/build_tools/revision_c.pl Tue Apr 12 10:17:23 2005
@@ -0,0 +1,49 @@
+# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
+# $Id: revision_c.pl 7804 2005-04-11 14:12:16Z jrieks $
+
+=head1 NAME
+
+build_tools/revision_c.pl
+
+=head1 DESCRIPTION
+
+creates F<src/revision.c>
+
+=cut
+
+use strict;
+use Parrot::Revision;
+
+print <<"EOF";
+/*
+ * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
+ *
+ * This file is generated automatically by $0.
+ *
+ * Any changes made here will be lost!
+ *
+ */
+
+#include "parrot/config.h"
+
+/* also in "parrot/embed.h" */
+int Parrot_revision(void);
+/* also in "parrot/misc.h" */
+int Parrot_config_revision(void);
+
+#if PARROT_REVISION != ${Parrot::Revision::config}
+#error revision PARROT_REVISION != configure revision
${Parrot::Revision::config}
+#endif
+
+
+int Parrot_revision(void)
+{
+ return ${Parrot::Revision::current};
+}
+
+int Parrot_config_revision(void)
+{
+ return ${Parrot::Revision::config};
+}
+
+EOF
Added: trunk/config/gen/revision.pl
==============================================================================
--- (empty file)
+++ trunk/config/gen/revision.pl Tue Apr 12 10:17:23 2005
@@ -0,0 +1,31 @@
+# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
+# $Id: revision.pl 7804 2005-04-11 14:12:16Z jrieks $
+
+=head1 NAME
+
+config/gen/revision.pl - Parrot's configure revision
+
+=head1 DESCRIPTION
+
+Determines parrot's revision.
+
+=cut
+
+package Configure::Step;
+
+use strict;
+use vars qw($description);
+use Parrot::Revision;
+
+$description="Determining Parrot's revision";
+
+sub runstep {
+ my $revision = $Parrot::Revision::current;
+
+ Configure::Data->set(
+ revision => $revision,
+ );
+ $Configure::Step::result = "r$revision";
+}
+
+1;
Added: trunk/lib/Parrot/Revision.pm
==============================================================================
--- (empty file)
+++ trunk/lib/Parrot/Revision.pm Tue Apr 12 10:17:23 2005
@@ -0,0 +1,44 @@
+# Copyright: 2004-2005 The Perl Foundation. All Rights Reserved.
+# $Id: Pmc2c.pm 7792 2005-04-08 10:17:16Z leo $
+
+=head1 NAME
+
+Parrot::Pmc2c - PMC to C Code Generation
+
+=head1 SYNOPSIS
+
+ use Parrot::Revision;
+
+ print $Parrot::Revision::current;
+ print $Parrot::Revision::config;
+
+=head1 DESCRIPTION
+
+Get parrot's current and configure time revision.
+
+=cut
+
+package Parrot::Revision;
+use strict;
+
+sub __get_revision {
+ # code taken from pugs/util/version_h.pl rev 859
+ my $svn_entries = ".svn/entries";
+
+ if (-r $svn_entries) {
+ open FH, $svn_entries or die $!;
+ while (<FH>) {
+ /^ *committed-rev=.(\d+)./ or next;
+ return $1;
+ }
+ }
+ return 0;
+}
+
+our $current = __get_revision();
+our $config = $current;
+
+# check if Parrot::Config is available
+eval 'use Parrot::Config; $config = $PConfig{revision};';
+
+1;