Alien-cargo
view release on metacpan or search on metacpan
lib/Alien/cargo.pm view on Meta::CPAN
package Alien::cargo;
use strict;
use warnings;
use 5.008004;
use File::Which qw( which );
use Capture::Tiny qw( capture );
use Env qw( @PATH $RUSTUP_HOME );
# ABSTRACT: Find or download the cargo command (build system and package manager for Rust)
our $VERSION = '0.03'; # VERSION
our %config;
if( which 'cargo' ) {
my($text, $stderr) = capture { system 'cargo', 'version' };
if($text =~ /^cargo ([0-9\.]+)/) {
%config = (
version => $1,
install_type => 'system',
bin_dir => [],
);
}
}
unless(%config) {
require Alien::Rust;
$RUSTUP_HOME = Alien::Rust->rustup_home if Alien::Rust->needs_rustup_home;
%config = (
version => Alien::Rust->version,
install_type => Alien::Rust->install_type,
bin_dir => [Alien::Rust->bin_dir],
);
}
# these are for compatability with Alien::Base and not documented
sub new { return bless {}, $_[0] }
sub cflags { '' }
sub libs { '' }
sub dynamic_libs { () }
sub bin_dir { @{ $config{bin_dir } } }
sub version { $config{version} }
sub install_type {
my $self = shift;
my $type = $config{install_type};
return @_ ? $type eq $_[0] : $type;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::cargo - Find or download the cargo command (build system and package manager for Rust)
=head1 VERSION
version 0.03
=head1 SYNOPSIS
use Alien::cargo;
use Env qw( @PATH );
unshift @PATH, Alien::cargo->bind_dir;
=head1 DESCRIPTION
This L<Alien> provides the Rust L<Cargo|https://doc.rust-lang.org/cargo/> command.
( run in 0.400 second using v1.01-cache-2.11-cpan-98d9bbf8dc8 )