Alien-gputils
view release on metacpan or search on metacpan
lib/Alien/gputils.pm view on Meta::CPAN
package Alien::gputils;
use strict;
use warnings;
use Env qw(@PATH);
if ($^O =~ /mswin32/i) {
foreach (qw{PROGRAMFILES ProgramFiles PROGRAMFILES(X86)
ProgramFiles(X86) ProgamFileW6432 PROGRAMFILESW6432}) {
next unless exists $ENV{$_};
my $dir = ($ENV{$_} =~ /\s+/) ? Win32::GetShortPathName($ENV{$_}) : $ENV{$_};
push @PATH, File::Spec->catdir($dir, 'gputils', 'bin') if $dir;
}
}
use File::Which qw(which);
use File::Spec;
our $VERSION = '0.08';
$VERSION = eval $VERSION;
use parent 'Alien::Base';
sub _get_gputils {
my $self = shift;
my $type = shift;
my $bd = $self->bin_dir;
if (defined $bd) {
my $ext = ($^O =~ /mswin32/i) ? '.exe' : '';
my $exe = File::Spec->catfile($bd, "$type$ext");
return $exe if (defined $exe and -e $exe);
}
my ($exe2) = which($type);
return $exe2;
}
sub gpasm { return $_[0]->_get_gputils('gpasm'); }
sub gplink { return $_[0]->_get_gputils('gplink'); }
sub gplib { return $_[0]->_get_gputils('gplib'); }
sub gpdasm { return $_[0]->_get_gputils('gpdasm'); }
sub gpstrip { return $_[0]->_get_gputils('gpstrip'); }
sub gpvc { return $_[0]->_get_gputils('gpvc'); }
sub gpvo { return $_[0]->_get_gputils('gpvo'); }
sub bin_dir {
my $self = shift;
if ($self->install_type('system')) {
my ($path) = $self->config('gputils_system_path');
return $path if $path;
}
return $self->SUPER::bin_dir();
}
1;
__END__
#### COPYRIGHT: Vikas N Kumar. Selective Intellect LLC. All Rights Reserved
#### AUTHOR: Vikas N Kumar <vikas@cpan.org>
#### DATE: 18th Nov 2014
#### LICENSE: Refer LICENSE file.
=head1 NAME
Alien::gputils
=head1 SYNOPSIS
Alien::gputils is a perl module that enables the installation of the gputils
toolkit for developing code for Microchip PIC microcontrollers.
The source code is taken from L<http://gputils.sourceforge.net>.
=head1 VERSION
0.07
=head1 METHODS
=over
=item B<gpasm>
This method returns the path to the C<gpasm> binary whether installed by this
module or if already installed in the C<$PATH>.
=item B<gplink>
This method returns the path to the C<gplink> binary whether installed by this
module or if already installed in the C<$PATH>.
=item B<gplib>
This method returns the path to the C<gplib> binary whether installed by this
module or if already installed in the C<$PATH>.
=item B<gpdasm>
This method returns the path to the C<gpdasm> binary whether installed by this
module or if already installed in the C<$PATH>.
=item B<gpstrip>
This method returns the path to the C<gpstrip> binary whether installed by this
module or if already installed in the C<$PATH>.
=item B<gpvc>
This method returns the path to the C<gpvc> binary whether installed by this
module or if already installed in the C<$PATH>.
=item B<gpvo>
( run in 0.710 second using v1.01-cache-2.11-cpan-39bf76dae61 )