| File: | config/auto/ctags.pm |
| Coverage: | 95.7% |
| line | stmt | bran | cond | sub | code |
|---|---|---|---|---|---|
| 1 | # Copyright (C) 2005-2007, Parrot Foundation. | ||||
| 2 | # $Id: ctags.pm 36833 2009-02-17 20:09:26Z allison $ | ||||
| 3 | |||||
| 4 - 16 | =head1 NAME config/auto/ctags - Check whether (exuberant) ctags works =head1 DESCRIPTION Determines whether exuberant ctags exists on the system. It is OK when it doesn't exist. This also checks if the ctags picked up is emacs ctags which we B<don't> want to use. On some systems exuberant ctags is called C<ctags>, on some C<exuberant-ctags> and on others C<ctags-exuberant>. This test tries to work out which one we've got. =cut | ||||
| 17 | |||||
| 18 | package auto::ctags; | ||||
| 19 | |||||
| 20 | 81 81 81 | use strict; | |||
| 21 | 81 81 81 | use warnings; | |||
| 22 | |||||
| 23 | 81 81 81 | use base qw(Parrot::Configure::Step); | |||
| 24 | |||||
| 25 | 81 81 81 | use Parrot::Configure::Utils ':auto'; | |||
| 26 | |||||
| 27 | sub _init { | ||||
| 28 | 84 | my $self = shift; | |||
| 29 | 84 | my %data; | |||
| 30 | 84 | $data{description} = q{Is (exuberant) ctags installed}; | |||
| 31 | 84 | $data{result} = q{}; | |||
| 32 | 84 | return \%data; | |||
| 33 | } | ||||
| 34 | |||||
| 35 | my @ctags_variations = | ||||
| 36 | defined( $ENV{TEST_CTAGS} ) | ||||
| 37 | ? @{ $ENV{TEST_CTAGS} } | ||||
| 38 | : qw( ctags exuberant-ctags ctags-exuberant exctags ); | ||||
| 39 | |||||
| 40 | sub runstep { | ||||
| 41 | 82 | my ( $self, $conf ) = @_; | |||
| 42 | |||||
| 43 | 82 | my $verbose = $conf->options->get( 'verbose' ); | |||
| 44 | 82 | print "\n" if $verbose; | |||
| 45 | |||||
| 46 | 82 | my ($ctags, $has_ctags) = | |||
| 47 | _probe_for_ctags($conf, [ @ctags_variations ], $verbose); | ||||
| 48 | 82 | $self->_evaluate_ctags($conf, $ctags, $has_ctags); | |||
| 49 | 82 | return 1; | |||
| 50 | } | ||||
| 51 | |||||
| 52 | sub _probe_for_ctags { | ||||
| 53 | 82 | my $conf = shift; | |||
| 54 | 82 | my $variations_ref = shift; | |||
| 55 | 82 | my $verbose = shift; | |||
| 56 | 82 | my ($ctags, $has_ctags); | |||
| 57 | 82 | while (defined (my $t = shift(@$variations_ref))) { | |||
| 58 | 82 | my $output = capture_output( $t, '--version' ) || ''; | |||
| 59 | 82 | print $output, "\n" if $verbose; | |||
| 60 | 82 | $has_ctags = _probe_for_ctags_output($output, $verbose); | |||
| 61 | 82 | $ctags = $t if $has_ctags; | |||
| 62 | 82 | last if $has_ctags; | |||
| 63 | } | ||||
| 64 | 82 | return ($ctags, $has_ctags); | |||
| 65 | } | ||||
| 66 | |||||
| 67 | sub _probe_for_ctags_output { | ||||
| 68 | 86 | my ($output, $verbose) = @_; | |||
| 69 | 86 | my $has_ctags = ( $output =~ m/Exuberant Ctags/ ) ? 1 : 0; | |||
| 70 | 86 | print $has_ctags, "\n" if $verbose; | |||
| 71 | 86 | return $has_ctags; | |||
| 72 | } | ||||
| 73 | |||||
| 74 | sub _evaluate_ctags { | ||||
| 75 | 84 | my ($self, $conf, $ctags, $has_ctags) = @_; | |||
| 76 | 84 | if ($has_ctags) { | |||
| 77 | 83 | $conf->data->set( ctags => $ctags ); | |||
| 78 | 83 | $self->set_result( 'yes' ); | |||
| 79 | } | ||||
| 80 | else { | ||||
| 81 | 1 | $conf->data->set( ctags => 'ctags' ); | |||
| 82 | 1 | $self->set_result( 'no' ); | |||
| 83 | } | ||||
| 84 | } | ||||
| 85 | |||||
| 86 | 1; | ||||
| 87 | |||||
| 88 - 92 | =head1 AUTHOR Paul Cochrane <paultcochrane at gmail dot com> =cut | ||||
| 93 | |||||
| 94 | # Local Variables: | ||||
| 95 | # mode: cperl | ||||
| 96 | # cperl-indent-level: 4 | ||||
| 97 | # fill-column: 100 | ||||
| 98 | # End: | ||||
| 99 | # vim: expandtab shiftwidth=4: | ||||