Skip to content

Commit

Permalink
Workaround windows dll renaming issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ugexe committed May 12, 2016
1 parent ec1b2a3 commit 91efa8c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion META.info
@@ -1,6 +1,6 @@
{
"name" : "OpenSSL",
"version" : "0.1.1",
"version" : "0.1.2",
"author" : "github:sergot",
"description" : "OpenSSL bindings",
"depends" : ["Digest"],
Expand Down
28 changes: 26 additions & 2 deletions lib/OpenSSL/NativeLib.pm6
Expand Up @@ -2,12 +2,36 @@ unit module OpenSSL::NativeLib;

sub ssl-lib is export {
state $lib = $*DISTRO.is-win
?? %?RESOURCES<ssleay32.dll>.absolute
?? dll-resource('ssleay32.dll')
!! $*VM.platform-library-name('ssl'.IO).Str;
}

sub gen-lib is export {
state $lib = $*DISTRO.is-win
?? %?RESOURCES<libeay32.dll>.absolute
?? dll-resource('libeay32.dll')
!! $*VM.platform-library-name('ssl'.IO).Str;
}

# Windows only
# Problem: The dll files in resources/ don't like to be renamed, but CompUnit::Repository::Installation
# does not provide a mechanism for storing resources without name mangling. Find::Bundled provided
# this before, but it has suffered significant bit rot.
# "Fix": Continue to store the name mangled resource. Check $*TMPDIR/<sha1 of resource path>/$basename
# and use it if it exists, otherwise copy the name mangled file to this location but using the
# original unmangled name.
# XXX: This should be removed when CURI/%?RESOURCES gets a mechanism to bypass name mangling
use nqp;
sub dll-resource($resource-name) {
my $resource = %?RESOURCES{$resource-name};
return $resource.absolute if $resource.basename eq $resource-name;

my $content_id = nqp::sha1($resource.absolute);
my $content_store = $*TMPDIR.child($content_id);
my $content_file = $content_store.child($resource-name).absolute;
return $content_file if $content_file.IO.e;

mkdir $content_store unless $content_store.e;
copy($resource, $content_file);

$content_file;
}

0 comments on commit 91efa8c

Please sign in to comment.