Alien-curl
view release on metacpan or search on metacpan
Source code for a work means the preferred form of the work for making
modifications to it. For an executable file, complete source code means
all the source code for all modules it contains; but, as a special
exception, it need not include source code for modules which are standard
libraries that accompany the operating system on which the executable
file runs, or for standard header files or definitions files that
accompany that operating system.
4. You may not copy, modify, sublicense, distribute or transfer the
Program except as expressly provided under this General Public License.
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
the Program is void, and will automatically terminate your rights to use
the Program under this License. However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.
5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.
my $type = $orig->($build,@_);
if($type eq 'system')
{
find_lib_or_die lib => 'curl';
}
$type;
});
share {
my $alien_ssl = 'Alien::OpenSSL';
my @acflags;
# - schannel is the native SSL on windows
if($^O eq 'MSWin32')
{
unshift @acflags, '--with-schannel';
undef $alien_ssl;
}
# - libressl is the native SSL on openbsd and would be expected to be used there.
elsif($^O eq 'openbsd')
{
$alien_ssl = 'Alien::LibreSSL';
unshift @acflags, '--with-openssl';
}
# - macOS has its own native SSL implementation which is supported by curl
elsif($^O eq 'darwin')
{
unshift @acflags, '--with-secure-transport';
undef $alien_ssl;
}
# - elsewhere OpenSSL is probably a reasonable option
else
{
unshift @acflags, '--with-openssl';
}
if($alien_ssl)
{
if($alien_ssl eq 'Alien::OpenSSL')
{
requires $alien_ssl => '0.15';
}
else
{
requires $alien_ssl => 0;
}
# Build::SearchDep should have an option to do just this
# without modifying the build stage
# https://github.com/PerlAlien/Alien-Build/issues/373
meta->after_hook(
gather_share => sub {
my($build) = @_;
$build->runtime_prop->{$_} .= $alien_ssl->$_ for qw( libs libs_static cflags cflags_static );
}
);
}
plugin Download => (
url => 'https://curl.haxx.se/download/',
version => qr/^curl-([0-9\.]+)\.tar\.gz$/,
);
plugin Extract => 'tar.gz';
# make sure that curl uses the linker flags
# from our Alien SSL
if($alien_ssl)
{
meta->around_hook( $_ => sub {
my $orig = shift;
my $build = shift;
local $ENV{LDFLAGS} = $ENV{LDFLAGS};
unshift @LDFLAGS, grep /^-L/, shellwords( $alien_ssl->libs );
log "using LDFLAGS = $ENV{LDFLAGS}";
$orig->($build, @_);
}) for qw( build build_ffi );
}
plugin 'Build::Autoconf' => ();
build [
"%{configure} --disable-shared --enable-static @acflags",
'%{make}',
'%{make} install',
];
after gather => sub {
my $build = shift;
return unless $alien_ssl;
$build->install_prop->{libs_static} = join(' ',
$build->install_prop->{libs_static},
grep /^-L/,
shellwords( $alien_ssl->libs ),
);
};
requires 'Path::Tiny';
my $ffi_target = '%{.install.autoconf_prefix}/dynamic';
ffi {
my $patch_makefile = sub {
my ($build) = @_;
maint/cip-before-install view on Meta::CPAN
if [ "x$CIP_ENV" == "x" ]; then
echo "please set CIP_ENV to one of:"
echo " export CIP_ENV=ALIEN_INSTALL_TYPE=share"
echo " export CIP_ENV=ALIEN_INSTALL_TYPE=system"
false
fi
if echo $CIP_ENV | grep -q system; then
echo use system curl
cip sudo apt-get update
cip sudo apt-get -y install libcurl4-openssl-dev libffi-dev
else
echo use internet curl
cip sudo apt-get update
cip sudo apt-get -y install g++ libffi-dev
fi
cip exec env ALIEN_INSTALL_TYPE=default cpanm -n FFI::Platypus
t/alien_curl.t view on Meta::CPAN
{
package
Curl::Version;
require FFI::Platypus::Record;
FFI::Platypus::Record::record_layout(
'enum' => 'age',
'string' => 'version',
'uint' => 'version_num',
'string' => 'host',
'int' => 'features',
'string' => 'ssl_version',
'ulong' => 'ssl_version_num',
'string' => 'libz_version',
'opaque' => 'protocols',
);
}
$ffi->function( curl_version_info => ['enum'] => 'record(Curl::Version)' );
};
if(my $error = $@)
{
note "error looking for curl_version_info";
note $error;
}
else
{
my $version = $curl_version_info->call(0);
note "age = ", $version->age;
note "version = ", $version->version;
note "version_num = ", $version->version_num;
note "host = ", $version->host;
note "features = ", $version->features;
note "ssl_version = ", $version->ssl_version;
note "ssl_version_num = ", $version->ssl_version_num;
note "libz_version = ", $version->libz_version;
my @proto = @{ $ffi->cast('opaque', 'string[]', $version->protocols()) };
note "proto = $_" for @proto;
my %proto = map { $_ => 1 } @proto;
is(
\%proto,
$proto_check,
'protocols supported incudes: http, https, and ftp',
) || diag "proto: @proto";
}
( run in 0.879 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )