[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 10/14: [grog]: Make program testable in build tree.
From: |
G. Branden Robinson |
Subject: |
[groff] 10/14: [grog]: Make program testable in build tree. |
Date: |
Fri, 4 Jun 2021 16:02:03 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 3b8ca15c91e42cdc3665ea5749b0c1146124d4a6
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Jun 5 05:00:11 2021 +1000
[grog]: Make program testable in build tree.
* src/roff/grog/grog.pl: Refactor initialiation so that the program can
be run from a build tree--and tested. Drop much cruft from before
Bertrand Garrigues's 2018 work to adopt `git-version-gen`.
Our other Perl programs by the same author (chem, gperl, gpinyin)
require similar refactoring.
---
ChangeLog | 7 +++++++
src/roff/grog/grog.pl | 40 +++++++++++++++++-----------------------
2 files changed, 24 insertions(+), 23 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3ca4342..91550a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2021-06-05 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/roff/grog/grog.pl: Refactor initialiation so that the
+ program can be run from a build tree--and tested. Drop much
+ cruft from before Bertrand Garrigues's 2018 work to adopt
+ `git-version-gen`.
+
2021-06-04 G. Branden Robinson <g.branden.robinson@gmail.com>
* tmac/tests/an-old_title-abbreviation-works.sh: Log more
diff --git a/src/roff/grog/grog.pl b/src/roff/grog/grog.pl
index f66fc65..9050735 100644
--- a/src/roff/grog/grog.pl
+++ b/src/roff/grog/grog.pl
@@ -34,6 +34,8 @@ use strict;
# $Bin is the directory where this script is located
use FindBin;
+# We need to portably construct file specifications.
+use File::Spec::Functions 'catfile';
my $before_make; # script before run of 'make'
{
@@ -41,35 +43,27 @@ my $before_make; # script before run of 'make'
$before_make = 1 if '@VERSION@' eq "${at}VERSION${at}";
}
-
our %at_at;
-my $grog_dir;
-
-if ($before_make) { # before installation
- my $grog_source_dir = $FindBin::Bin;
- $at_at{'BINDIR'} = $grog_source_dir;
-# $grog_dir = $grog_source_dir;
- $grog_dir = '.';
- my $top = $grog_source_dir . '/../../../';
- open FILE, '<', $top . 'VERSION' ||
- die 'grog: could not open file "VERSION"';
- my $version = <FILE>;
- chomp $version;
- close FILE;
- open FILE, '<', $top . 'REVISION' ||
- die 'grog: could not open file "REVISION"';
- my $revision = <FILE>;
- chomp $revision;
- $at_at{'GROFF_VERSION'} = $version . '.' . $revision;
-} else { # after installation}
+
+if ($before_make) {
+ $at_at{'GROFF_VERSION'} = "DEVELOPMENT";
+} else {
$at_at{'GROFF_VERSION'} = '@VERSION@';
- $at_at{'BINDIR'} = '@BINDIR@';
- $grog_dir = '@grog_dir@';
-} # before make
+}
+# Locate our subroutines file. We might be installed, in a source tree,
+# or in a separate build tree.
+my $grog_dir = $FindBin::Bin;
die 'grog: "' . $grog_dir . '" does not exist or is not a directory'
unless -d $grog_dir;
+foreach my $dir ( $grog_dir, './src/roff/grog', '../src/roff/grog' ) {
+ my $subs = catfile("$dir", "subs.pl");
+ if ( -f $subs ) {
+ $grog_dir = $dir;
+ last;
+ }
+}
#############
# import subs
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 10/14: [grog]: Make program testable in build tree.,
G. Branden Robinson <=