Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Nix) Allow for specifying include/library paths #210

Merged
merged 4 commits into from
Mar 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 52 additions & 41 deletions ext/oci8/oraconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ def initialize
def self.get
original_CFLAGS = $CFLAGS
original_defs = $defs
ic_dir = nil
begin
# check Oracle instant client
if with_config('instant-client')
Expand All @@ -262,11 +261,17 @@ def self.get
=======================================================
EOS
end
ic_dir = check_ic_dir
if ic_dir
OraConfIC.new(ic_dir)
inc, lib = dir_config('instant-client')
if inc && lib
OraConfIC.new(inc, lib)
else
OraConfFC.new()
base = guess_ic_dir
if base
inc, lib = guess_dirs_from_ic_base(base)
OraConfIC.new(inc, lib)
else
OraConfFC.new
end
end
rescue
case ENV['LANG']
Expand Down Expand Up @@ -298,6 +303,44 @@ def self.get
end
end

# Guess the include and directory paths from
def self.guess_dirs_from_ic_base(ic_dir)
if ic_dir =~ /^\/usr\/lib(?:64)?\/oracle\/(\d+(?:\.\d+)*)\/client(64)?\/lib(?:64)?/
# rpm package
# x86 rpms after 11.1.0.7.0:
# library: /usr/lib/oracle/X.X/client/lib/
# include: /usr/include/oracle/X.X/client/
#
# x86_64 rpms after 11.1.0.7.0:
# library: /usr/lib/oracle/X.X/client64/lib/
# include: /usr/include/oracle/X.X/client64/
#
# x86 rpms before 11.1.0.6.0:
# library: /usr/lib/oracle/X.X.X.X/client/lib/
# include: /usr/include/oracle/X.X.X.X/client/
#
# x86_64 rpms before 11.1.0.6.0:
# library: /usr/lib/oracle/X.X.X.X/client64/lib/
# include: /usr/include/oracle/X.X.X.X/client64/
#
# third-party x86_64 rpms(*1):
# library: /usr/lib64/oracle/X.X.X.X/client/lib/
# or /usr/lib64/oracle/X.X.X.X/client/lib64/
# include: /usr/include/oracle/X.X.X.X/client/
#
# *1 These had been used before Oracle released official x86_64 rpms.
#
lib_dir = ic_dir
inc_dir = "/usr/include/oracle/#{$1}/client#{$2}"
else
# zip package
lib_dir = ic_dir
inc_dir = "#{ic_dir}/sdk/include"
end

[inc_dir, lib_dir]
end

def self.ld_envs
@@ld_envs
end
Expand All @@ -316,8 +359,9 @@ def self.make_proc_to_check_cpu(*expect)
end
end

def self.check_ic_dir
puts "checking for load library path... "
def self.guess_ic_dir
puts "attempting to locate oracle-instantclient..."
puts "checking load library path... "
STDOUT.flush

# get library load path names
Expand Down Expand Up @@ -947,42 +991,9 @@ def get_cflags

# OraConf for Instant Client
class OraConfIC < OraConf
def initialize(ic_dir)
def initialize(inc_dir, lib_dir)
init

if ic_dir =~ /^\/usr\/lib(?:64)?\/oracle\/(\d+(?:\.\d+)*)\/client(64)?\/lib(?:64)?/
# rpm package
# x86 rpms after 11.1.0.7.0:
# library: /usr/lib/oracle/X.X/client/lib/
# include: /usr/include/oracle/X.X/client/
#
# x86_64 rpms after 11.1.0.7.0:
# library: /usr/lib/oracle/X.X/client64/lib/
# include: /usr/include/oracle/X.X/client64/
#
# x86 rpms before 11.1.0.6.0:
# library: /usr/lib/oracle/X.X.X.X/client/lib/
# include: /usr/include/oracle/X.X.X.X/client/
#
# x86_64 rpms before 11.1.0.6.0:
# library: /usr/lib/oracle/X.X.X.X/client64/lib/
# include: /usr/include/oracle/X.X.X.X/client64/
#
# third-party x86_64 rpms(*1):
# library: /usr/lib64/oracle/X.X.X.X/client/lib/
# or /usr/lib64/oracle/X.X.X.X/client/lib64/
# include: /usr/include/oracle/X.X.X.X/client/
#
# *1 These had been used before Oracle released official x86_64 rpms.
#
lib_dir = ic_dir
inc_dir = "/usr/include/oracle/#{$1}/client#{$2}"
else
# zip package
lib_dir = ic_dir
inc_dir = "#{ic_dir}/sdk/include"
end

if RUBY_PLATFORM =~ /mswin32|mswin64|cygwin|mingw32|bccwin32/ # when Windows
unless File.exist?("#{ic_dir}/sdk/lib/msvc/oci.lib")
raise <<EOS
Expand Down
11 changes: 10 additions & 1 deletion setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,16 @@ class ConfigTable
'the make program to compile ruby extentions' ] ],
[ 'without-ext', [ 'no',
'yes/no',
'does not compile/install ruby extentions' ] ]
'does not compile/install ruby extentions' ] ],
[ 'with-instant-client-dir', ['',
'path',
'path to the Oracle instant client directory'] ],
[ 'with-instant-client-lib', ['',
'path',
'path to the Oracle instant client libraries'] ],
[ 'with-instant-client-include', ['',
'path',
'path to the Oracle instant client header files'] ]
]
multipackage_descripters = [
[ 'with', [ '',
Expand Down