Alien-Build

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

2.49      2022-06-23 11:19:08 -0500
  - Fix tests to pass on systems that do not have a compiler (gh#309)

2.48      2022-03-13 11:20:19 -0600
  - Added atleast_version to Probe::CommandLine and Probe::CBuilder plugins
    (gh#299, gh#300, shawnlaffan++)
  - Added Alien::Util module (gh#301)

2.47      2022-03-07 07:03:52 -0700
  - Fixed bug where Probe::CBuilder plugin could report the wrong diagnostic
    when throwing an exception (gh#296, gh#297, shawnlaffan++)

2.46      2021-11-30 15:17:58 -0700
  - Fix bug where the Build::Copy plugin could fail when spaces are in
    the target path (gh#290, gh#292 kiwiroy++)

2.45      2021-10-28 04:55:28 -0600
  - On macOS / OS X the Build::Copy plugin now uses cp -pPR instead of
    cp -aR; on modern macOS this does the same thing, on very old versions
    of OS X the -a option is not recognized (gh#288)

Changes  view on Meta::CPAN

0.98_01   2017-08-16 17:50:17 -0400
  - Added Alien::Build::Plugin::Build::CMake (which was briefly in its own distribution).

0.97      2017-08-16 17:36:36 -0400
  - Production release identical to 0.96_01

0.96_01   2017-08-16 11:30:50 -0400
  - Added Alien::Build::Plugin::Build::Make (which was briefly in its own distribution).
  - Removing accidental dependency on Archive::Tar
    (it should be optional, though it is available as part of the Perl core on 5.10+)
  - Fixed bug where Test::Alien xs_ok could throw an exception instead
    of failing gracefully.
  - Test::Alien alien_ok does not crash when undef is passed to it
  - C++ support in Test::Alien xs_ok is deprecated and will be removed on or after
    31 August 2017.  This feature was experimental.  This capability will be developed
    in the separate distribution Test-Alien-CPP
  - remove Test::Alien::CanCompileCpp.  This module will come bundled with
    Test-Alien-CPP instead.

0.95      2017-08-11 09:47:57 -0400
  - Improve extractor logic for zip files

Changes  view on Meta::CPAN

0.14      2017-02-09 02:07:09 -0500
  - Add meta directive to alienfile.
  - Use .pc files from dependant Aliens that used Alien::Build
  - Work around for elder Perls 5.8.7 and earlier

0.12      2017-02-08 15:39:56 -0500
  - Added Probe::GnuWin32 plugin

0.11      2017-02-08 07:56:08 -0500
  - Fixed regression in architecture logic for Alien::Build::MM
  - Fix bug where compile error wouldn't throw exception from
    Alien::Build->load

0.10      2017-02-06 05:24:25 -0500
  - Add heuristic to determine version from filename using
    Prefer::SortVersions plugin
  - Add log method to Alien::Build
  - Fixed bug in probe where first 'share' would be accepted (gh#7)

0.09      2017-02-04 17:31:00 -0500
  - Using an undefined property in command interpolation is now an

README  view on Meta::CPAN

    Path::Tiny

      Containing the path to the file to be checked.

    HASH

      A Hash reference containing information about a file. See the fetch
      hook for details on the format.

    Returns true if the cryptographic signature matches, false if
    cryptographic signatures are disabled. Will throw an exception if the
    signature does not match, or if no plugin provides the correct
    algorithm for checking the signature.

 decode

     my $decoded_res = $build->decode($res);

    Decode the HTML or file listing returned by fetch. Returns the same
    hash structure described below in the decode hook documentation.

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


  return if $class eq __PACKAGE__;

  return if $class->runtime_prop;

  return if $class->install_type('system');

  require DynaLoader;

  # Sanity check in order to ensure that dist_dir can be found.
  # This will throw an exception otherwise.
  $class->dist_dir;

  # get a reference to %Alien::MyLibrary::AlienLoaded
  # which contains names of already loaded libraries
  # this logic may be replaced by investigating the DynaLoader arrays
  my $loaded = do {
    no strict 'refs';
    no warnings 'once';
    \%{ $class . "::AlienLoaded" };
  };

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


=item C<HASH>

A Hash reference containing information about a file.  See
the L<fetch hook|Alien::Build::Manual::PluginAuthor/"fetch hook"> for details
on the format.

=back

Returns true if the cryptographic signature matches, false if cryptographic
signatures are disabled.  Will throw an exception if the signature does not
match, or if no plugin provides the correct algorithm for checking the
signature.

=head2 decode

 my $decoded_res = $build->decode($res);

Decode the HTML or file listing returned by C<fetch>.  Returns the same
hash structure described below in the
L<decode hook|Alien::Build::Manual::PluginAuthor/"decode hook"> documentation.

lib/Alien/Build/Manual/AlienAuthor.pod  view on Meta::CPAN

way to call C<pkg-config> would be from Perl:

 probe sub {
   my($build) = @_;  # $build is the Alien::Build instance.
   system 'pkg-config --exists libfoo';
   $? == 0 ? 'system' : 'share';
 };

The Perl code should return 'system' if the library is installed, and
'share' if not.  (Other directives should return a true value on
success, and a false value on failure).  You can also throw an exception with
C<die> to indicate a failure.

The next part of the L<alienfile> is the C<share> block, which is used
to group the directives which are used to download and install the
library or tool in the event that it is not already installed.

 share {
   start_url 'http://www.libfoo.org/src/libfoo-1.00.tar.gz';
   download [ 'wget %{.meta.start_url}' ];
   extract [ 'tar zxf %{.install.download}' ];

lib/Alien/Build/Manual/AlienAuthor.pod  view on Meta::CPAN

 gather [
   [ 'pkg-config --modversion libfoo', \'%{.runtime.version}' ],
   [ 'pkg-config --cflags     libfoo', \'%{.runtime.cflags}'  ],
   [ 'pkg-config --libs       libfoo', \'%{.runtime.libs}'    ],
 ];

The scalar reference as the final item in the command list tells
L<Alien::Build> that the output from the command should be stored in the
given variable.  The runtime variables are the ones that will be
available to C<Alien::Libfoo> once it is installed.  (Install
properties, which are the ones that we have seen up till now are thrown
away once the L<Alien> distribution is installed.

You can also provide a C<sys> block for directives that should be used
when a system install is detected.  Normally you only need to do this if
the gather step is different between share and system installs.  For
example, the above is equivalent to:

 build {
   ...
   gather [

lib/Alien/Build/Manual/PluginAuthor.pod  view on Meta::CPAN

</div></div>
<p><b>Notes</b>: The colored blocks indicate <tt>alienfile</tt> blocks.
Hooks are indicated as predefined process (rectangle with double struck
vertical edges).  Hooks that can easily be implemented from an
<tt>alienfile</tt> are indicated in blue (Note that <tt>[]</tt> is used
to indicate passing in an array reference, but a subroutine
reference can also be used).  For simplicity, the the flowchart does
not include when required modules are loaded.  Except for configure
time requirements, they are loaded when the corresponding <tt>alienfile</tt>
blocks are entered.  It is not shown, but generally any plugin can cause
a <b>Fail</b> by throwing an exception with <tt>die</tt>.</p>

Perlish pseudo code for how plugins are called:

 my $probe;
 my $override = override();
 
 if($override eq 'system') {
 
   $probe = probe();
 

lib/Alien/Build/Manual/PluginAuthor.pod  view on Meta::CPAN

     return 1;
   } else {
     die "Digest FOO92 does not match: got $actual, expected $digest";
   }
 });

This hook should check the given C<$file> (the format is the same as used by
L<the fetch hook|/"fetch hook">) matches the given C<$digest> using the
given C<$algorithm>.  If the plugin does not support the given algorithm,
then it should return a false value.  If the digest does not match, it
should throw an exception.  If the digest matches, it should return a
true value.

=head2 clean_install

 $meta->register_hook( clean_install => sub {
   my($build) = @_;
 });

This hook allows you to remove files from the final install location before
the files are installed by the installer layer (examples: L<Alien::Build::MM>,

lib/Alien/Build/Manual/PluginAuthor.pod  view on Meta::CPAN

 });

This hook is used to download from the internet the source.  Either as
an archive (like tar, zip, etc), or as a directory of files (C<git clone>,
etc).  When the hook is called, the current working directory will be a
new empty directory, so you can save the download to the current
directory.  If you store a single file in the directory, L<Alien::Build>
will assume that it is an archive, which will be processed by the
L<extract hook|/"extract hook">.  If you store multiple files, L<Alien::Build> will
assume the current directory is the source root.  If no files are stored
at all, an exception with an appropriate diagnostic will be thrown.

B<Note>: If you register this hook, then the fetch, decode and prefer
hooks will NOT be called, unless you call them yourself from this hook.

=head2 extract hook

 $meta->register_hook( extract => sub {
   my($build, $archive) = @_;
   ...
 });

lib/Alien/Build/Plugin/Test/Mock.pm  view on Meta::CPAN

=item share

For a C<share> build.

=item system

For a C<system> build.

=item die

To throw an exception in the probe hook.  This will usually cause L<Alien::Build>
to try the next probe hook, if available, or to assume a C<share> install.

=back

=head2 download

 plugin 'Test::Mock' => (
   download => \%fs_spec,
 );
 

lib/Test/Alien/Build.pm  view on Meta::CPAN


=back

=head2 alienfile_ok

 my $build = alienfile_ok;
 my $build = alienfile_ok q{ use alienfile ... };
 my $build = alienfile_ok filename => 'alienfile';
 my $build = alienfile_ok $build;

Same as C<alienfile> above, except that it runs as a test, and will not throw an exception
on failure (it will return undef instead).

[version 1.49]

As of version 1.49 you can also pass in an already formed instance of L<Alien::Build>.  This
allows you to do something like this:

 subtest 'a subtest' => sub {
   my $build = alienfile q{ use alienfile; ... };
   alienfile_skip_if_missing_prereqs; # skip if alienfile prereqs are missing

t/alien_build.t  view on Meta::CPAN

        item 'ramjet';
      }
    );
  };

  my $exception_count = 0;

  $meta->register_hook(
    foo2 => sub {
      $exception_count++;
      die "throw exception";
    }
  );

  subtest 'single failing hook' => sub {

    $exception_count = 0;

    eval { $build->_call_hook(foo2 => ()) };
    like $@, qr/throw exception/;
    note "error = $@";
    is $exception_count, 1;

  };

  subtest 'one fail, one okay' => sub {

    $exception_count = 0;

    $meta->register_hook(

t/alien_build.t  view on Meta::CPAN

        note "dir = $CWD";
        return 'system';
      },
    );

    is($build->probe, 'system');
    is($build->runtime_prop->{install_type}, 'system');

  };

  subtest 'throw exception' => sub {

    my $build = alienfile filename => 'corpus/blank/alienfile';
    my $meta = $build->meta;

    $meta->register_hook(
      probe => sub {
        note "dir = $CWD";
        die "error will robinson!";
      },
    );

t/alien_build_plugin_digest_negotiate.t  view on Meta::CPAN

  subtest 'check_digest method' => sub {

    is
      $build->check_digest('corpus/alien_build_plugin_digest_shapp/foo.txt.gz'),
      T(),
      'check digest works';

    is
      dies { $build->check_digest(__FILE__) },
      match qr/SHA256 digest does not match/,
      'check digest throws exception on bad signature';
  };

  subtest 'fetch method' => sub {

    is
      $build->fetch('corpus/alien_build_plugin_digest_shapp/foo.txt.gz'),
      hash {
        field type => 'file';
        field filename => 'foo.txt.gz';
        etc;

t/alien_build_plugin_digest_negotiate.t  view on Meta::CPAN

      'check digest works foo.txt.gz';

    is
      $build->check_digest('corpus/alien_build_plugin_digest_shapp/foo.txt'),
      T(),
      'check digest works foo.txt';

    is
      dies { $build->check_digest(__FILE__) },
      match qr/SHA256 digest does not match/,
      'check digest throws exception on bad signature';
  };

  subtest 'fetch method' => sub {

    is
      $build->fetch('corpus/alien_build_plugin_digest_shapp/foo.txt.gz'),
      hash {
        field type => 'file';
        field filename => 'foo.txt.gz';
        etc;

t/alien_build_plugin_digest_negotiate.t  view on Meta::CPAN

      hash {
        field type => 'file';
        field filename => 'foo.txt';
        etc;
      },
      'fetch works foo.txt';

    is
      dies { $build->fetch(__FILE__) },
      match qr/SHA256 digest does not match/,
      'fetch throws exception on bad signature';

  };

  subtest 'download method' => sub {

    local $download_filename = path('corpus/alien_build_plugin_digest_shapp/foo.txt')->absolute;

    is
      $build,
      object {

t/alien_build_plugin_fetch_curlcommand.t  view on Meta::CPAN


  subtest '404' => sub {

    my($file, $error) = capture_note {
      my $file = eval {
        $build->fetch("$base/bogus.html");
      };
      ($file, $@);
    };

    isnt $error, '', 'throws error';
    note "error is: $error";

  };

};

#subtest 'fetch from ftp' => sub {
#
#  my $config = test_config 'ftpd';
#

t/alien_build_plugin_fetch_curlcommand.t  view on Meta::CPAN

#
#  subtest 'get non-existant directory listing with trailing slash' => sub {
#
#    my $error = capture_note {
#      eval {
#        $build->fetch("$base/bogus/")
#      };
#      $@;
#    };
#
#    isnt $error, '', 'throws error';
#    note "error = $error";
#
#  };
#
#  subtest 'get file' => sub {
#
#    my $file = capture_note { $build->fetch("$base/foo-1.01.tar") };
#
#    is(
#      $file,

t/alien_build_plugin_fetch_curlcommand.t  view on Meta::CPAN

#
#  subtest 'get missing file' => sub {
#
#    my($error) = capture_note {
#      eval {
#        $build->fetch("$base/bogus.txt");
#      };
#      $@;
#    };
#
#    isnt $error, '', 'throws error';
#    note "error is : $error";
#
#  };
#
#  subtest 'get directory listing sans trailing slash' => sub {
#
#    my $list = capture_note { $build->fetch("$base") };
#
#    is(
#      $list,

t/alien_build_plugin_fetch_wget.t  view on Meta::CPAN


  subtest '404' => sub {

    my($file, $error) = capture_note {
      my $file = eval {
        $build->fetch("$base/bogus.html");
      };
      ($file, $@);
    };

    isnt $error, '', 'throws error';
    note "error is: $error";

  };

};

subtest 'headers' => sub {
  my $url = http_url;
  skip_all http_error unless $url;

t/alienfile.t  view on Meta::CPAN

subtest 'non struct alienfile' => sub {

  eval {
    alienfile q{
      use alienfile;
      my $foo = 'bar';
      @{ "${foo}::${foo}" } = ();
    };
  };
  my $error = $@;
  isnt $error, '', 'throws error';
  note "error = $error";

};

subtest 'warnings alienfile' => sub {

  my $warning = warning {
    alienfile q{
      use alienfile;
      my $foo;



( run in 0.622 second using v1.01-cache-2.11-cpan-496ff517765 )