Alien-ROOT

 view release on metacpan or  search on metacpan

lib/Alien/ROOT.pm  view on Meta::CPAN

use strict;
use warnings;
use Carp ();

=head1 NAME

Alien::ROOT - Utility package to install and locate CERN's ROOT library

=cut

our $VERSION = '5.34.36.1';
$VERSION = eval $VERSION;

=head1 SYNOPSIS

  use Alien::ROOT;

  my $aroot = Alien::ROOT->new;

=head1 DESCRIPTION

Installs or detects CERN's ROOT library.

This version of C<Alien::ROOT> will download and install
C<ROOT v5.30.0> B<if necessary>. If an existing (and
compatible) installation of ROOT was detected, the
module will not download/compile/install a new version
of ROOT.

=head1 METHODS

=head2 Alien::ROOT->new

Creates a new C<Alien::ROOT> object, which essentially just has a few
convenience methods providing useful information like the path
to the ROOT installation (C<ROOTSYS> environment variable)
and the path to the F<root-config> utility.

=cut

sub new {
  my $class = shift;

  Carp::croak('You must call this as a class method') if ref($class);

  my $self = {
    installed    => 0,
    root_config  => undef,
    version      => undef,
    cflags       => undef,
    ldflags      => undef,
    features     => undef,
    libdir       => undef,
    bindir       => undef,
    incdir       => undef,
    etcdir       => undef,
    archdir      => undef, # internal
    private_root => undef,
  };

  bless($self, $class);

  $self->_load_modules();
  $self->_configure();

  return $self;
}

sub _load_modules {
  require File::Spec;
  require Config;
  require ExtUtils::MakeMaker;
  require IPC::Open3;
}

=head2 $aroot->installed

Determine if a valid installation of ROOT has been detected in the system.
This method will return a true value if it is, or undef otherwise.

Example code:

  print "okay\n" if $aroot->installed;

=cut

sub installed {
  my $self = shift;

  Carp::croak('You must call this method as an object') unless ref($self);

  return $self->{installed};
}

=head2 $aroot->run

Sets up the ROOT environment (see C<setup_environment>) and then invokes
the ROOT shell by simply calling C<root>.

=cut

sub run {
  my $self = shift;
  $self->setup_environment;
  system {'root'} 'root', @_;
}

=head2 $aroot->setup_environment

Sets up the C<PATH> and C<LD_LIBRARY_PATH> environment
variables to point at the correct paths for ROOT.

Throws an exception if ROOT was not found, so wrap this in an C<eval>
or check C<$aroot-E<gt>installed> before using this.

=cut

sub setup_environment {
  my $self = shift;
  Carp::croak('You must call this method as an object') unless ref($self);
  die "ROOT was not found. Make the 'root-config' utility accessible or set the ROOTSYS variable"



( run in 0.529 second using v1.01-cache-2.11-cpan-97f6503c9c8 )