Skip to content

Commit

Permalink
Fix deprecation messages on Windows
Browse files Browse the repository at this point in the history
Previously we were copying dll files from resources to a different
location so that the files could continue having the same file
name. There was also a hack to avoid doing that copy and to use
the included dll files directly if it determined those resources
already had the expected basename (such as a non-installed openssl).
The hack relied on using now deprecated methods, but realistically
we don't need it.

This reworks the logic on Windows for copying a resource file to
always occur regardless of what repository has loaded it. By doing
so it fixes some deprecation messages from rakudo about treating
resource objects like path strings.

See: rakudo/rakudo#5507
  • Loading branch information
ugexe committed Jan 21, 2024
1 parent c1a9893 commit 286f199
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ jobs:
run: zef build .
- name: Stage, Test, and Installation
run: zef install . --debug
- name: Ensure dll rename hack works
if: runner.os == 'Windows'
run: |
Remove-Item -Path $env:TEMP\* -Recurse -Force -ErrorAction Ignore
raku ${{ github.workspace }}/t/06-digest-md5.t
24 changes: 12 additions & 12 deletions lib/OpenSSL/NativeLib.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ sub crypto-lib is export {
# 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;
my $content-id = nqp::sha1($resource-name);
my $dll-directory = $*TMPDIR.add($content-id);
my $dll-resource = $dll-directory.add($resource-name);

unless $dll-resource.e {
mkdir $dll-directory unless $dll-directory.e;
my $resource = %?RESOURCES{$resource-name};
my $resource-data := %?RESOURCES{$resource-name}.slurp(:bin, :close);
$dll-resource.spurt($resource-data, :bin, :close);
}

return $dll-resource.absolute;
}

0 comments on commit 286f199

Please sign in to comment.