diff --git a/mingw-w64-ruby-head/0001-Add-C-ext-win32-dll_directory-as-an-alternative-to-f.patch b/mingw-w64-ruby-head/0001-Add-C-ext-win32-dll_directory-as-an-alternative-to-f.patch new file mode 100644 index 0000000..ef1d787 --- /dev/null +++ b/mingw-w64-ruby-head/0001-Add-C-ext-win32-dll_directory-as-an-alternative-to-f.patch @@ -0,0 +1,82 @@ +From fd61aba54664f3374e950e260876a64369b5c839 Mon Sep 17 00:00:00 2001 +From: Lars Kanis +Date: Tue, 28 Dec 2021 11:11:42 +0100 +Subject: [PATCH] Add C-ext "win32/dll_directory" as an alternative to fiddle + +--- + ext/win32/dll_directory/depend | 2 ++ + ext/win32/dll_directory/dll_directory.c | 42 +++++++++++++++++++++++++ + ext/win32/dll_directory/extconf.rb | 3 ++ + 3 files changed, 47 insertions(+) + create mode 100644 ext/win32/dll_directory/depend + create mode 100644 ext/win32/dll_directory/dll_directory.c + create mode 100644 ext/win32/dll_directory/extconf.rb + +diff --git a/ext/win32/dll_directory/depend b/ext/win32/dll_directory/depend +new file mode 100644 +index 0000000000..0301ce074c +--- /dev/null ++++ b/ext/win32/dll_directory/depend +@@ -0,0 +1,2 @@ ++# AUTOGENERATED DEPENDENCIES START ++# AUTOGENERATED DEPENDENCIES END +diff --git a/ext/win32/dll_directory/dll_directory.c b/ext/win32/dll_directory/dll_directory.c +new file mode 100644 +index 0000000000..d44b8f2cb3 +--- /dev/null ++++ b/ext/win32/dll_directory/dll_directory.c +@@ -0,0 +1,42 @@ ++#include ++#include ++#include ++#include ++ ++#define PTR2NUM(x) (ULL2NUM((LONG_LONG)(x))) ++#define NUM2PTR(x) ((void*)(NUM2ULL(x))) ++ ++static VALUE ++s_SetDefaultDllDirectories(VALUE self, VALUE flags) ++{ ++ int ret = SetDefaultDllDirectories(RB_NUM2LONG(flags)); ++ return RB_INT2NUM(ret); ++} ++ ++static VALUE ++s_AddDllDirectory(VALUE self, VALUE dir) ++{ ++ void *handle; ++ int encidx = rb_enc_find_index("utf-16le"); ++ StringValueCStr(dir); ++ dir = rb_str_export_to_enc(dir, rb_enc_from_index(encidx)); ++ handle = AddDllDirectory((PCWSTR)RSTRING_PTR(dir)); ++ return PTR2NUM(handle); ++} ++ ++static VALUE ++s_RemoveDllDirectory(VALUE self, VALUE handle) ++{ ++ int ret = RemoveDllDirectory(NUM2PTR(handle)); ++ return RB_INT2NUM(ret); ++} ++ ++void ++Init_dll_directory(void) ++{ ++ VALUE mWin32 = rb_define_module("Win32"); ++ VALUE mDD = rb_define_module_under(mWin32, "DllDirectory"); ++ rb_define_singleton_method(mDD, "SetDefaultDllDirectories", s_SetDefaultDllDirectories, 1); ++ rb_define_singleton_method(mDD, "AddDllDirectory", s_AddDllDirectory, 1); ++ rb_define_singleton_method(mDD, "RemoveDllDirectory", s_RemoveDllDirectory, 1); ++} +diff --git a/ext/win32/dll_directory/extconf.rb b/ext/win32/dll_directory/extconf.rb +new file mode 100644 +index 0000000000..cfdeafacaf +--- /dev/null ++++ b/ext/win32/dll_directory/extconf.rb +@@ -0,0 +1,3 @@ ++if have_library('kernel32', 'AddDllDirectory') ++ create_makefile('win32/dll_directory') ++end +-- +2.30.0.windows.1 + diff --git a/mingw-w64-ruby-head/PKGBUILD b/mingw-w64-ruby-head/PKGBUILD index 7c20f7c..3849925 100644 --- a/mingw-w64-ruby-head/PKGBUILD +++ b/mingw-w64-ruby-head/PKGBUILD @@ -20,6 +20,7 @@ depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" "${MINGW_PACKAGE_PREFIX}-zlib") options=('staticlibs' 'strip') source=("https://cache.ruby-lang.org/pub/ruby/snapshot/snapshot-master.tar.xz" + 0001-Add-C-ext-win32-dll_directory-as-an-alternative-to-f.patch 0002-Don-t-add-an-exe-file-manifest.patch ruby.ico rubyw.ico) @@ -29,6 +30,7 @@ noextract=("snapshot-master.tar.xz") # and set first entry to 'SKIP' sha256sums=('SKIP' + 'a50c81ab8c178689485257f8eaa70bd8184b878a798780084668f838912e2832' 'da079dbfdc3d4e1b976ed15d58244ed6e0df201ec829bead578fb4a7177b9cab' '6c80ba2ca49840e387a08b7fedc6e7acd298ac2ec853155209efb2af20397b22' 'c30fb04ac0e88ba634daaa811a81ea5a75027646617b895acd14df9518a4a55a') @@ -36,6 +38,7 @@ sha256sums=('SKIP' prepare() { bsdtar -xf snapshot-master.tar.xz || true cd ${srcdir}/snapshot-master + patch -p1 -i ${srcdir}/0001-Add-C-ext-win32-dll_directory-as-an-alternative-to-f.patch patch -p1 -i ${srcdir}/0002-Don-t-add-an-exe-file-manifest.patch autoreconf -fi }