-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
mingw-w64-ruby34/0001-Add-C-ext-win32-dll_directory-as-an-alternative-to-f.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
From fd61aba54664f3374e950e260876a64369b5c839 Mon Sep 17 00:00:00 2001 | ||
From: Lars Kanis <[email protected]> | ||
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 <ruby.h> | ||
+#include <ruby/encoding.h> | ||
+#include <windows.h> | ||
+#include <libloaderapi.h> | ||
+ | ||
+#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 | ||
|
26 changes: 26 additions & 0 deletions
26
mingw-w64-ruby34/0002-Don-t-add-an-exe-file-manifest.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From 61a79dda62aa64edd1648ca97d4fe01ce9f69811 Mon Sep 17 00:00:00 2001 | ||
From: Lars Kanis <[email protected]> | ||
Date: Thu, 10 Jun 2021 21:10:33 +0200 | ||
Subject: [PATCH] Don't add an exe file manifest | ||
|
||
It is later added as part of the rubyinstaller2 build process. | ||
The manifest was introduced in: https://github.com/ruby/ruby/pull/4505 | ||
--- | ||
win32/resource.rb | 1 - | ||
1 file changed, 1 deletion(-) | ||
|
||
diff --git a/win32/resource.rb b/win32/resource.rb | ||
index bc3eda5630..e0e7323dc7 100755 | ||
--- a/win32/resource.rb | ||
+++ b/win32/resource.rb | ||
@@ -61,7 +61,6 @@ def icons.find(path) | ||
#include <winver.h> | ||
|
||
#{icon || ''} | ||
-#{type == 'VFT_APP' ? "1 RT_MANIFEST ruby.manifest" : ""} | ||
VS_VERSION_INFO VERSIONINFO | ||
FILEVERSION #{nversion} | ||
PRODUCTVERSION #{nversion} | ||
-- | ||
2.30.0.windows.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
_realname=ruby | ||
pkgbase=mingw-w64-ruby34 | ||
pkgname="${MINGW_PACKAGE_PREFIX}-ruby33" | ||
# version used by MRI | ||
pkgver2=3.4.1 | ||
# version used by pacman | ||
pkgver="${pkgver2/-/.}" | ||
pkgrel=1 | ||
pkgdesc="An object-oriented language for quick and easy programming (mingw-w64)" | ||
arch=('any') | ||
mingw_arch=('mingw32' 'ucrt64' 'clangarm64') | ||
url="https://www.ruby-lang.org/en" | ||
license=("BSD, custom") | ||
makedepends=("${MINGW_PACKAGE_PREFIX}-cc" | ||
"${MINGW_PACKAGE_PREFIX}-pkgconf" | ||
autoconf automake libtool patch make) | ||
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" | ||
"${MINGW_PACKAGE_PREFIX}-gmp" | ||
"${MINGW_PACKAGE_PREFIX}-libffi" | ||
"${MINGW_PACKAGE_PREFIX}-libyaml" | ||
"${MINGW_PACKAGE_PREFIX}-openssl>=3.0.0" | ||
"${MINGW_PACKAGE_PREFIX}-zlib") | ||
options=('staticlibs' 'strip') | ||
source=("https://cache.ruby-lang.org/pub/ruby/${pkgver2%.*}/${_realname}-${pkgver2}.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) | ||
|
||
# To update SHA256 hashs run: ridk exec sh -c "updpkgsums PKGBUILD" | ||
|
||
sha256sums=('018d59ffb52be3c0a6d847e22d3fd7a2c52d0ddfee249d3517a0c8c6dbfa70af' | ||
'a50c81ab8c178689485257f8eaa70bd8184b878a798780084668f838912e2832' | ||
'da079dbfdc3d4e1b976ed15d58244ed6e0df201ec829bead578fb4a7177b9cab' | ||
'6c80ba2ca49840e387a08b7fedc6e7acd298ac2ec853155209efb2af20397b22' | ||
'c30fb04ac0e88ba634daaa811a81ea5a75027646617b895acd14df9518a4a55a') | ||
|
||
prepare() { | ||
cd ${srcdir}/${_realname}-${pkgver2} | ||
rm -rf ext/win32/dll_directory | ||
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 | ||
} | ||
|
||
build() { | ||
mkdir -p build-${MSYSTEM} && cd build-${MSYSTEM} | ||
|
||
CFLAGS="-O3 -fstack-protector-strong" | ||
LDFLAGS="-pipe -s -fstack-protector-strong" | ||
if [[ ${MSYSTEM} == CLANG* ]]; then | ||
CFLAGS+=" -Wno-dll-attribute-on-redeclaration -Wno-shorten-64-to-32" | ||
else | ||
CFLAGS+=" -Wno-incompatible-pointer-types" | ||
fi | ||
|
||
cp ${srcdir}/*.ico . | ||
|
||
../${_realname}-${pkgver2}/configure \ | ||
--prefix=${MINGW_PREFIX} \ | ||
--build=${MINGW_CHOST} \ | ||
--host=${MINGW_CHOST} \ | ||
--target=${MINGW_CHOST} \ | ||
--with-out-ext=readline,pty,syslog | ||
|
||
make showflags main | ||
echo "Generate RI and HTML documentation" | ||
# Make rdoc outputs so many lines -> print dots only | ||
make rdoc html 2>&1 | ./miniruby -ne "STDERR.print '.'" | ||
} | ||
|
||
check() { | ||
cd build-${MSYSTEM} | ||
echo $PATH | ||
make -l "TESTOPTS=-q" btest test-basic | ||
# TODO: Full tests fail currently | ||
# make -l "TESTOPTS=-q" test-all || true | ||
} | ||
|
||
package() { | ||
cd build-${MSYSTEM} | ||
make -f GNUMakefile DESTDIR="${pkgdir}" install | ||
for script in gem; do | ||
install ${srcdir}/ruby-${pkgver2}/bin/${script} \ | ||
${pkgdir}${MINGW_PREFIX}/bin/ | ||
done | ||
} |
Binary file not shown.
Binary file not shown.