Created
December 30, 2010 14:15
-
-
Save zedalaye/759831 to your computer and use it in GitHub Desktop.
Improve the search of Firebird Root algorithm under Windows
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
From ed6cd80bdd2e289befdad1e5e15eed425e19e2e8 Mon Sep 17 00:00:00 2001 | |
From: Pierre Yager <pierre@levosgien.net> | |
Date: Thu, 30 Dec 2010 15:06:06 +0100 | |
Subject: [PATCH 1/2] Improved searching of the Firebird root directory. | |
--- | |
extconf.rb | 24 ++++++++++++++++++++---- | |
1 files changed, 20 insertions(+), 4 deletions(-) | |
diff --git a/extconf.rb b/extconf.rb | |
index 09444ef..c142c6c 100644 | |
--- a/extconf.rb | |
+++ b/extconf.rb | |
@@ -14,13 +14,29 @@ | |
# = Mac OS X (Intel) | |
# * Works | |
-if RUBY_PLATFORM =~ /(mingw32|mswin32)/ and ARGV.grep(/^--with-opt-dir=/).empty? | |
- program_files = ENV['ProgramFiles'].gsub('\\', '/').gsub(/(\w+\s+[\w\s]+)/) { |s| s.size > 8 ? s[0,6] + '~1' : s } | |
- if opt = Dir["#{program_files}/Firebird/Firebird_*"].sort.last | |
- ARGV << "--with-opt-dir=#{opt}" | |
+def unquote(string) | |
+ string.sub(/\A(['"])?(.*?)\1?\z/m, '\2') unless string.nil? | |
+end | |
+ | |
+def read_firebird_registry | |
+ require 'win32/registry' | |
+ Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Firebird Project\Firebird Server\Instances', Win32::Registry::Constants::KEY_READ) do |reg| | |
+ return reg.read_s('DefaultInstance') rescue nil | |
end | |
end | |
+def search_firebird_path | |
+ program_files = ENV['ProgramFiles'].gsub('\\', '/').gsub(/(\w+\s+[\w\s]+)/) { |s| s.size > 8 ? s[0,6] + '~1' : s } | |
+ Dir["#{program_files}/Firebird/Firebird_*"].sort.last | |
+end | |
+ | |
+if RUBY_PLATFORM =~ /(mingw32|mswin32)/ and ARGV.grep(/^--with-opt-dir=/).empty? | |
+ opt = unquote(ENV['FIREBIRD']) | |
+ opt = opt || read_firebird_registry | |
+ opt = opt || search_firebird_path | |
+ ARGV << "--with-opt-dir=#{opt}" if opt | |
+end | |
+ | |
require 'mkmf' | |
libs = %w/ fbclient gds / | |
-- | |
1.7.0.2.msysgit.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment