summaryrefslogtreecommitdiff
path: root/util/doc-install.pl
diff options
context:
space:
mode:
authorDaniel Elstner <daniel.kitta@gmail.com>2009-08-09 16:18:48 +0200
committerDaniel Elstner <daniel.kitta@gmail.com>2009-08-09 16:57:55 +0200
commite0376dfa81b6f9fc13112e0a948664c86e459b71 (patch)
tree7b6575fb2fb17f6773598426fe51817801030cc4 /util/doc-install.pl
parent18f602f49ddc14f3e4452dedd62b69c5d958881d (diff)
downloadmm-common-e0376dfa81b6f9fc13112e0a948664c86e459b71.tar.gz
Implement filename globbing within doc-install.pl
* util/doc-install.pl: Add a new --glob flag, which tells the script to interpret the source arguments as glob patterns instead of literal filenames. Performing the filename glob expansion internally avoids excessively long argument lists, which can unfortunately be a problem with some platforms. Also, remember the basename of every installed file, and use that information to skip over files whose basename has already been seen. * util/doc-postprocess.pl: Also perform globbing internally to avoid excessively long command lines. * build/doc-reference.am (MMDOCTOOLDIR): Use this separate variable instead of GMMPROC_DIR for the default location of the documentation utility scripts. (doc_postprocess), (doc_install), (tagfile_to_devhelp2): Derive default values from $(MMDOCTOOLDIR). Include the interpreter command $(PERL) as part of the variable value, just in case someone needs to override the Perl interpreter as well. (install-data-local): Use the new --glob feature of doc-install.pl instead of having make expand the entire list of filenames into the shell command-line. (uninstall-local): Do not rely on globbing at the shell level for producing the list of files to delete, since it would probably exceed the command line length limits of some platforms. Do not go back to rm -rf either, but use a combination of 'find' and 'rm -f' to restrict the deletion to those files that match the same glob pattern as the one used to select the files to install.
Diffstat (limited to 'util/doc-install.pl')
-rw-r--r--util/doc-install.pl26
1 files changed, 20 insertions, 6 deletions
diff --git a/util/doc-install.pl b/util/doc-install.pl
index 3bca5f7..19515ad 100644
--- a/util/doc-install.pl
+++ b/util/doc-install.pl
@@ -1,6 +1,6 @@
package main;
-# Copyright (c) 2009 Daniel Elstner <daniel.kitta@gmail.com>
+# Copyright (c) 2009 Openismus GmbH <http://www.openismus.com/>
#
# This file is part of mm-common.
#
@@ -30,7 +30,8 @@ my $book_base;
my $perm_mode;
my $target_dir;
my $target_nodir = '';
-my $verbose = '';
+my $expand_glob = '';
+my $verbose = '';
sub path_basename ($)
{
@@ -54,11 +55,12 @@ while setting permission modes. For HTML files, translate references to
external documentation.
Mandatory arguments to long options are mandatory for short options, too.
- -k, --book-base=BASEPATH use reference BASEPATH for Devhelp book
+ --book-base=BASEPATH use reference BASEPATH for Devhelp book
-l, --tag-base=TAGFILE\@BASEPATH use BASEPATH for references from TAGFILE
-m, --mode=MODE override file permission MODE (octal)
-t, --target-directory=DIRECTORY copy all SOURCE arguments into DIRECTORY
-T, --no-target-directory treat DEST as normal file
+ --glob expand SOURCE as filename glob pattern
-v, --verbose enable informational messages
-?, --help display this help and exit
EOF
@@ -156,11 +158,12 @@ $message_prefix = ($message_prefix || 'doc-install') . ': ';
my @tags = ();
my $mode = '0644';
- GetOptions('book-base|k=s' => \$book_base,
+ GetOptions('book-base=s' => \$book_base,
'tag-base|l=s' => \@tags,
'mode|m=s' => \$mode,
'target-directory|t=s' => \$target_dir,
'no-target-directory|T' => \$target_nodir,
+ 'glob' => \$expand_glob,
'verbose|v' => \$verbose,
'help|?' => \&exit_help)
or exit 2;
@@ -176,6 +179,7 @@ if ($target_nodir)
{
error('Conflicting target directory options') if (defined $target_dir);
error('Source and destination filenames expected') unless ($#ARGV == 1);
+ error('Filename globbing requires target directory') if ($expand_glob);
install_file($ARGV[0], $ARGV[1], path_basename($ARGV[1]));
exit;
@@ -183,7 +187,7 @@ if ($target_nodir)
unless (defined $target_dir)
{
- if ($#ARGV == 1)
+ if (!$expand_glob and $#ARGV == 1)
{
my $basename = path_basename($ARGV[1]);
@@ -197,11 +201,21 @@ unless (defined $target_dir)
}
error('No target directory specified') unless (defined($target_dir) and $target_dir ne '');
+@ARGV = map(glob, @ARGV) if ($expand_glob);
+my %basename_hash = ();
+
foreach my $in_name (@ARGV)
{
my $basename = path_basename($in_name);
my $out_name = File::Spec->catfile($target_dir, $basename);
- install_file($in_name, $out_name, $basename);
+ # If there are multiple files with the same base name in the list, only
+ # the first one will be installed. This behavior makes it very easy to
+ # implement a VPATH search for each individual file.
+ unless (exists $basename_hash{$basename})
+ {
+ $basename_hash{$basename} = undef;
+ install_file($in_name, $out_name, $basename);
+ }
}
exit;