Alien-FluentBit

 view release on metacpan or  search on metacpan

alienfile  view on Meta::CPAN

      `"$bin_dir/fluent-bit" --version` =~ /v([0-9.]+)/ or die; # tested above
      $build->runtime_prop->{version}= $1;
      # Headers installed by fluent-bit cmake are broken, missing many referenced
      # sub-projects, but also all of it it is unnecessary because the public API
      # is only 10 functions.
      # See https://github.com/fluent/fluent-bit/issues/7165
      my $custom_inc_dir= path("$prefix/include");
      $custom_inc_dir->mkpath;
      $minimal_header->copy("$custom_inc_dir/fluent-bit-minimal.h");
      $minimal_header->copy("$custom_inc_dir/fluent-bit.h");
      $build->runtime_prop->{cflags}= "-I$custom_inc_dir";
      $build->runtime_prop->{libs}= "-L/lib/fluent-bit -Wl,-rpath,/lib/fluent-bit -lfluent-bit";
   };
};

share {
   requires 'Alien::cmake3';
   requires 'Alien::flex';
   requires 'Alien::bison';
   start_url 'https://github.com/fluent/fluent-bit/archive/refs/tags/v2.1.0.tar.gz';
   plugin Download => ();

alienfile  view on Meta::CPAN

         # ... put extra cmake args here ...
         '%{.install.extract}'
      ],
      '%{make} -j 10',
      '%{make} install',
   ];
   plugin 'Gather::IsolateDynamic';
   after gather => sub {
      my $build   = shift;
      my $prefix  = path($build->install_prop->{prefix})->absolute;
      $build->runtime_prop->{cflags}= "-I$prefix/include";
      $build->runtime_prop->{libs}  = "-L$prefix/lib/fluent-bit -Wl,-rpath,$prefix/lib/fluent-bit -lfluent-bit";
      # Use a minimal fluent-bit.h because the headers installed by cmake
      # are broken, missing many deps.
      # See https://github.com/fluent/fluent-bit/issues/7165
      my $install_root;
      if ($build->meta_prop->{destdir}) {
         my $destdir = $ENV{DESTDIR};
         $install_root = path(_destdir_prefix($ENV{DESTDIR}, $build->install_prop->{prefix}));
      } else {
         $install_root = path($build->install_prop->{stage});

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

To install fluent-bit from official binary release:

  $ curl https://raw.githubusercontent.com/fluent/fluent-bit/master/install.sh | sh
  $ export LD_PRELOAD=/lib/fluent-bit/libfluent-bit.so # see below
  $ cpanm Alien::FluentBit

To use:

  use Alien::FluentBit;
  say "Commandline tool is ".Alien::FluentBit->fluentbit;
  say "Compile flags are ".Alien::FluentBit->cflags;
  say "Link flags are ".Alien::FluentBit->libs;

See the Makefile.PL of Fluent::LibFluentBit for a full example.

=head1 DESCRIPTION

This distribution either finds fluent-bit installed on your system (currently only at the
slightly odd locations used by the binary dist for Debian systems) or builds it from source.

Currently only building from source works properly, as the binary dist library conflucts with
perl related to TLS allocations, and needs pre-loaded.  Pre-loading a giant library like this

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

=over

=item version

The version of fluent-bit and libfluent-bit.so

=item fluentbit

The path of the fluent-bit executable

=item cflags

The C compiler flags

=item libs

The C linker flags and libraries

I<< ( this module does not yet support static linking ) >>

=back

See L<Alien::Base> for additional inherited attributes and methods.

=head1 SEE ALSO

=over

t/01-compile.t  view on Meta::CPAN

use Test2::V0;
use Test::Alien;
use Alien::FluentBit;

alien_ok 'Alien::FluentBit';
note 'cflags '.Alien::FluentBit->cflags;
note 'libs '.Alien::FluentBit->libs;
note 'bin_dir '.Alien::FluentBit->bin_dir;

ok( -x Alien::FluentBit->fluentbit, 'fluent-bit executable' );

# Workaround bug where Test::Alien doesn't rewrite the rpath
# It needs to point to the temp dir, not the final perl lib install dir
my $libs= Alien::FluentBit->libs;
my ($libpath)= ($libs =~ m{-L(/\S+)});
$libs =~ s{-Wl,-rpath,(/\S+)}{-Wl,-rpath,$libpath};



( run in 0.262 second using v1.01-cache-2.11-cpan-94b05bcf43c )