Alien-libzookeeper
view release on metacpan or search on metacpan
use alienfile;
use strict;
# problem: https://issues.apache.org/jira/browse/ZOOKEEPER-4013
# libzookeeper doesn't come with a pkg-config file, so even if there
# is a libzookeeper.a available, it won't show up here.
# So first probe with pkgconfig:
plugin 'PkgConfig' => (
pkg_name => 'libzookeeper',
minimum_version => '3.5.0', # version here is a trick -- if there's no pkg-config result,
# the PkgConfig plugin will return an empty string, which will
# fail this version check, and tickle the CBuilder codepath
);
# And then try with Probe::CBuilder:
my %zk_probe_args = (
version => qr/version = '[0-9\.]+'/,
program => q{
#include <stdio.h>
#include <zookeeper/zookeeper_version.h>
int main() {
#ifdef ZOO_VERSION
/* recent versions of zk only provide the textual version: */
printf("version = '%s'\n", ZOO_VERSION);
#else
printf("version = '%d.%d.%d'\n", ZOO_MAJOR_VERSION, ZOO_MINOR_VERSION, ZOO_PATCH_VERSION);
#endif
return 0;
}
},
);
plugin 'Probe::CBuilder' => (
# directly building the zk C source gets you a libzookeper
# using the maven build gets you two libraries:
# libzookeeper_st, which they strongly recommend not using,
# and libzookeeper_mt, which is actually just libzookeeper.
# So probe for both:
libs => '-lzookeeper_mt',
%zk_probe_args,
);
share {
# this is https://github.com/Hugmeir/zookeeper/tree/all-patches-for-p5-alien-libzookeeper
plugin Download => (
url => 'https://github.com/hugmeir/zookeeper/archive/4b6b9dc0a6a419958ab27af8699e8417ab0f8dac.tar.gz',
);
plugin Extract => 'tar.gz';
plugin 'Build::CMake' => ();
build [
'cd %{.install.extract}/zookeeper-client/zookeeper-client-c',
[
'%{cmake}',
'-DCMAKE_BUILD_TYPE=Release', # release, no debug symbols
'-DWANT_SYNCAPI=ON', # sync and async symbols
'-DWANT_CPPUNIT=OFF', # we don't run `make test`
'-DWITH_CYRUS_SASL:BOOL=OFF', # TODO: should probe for sasl
@{ meta->prop->{plugin_build_cmake}->{args} },
'%{.install.extract}/zookeeper-client/zookeeper-client-c',
],
[
'%{make}',
'-C' => '%{.install.extract}/zookeeper-client/zookeeper-client-c',
],
[
'%{make}',
'-C' => '%{.install.extract}/zookeeper-client/zookeeper-client-c',
'install',
],
];
};
meta->after_hook(
'gather_system' => sub {
# if we are using the system libraries, we need to add -lzookeeper into libs:
# ..but because we use three different hooks, we end up with race conditions
# and need to do this mess:
my ($build) = @_;
my $install_prop = $build->{install_prop} // {}; # make sure not to vivify this!
my $cbuilder_gather = $install_prop->{plugin_probe_cbuilder_gather} // {};
foreach my $gathered ( values %$cbuilder_gather ) {
# if we have entries, it means the CBuilder hook succeeded -- so copy
# the values it got!
$build->{runtime_prop}->{$_} ||= $gathered->{$_}
for keys %$gathered;
}
}
);
( run in 2.150 seconds using v1.01-cache-2.11-cpan-02777c243ea )