Skip to content

Instantly share code, notes, and snippets.

@aharpervc
Created May 18, 2015 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aharpervc/e2675cc13ef000d8c791 to your computer and use it in GitHub Desktop.
Save aharpervc/e2675cc13ef000d8c791 to your computer and use it in GitHub Desktop.
patch for ruby 2.2 securerandom.rb to get rake-compiler to cross build ruby 2.2
--- /home/vagrant/.rake-compiler/sources/ruby-2.2.1/lib/securerandom.rb.original 2015-05-18 08:49:56.007018200 -0700
+++ /home/vagrant/.rake-compiler/sources/ruby-2.2.1/lib/securerandom.rb 2015-05-18 08:58:42.187018200 -0700
@@ -45,9 +45,14 @@
module AdvApi32 # :nodoc:
extend Fiddle::Importer
- dlload "advapi32"
- extern "int CryptAcquireContext(void*, void*, void*, unsigned long, unsigned long)"
- extern "int CryptGenRandom(void*, unsigned long, void*)"
+
+ begin
+ dlload "advapi32"
+ extern "int CryptAcquireContext(void*, void*, void*, unsigned long, unsigned long)"
+ extern "int CryptGenRandom(void*, unsigned long, void*)"
+ rescue Fiddle::DLError => e
+ STDERR.puts "(Ignore this error if cross compiling) #{e}"
+ end
def self.get_provider
hProvStr = " " * Fiddle::SIZEOF_VOIDP
@@ -74,9 +79,14 @@
module Kernel32 # :nodoc:
extend Fiddle::Importer
- dlload "kernel32"
- extern "unsigned long GetLastError()"
- extern "unsigned long FormatMessageA(unsigned long, void*, unsigned long, unsigned long, void*, unsigned long, void*)"
+
+ begin
+ dlload "kernel32"
+ extern "unsigned long GetLastError()"
+ extern "unsigned long FormatMessageA(unsigned long, void*, unsigned long, unsigned long, void*, unsigned long, void*)"
+ rescue Fiddle::DLError => e
+ STDERR.puts "(Ignore this error if cross compiling) #{e}"
+ end
# Following code is based on David Garamond's GUID library for Ruby.
def self.last_error_message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment