tiny_tds 1.0.4 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +5 -5
  2. data/.codeclimate.yml +20 -0
  3. data/.gitattributes +1 -0
  4. data/.github/workflows/ci.yml +590 -0
  5. data/.gitignore +2 -0
  6. data/.rubocop.yml +31 -0
  7. data/{CHANGELOG → CHANGELOG.md} +133 -26
  8. data/Gemfile +1 -5
  9. data/ISSUE_TEMPLATE.md +36 -3
  10. data/README.md +147 -85
  11. data/Rakefile +51 -94
  12. data/VERSION +1 -1
  13. data/docker-compose.yml +34 -0
  14. data/ext/tiny_tds/client.c +149 -67
  15. data/ext/tiny_tds/client.h +11 -5
  16. data/ext/tiny_tds/extconf.rb +144 -283
  17. data/ext/tiny_tds/extconsts.rb +4 -11
  18. data/ext/tiny_tds/result.c +68 -50
  19. data/ext/tiny_tds/tiny_tds_ext.c +4 -1
  20. data/lib/tiny_tds/bin.rb +44 -40
  21. data/lib/tiny_tds/client.rb +63 -55
  22. data/lib/tiny_tds/error.rb +0 -3
  23. data/lib/tiny_tds/gem.rb +23 -0
  24. data/lib/tiny_tds/result.rb +0 -3
  25. data/lib/tiny_tds.rb +37 -32
  26. data/{ports/patches/freetds/1.00 → patches/freetds/1.00.27}/0001-mingw_missing_inet_pton.diff +4 -4
  27. data/patches/freetds/1.00.27/0002-Don-t-use-MSYS2-file-libws2_32.diff +28 -0
  28. data/patches/libiconv/1.14/1-avoid-gets-error.patch +17 -0
  29. data/setup_cimgruby_dev.sh +25 -0
  30. data/start_dev.sh +21 -0
  31. data/tasks/native_gem.rake +16 -0
  32. data/tasks/package.rake +6 -0
  33. data/tasks/ports.rake +24 -0
  34. data/tasks/test.rake +7 -0
  35. data/test/bin/install-freetds.sh +18 -0
  36. data/test/bin/install-mssql.ps1 +42 -0
  37. data/test/bin/install-mssqltools.sh +9 -0
  38. data/test/bin/install-openssl.sh +18 -0
  39. data/test/bin/restore-from-native-gem.ps1 +10 -0
  40. data/test/bin/setup_tinytds_db.sh +7 -0
  41. data/test/bin/setup_volume_permissions.sh +10 -0
  42. data/test/client_test.rb +161 -112
  43. data/test/gem_test.rb +100 -0
  44. data/test/result_test.rb +293 -313
  45. data/test/schema_test.rb +369 -395
  46. data/test/sql/db-create.sql +18 -0
  47. data/test/sql/db-login.sql +38 -0
  48. data/test/test_helper.rb +116 -85
  49. data/test/thread_test.rb +22 -31
  50. data/tiny_tds.gemspec +27 -24
  51. metadata +109 -56
  52. data/appveyor.yml +0 -51
  53. data/test/appveyor/dbsetup.ps1 +0 -27
  54. data/test/appveyor/dbsetup.sql +0 -9
  55. data/test/benchmark/query.rb +0 -77
  56. data/test/benchmark/query_odbc.rb +0 -106
  57. data/test/benchmark/query_tinytds.rb +0 -126
  58. data/test/schema/sqlserver_2000.sql +0 -140
  59. data/test/schema/sqlserver_2005.sql +0 -140
  60. data/test/schema/sqlserver_2014.sql +0 -140
  61. data/test/schema/sybase_ase.sql +0 -138
  62. /data/bin/{defncopy → defncopy-ttds} +0 -0
  63. /data/bin/{tsql → tsql-ttds} +0 -0
  64. /data/test/schema/{sqlserver_2008.sql → sqlserver_2017.sql} +0 -0
@@ -1,329 +1,190 @@
1
- ENV['RC_ARCHS'] = '' if RUBY_PLATFORM =~ /darwin/
2
-
3
- # :stopdoc:
4
-
5
- require 'mkmf'
6
- require 'fileutils'
7
-
8
- # The gem version constraint in the gemspec is not respected at install time.
9
- # Keep this version in sync with the one in the gemspec !
10
- gem 'mini_portile2', '~> 2.0'
11
- require 'mini_portile2'
12
- require_relative './extconsts'
13
-
14
- OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
15
-
16
- # Shamelessly copied from nokogiri
17
- #
18
-
19
- def do_help
20
- print <<HELP
21
- usage: ruby #{$0} [options]
22
-
23
- --enable-system-freetds / --disable-system-freetds
24
- --enable-system-iconv / --disable-system-iconv
25
- --enable-system-openssl / --disable-system-openssl
26
- Force use of system or builtin freetds/iconv/openssl library.
27
- Default is to prefer system libraries and fallback to builtin.
28
-
29
- --with-freetds-dir=DIR
30
- Use the freetds library placed under DIR.
31
-
32
- --enable-lookup
33
- Search for freetds through all paths in the PATH environment variable.
34
-
35
- --disable-openssl
36
- Disable OpenSSL for freetds build. No effect on system-freetds.
37
-
38
- --enable-gnutls
39
- Use GnuTLS instead of OpenSSL for freetds build.
40
-
41
- --enable-cross-build
42
- Do cross-build.
43
- HELP
44
- exit! 0
45
- end
46
-
47
- do_help if arg_config('--help')
48
-
49
- FREETDSDIR = ENV['FREETDS_DIR']
50
-
51
- if FREETDSDIR.nil? || FREETDSDIR.empty?
52
- LIBDIR = RbConfig::CONFIG['libdir']
53
- INCLUDEDIR = RbConfig::CONFIG['includedir']
54
- else
55
- puts "Will use #{FREETDSDIR}"
56
- LIBDIR = "#{FREETDSDIR}/lib"
57
- INCLUDEDIR = "#{FREETDSDIR}/include"
58
- end
59
-
60
- $CFLAGS << " #{ENV["CFLAGS"]}"
61
- $LDFLAGS << " #{ENV["LDFLAGS"]}"
62
- $LIBS << " #{ENV["LIBS"]}"
63
-
64
- SEARCHABLE_PATHS = begin
65
- eop_regexp = /#{File::SEPARATOR}bin$/
66
- paths = ENV['PATH']
67
- paths = paths.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
68
- paths = paths.split(File::PATH_SEPARATOR)
69
- bin_paths = paths.select{ |p| p =~ eop_regexp }
70
- bin_paths.map{ |p| p.sub(eop_regexp,'') }.compact.reject{ |p| p.empty? }.uniq
1
+ require "mkmf"
2
+ require_relative "extconsts"
3
+
4
+ if ENV["MAINTAINER_MODE"]
5
+ warn "Maintainer mode enabled."
6
+ $CFLAGS << # standard:disable Style/GlobalVars
7
+ " -Wall" \
8
+ " -ggdb" \
9
+ " -DDEBUG" \
10
+ " -pedantic"
11
+ $LDFLAGS << # standard:disable Style/GlobalVars
12
+ " -ggdb"
71
13
  end
72
14
 
73
- def searchable_paths_with_directories(*directories)
74
- SEARCHABLE_PATHS.map do |path|
75
- directories.map do |paths|
76
- dir = File.join path, *paths
77
- File.directory?(dir) ? dir : nil
78
- end.flatten.compact
79
- end.flatten.compact
80
- end
15
+ if (gem_platform = with_config("cross-build"))
16
+ require "mini_portile2"
81
17
 
82
- class BuildRecipe < MiniPortile
83
- def initialize(name, version, files)
84
- super(name, version)
85
- self.files = files
86
- self.target = File.expand_path('../../../ports', __FILE__)
87
- self.host = consolidated_host(RbConfig::CONFIG["host"])
88
- self.patch_files = Dir[File.join(self.target, "patches", self.name, self.version, "*.diff")].sort
89
- end
18
+ openssl_platform = with_config("openssl-platform")
90
19
 
91
- def consolidated_host(name)
92
- # Host name and prefix of build tools are different on Windows 32 bit.
93
- name.gsub('i686-pc-mingw32', 'i686-w64-mingw32')
94
- end
20
+ class BuildRecipe < MiniPortile
21
+ attr_accessor :gem_platform
95
22
 
96
- def configure_defaults
97
- [
98
- "--host=#{host}", # build for specific target (host)
99
- "--disable-static",
100
- "--enable-shared",
101
- ]
102
- end
103
-
104
- # Use the same path for all recipes, so that only one include/lib path is required.
105
- def port_path
106
- "#{target}/#{host}"
107
- end
108
-
109
- # We use the same port_path for all recipes. That breaks the standard installed? method.
110
- def installed?
111
- false
112
- end
23
+ def initialize(name, version, files)
24
+ super(name, version)
25
+ self.files = files
26
+ rootdir = File.expand_path("../../..", __FILE__)
27
+ self.target = File.join(rootdir, "ports")
28
+ self.patch_files = Dir[File.join("patches", self.name, self.version, "*.patch")].sort
29
+ end
113
30
 
114
- # When using rake-compiler-dock on Windows, the underlying Virtualbox shared
115
- # folders don't support symlinks, but libiconv expects it for a build on
116
- # Linux. We work around this limitation by using the temp dir for cooking.
117
- def chdir_for_build
118
- build_dir = ENV['RCD_HOST_RUBY_PLATFORM'].to_s =~ /mingw|mswin|cygwin/ ? '/tmp' : '.'
119
- Dir.chdir(build_dir) do
120
- yield
31
+ # this will yield all ports into the same directory, making our path configuration for the linker easier
32
+ def port_path
33
+ "#{@target}/#{gem_platform}"
121
34
  end
122
- end
123
35
 
124
- def cook_and_activate
125
- checkpoint = File.join(self.target, "#{self.name}-#{self.version}-#{self.host}.installed")
126
- unless File.exist?(checkpoint)
127
- chdir_for_build do
128
- self.cook
36
+ def cook_and_activate
37
+ checkpoint = File.join(target, "#{name}-#{version}-#{gem_platform}.installed")
38
+
39
+ unless File.exist?(checkpoint)
40
+ cook
41
+ FileUtils.touch checkpoint
129
42
  end
130
- FileUtils.touch checkpoint
43
+
44
+ activate
45
+ self
131
46
  end
132
- self.activate
133
- self
134
47
  end
135
- end
136
48
 
137
- def define_libssl_recipe(host)
138
- BuildRecipe.new("openssl", OPENSSL_VERSION, [OPENSSL_SOURCE_URI]).tap do |recipe|
49
+ openssl_recipe = BuildRecipe.new("openssl", OPENSSL_VERSION, [OPENSSL_SOURCE_URI]).tap do |recipe|
139
50
  class << recipe
140
- def extract_file(file, target)
141
- filename = File.basename(file)
142
- FileUtils.mkdir_p target
143
-
144
- message "Extracting #{filename} into #{target}... "
145
- result = `#{tar_exe} #{tar_compression_switch(filename)}xf "#{file}" -C "#{target}" 2>&1`
146
- if $?.success?
147
- output "OK"
148
- else
149
- # tar on windows returns error exit code, because it can not extract symlinks
150
- output "ERROR (ignored)"
151
- end
152
- end
51
+ attr_accessor :openssl_platform
153
52
 
154
53
  def configure
155
- config = if host=~/mingw/
156
- host=~/x86_64/ ? 'mingw64' : 'mingw'
157
- end
158
- args = [ "CFLAGS=-DDSO_WIN32",
159
- "./Configure",
160
- "no-shared",
161
- configure_prefix,
162
- config,
163
- ]
164
- args.unshift("CROSS_COMPILE=#{host}-") if enable_config("cross-build")
165
-
166
- execute "configure", "sh -c \"#{args.join(" ")}\""
54
+ envs = []
55
+ envs << "CFLAGS=-DDSO_WIN32 -DOPENSSL_THREADS" if MiniPortile.windows?
56
+ envs << "CFLAGS=-fPIC -DOPENSSL_THREADS" if MiniPortile.linux?
57
+ execute("configure", ["env", *envs, "./Configure", openssl_platform, "threads", "-static", "CROSS_COMPILE=#{host}-", configure_prefix, "--libdir=lib"], altlog: "config.log")
167
58
  end
168
59
 
169
60
  def compile
170
- super
171
- # OpenSSL DLLs are called "libeay32.dll" and "ssleay32.dll" per default,
172
- # regardless to the version. This is best suited to meet the Windows DLL hell.
173
- # To avoid any conflicts we do a static build and build DLLs afterwards,
174
- # with our own naming scheme.
175
- execute "mkdef-libeay32", "(perl util/mkdef.pl 32 libeay >libeay32.def)"
176
- execute "mkdef-ssleay32", "(perl util/mkdef.pl 32 ssleay >ssleay32.def)"
177
- dllwrap = consolidated_host(RbConfig::CONFIG["DLLWRAP"])
178
- execute "dllwrap-libeay32", "#{dllwrap} --dllname libeay32-#{version}-#{host}.dll --output-lib libcrypto.dll.a --def libeay32.def libcrypto.a -lwsock32 -lgdi32 -lcrypt32"
179
- execute "dllwrap-ssleay32", "#{dllwrap} --dllname ssleay32-#{version}-#{host}.dll --output-lib libssl.dll.a --def ssleay32.def libssl.a libcrypto.dll.a"
61
+ execute("compile", "#{make_cmd} build_libs")
180
62
  end
181
63
 
182
64
  def install
183
- super
184
- FileUtils.cp "#{work_path}/libeay32-#{version}-#{host}.dll", "#{path}/bin/"
185
- FileUtils.cp "#{work_path}/ssleay32-#{version}-#{host}.dll", "#{path}/bin/"
186
- FileUtils.cp "#{work_path}/libcrypto.dll.a", "#{path}/lib/"
187
- FileUtils.cp "#{work_path}/libssl.dll.a", "#{path}/lib/"
65
+ execute("install", "#{make_cmd} install_dev")
188
66
  end
189
67
  end
68
+
69
+ recipe.gem_platform = gem_platform
70
+ recipe.openssl_platform = openssl_platform
71
+ recipe.cook_and_activate
190
72
  end
191
- end
192
73
 
193
- def define_libiconv_recipe(host)
194
- BuildRecipe.new("libiconv", ICONV_VERSION, [ICONV_SOURCE_URI]).tap do |recipe|
195
- # always produce position independent code
196
- recipe.configure_options << "CFLAGS=-fPIC"
74
+ libiconv_recipe = BuildRecipe.new("libiconv", ICONV_VERSION, [ICONV_SOURCE_URI]).tap do |recipe|
75
+ recipe.configure_options << "CFLAGS=-fPIC" if MiniPortile.linux?
76
+ recipe.gem_platform = gem_platform
77
+
78
+ recipe.cook_and_activate
197
79
  end
198
- end
199
80
 
200
- def define_freetds_recipe(host, libiconv, libssl, gnutls)
201
- BuildRecipe.new("freetds", FREETDS_VERSION, [FREETDS_SOURCE_URI]).tap do |recipe|
202
- with_tdsver = FREETDS_VERSION =~ /0\.91/ ? "--with-tdsver=7.1" : "--with-tdsver=7.3"
203
- for_windows = recipe.host =~ /mswin|mingw/i
204
- recipe.configure_options << '--with-pic'
205
- recipe.configure_options << "--with-libiconv-prefix=#{libiconv.path}" if libiconv
206
- if true == libssl
207
- recipe.configure_options << "--with-openssl"
208
- elsif libssl
209
- recipe.configure_options << "--with-openssl=#{libssl.path}"
210
- end
211
- recipe.configure_options << "--with-gnutls" if gnutls
212
- recipe.configure_options << '--sysconfdir=C:\Sites' if for_windows
213
- recipe.configure_options << '--enable-sspi' if for_windows
214
- recipe.configure_options << "--disable-odbc"
215
- recipe.configure_options << with_tdsver
216
- if libiconv
217
- # For some reason freetds doesn't honor --with-libiconv-prefix
218
- # so we have do add it by hand:
219
- recipe.configure_options << "CFLAGS=-I#{libiconv.path}/include"
220
- recipe.configure_options << "LDFLAGS=-L#{libiconv.path}/lib -liconv"
221
- end
81
+ # remove the ".la" files, otherwise libtool starts to complain when linking into FreeTDS
82
+ Dir.glob(File.join(libiconv_recipe.path, "lib", "**", "*.la")).each do |la_file|
83
+ File.delete(la_file)
84
+ end
222
85
 
86
+ freetds_recipe = BuildRecipe.new("freetds", FREETDS_VERSION, [FREETDS_SOURCE_URI]).tap do |recipe|
223
87
  class << recipe
224
-
225
- def install
226
- super_value = super
227
- # Install binstub target binaries.
228
- if super_value
229
- bin_path = File.expand_path File.join(path, 'bin')
230
- exe_path = File.expand_path File.join(target, '..', 'exe')
231
- return unless File.directory?(bin_path)
232
- ['tsql', 'defncopy'].each do |bin|
233
- ['.exe', ''].each do |ext|
234
- exe = File.join bin_path, "#{bin}#{ext}"
235
- next unless File.exists?(exe)
236
- next unless File.executable?(exe)
237
- FileUtils.cp exe, exe_path
238
- end
239
- end
240
- end
241
- super_value
88
+ def configure_defaults
89
+ [
90
+ "--host=#{@host}",
91
+ "--enable-shared",
92
+ "--disable-static",
93
+ "--disable-odbc"
94
+ ]
242
95
  end
96
+ end
243
97
 
98
+ # i am not 100% what is going on behind the scenes
99
+ # it seems that FreeTDS build system prefers OPENSSL_CFLAGS and OPENSSL_LIBS
100
+ # but the linker still relies on LIBS and CPPFLAGS
101
+ # removing one or the other leads to build failures in any case of FreeTDS
102
+ if MiniPortile.linux?
103
+ recipe.configure_options << "CFLAGS=-fPIC"
104
+ elsif MiniPortile.windows?
105
+ recipe.configure_options << "--enable-sspi"
244
106
  end
245
107
 
108
+ # pass an additional runtime path to the linker so defncopy and tsql can find our shared sybdb
109
+ recipe.configure_options << "LDFLAGS=-L#{openssl_recipe.path}/lib #{"-Wl,-rpath='$$ORIGIN/../lib'" if MiniPortile.linux?}"
110
+ recipe.configure_options << "LIBS=-liconv -lssl -lcrypto #{"-lwsock32 -lgdi32 -lws2_32 -lcrypt32" if MiniPortile.windows?} #{"-ldl -lpthread" if MiniPortile.linux?}"
111
+ recipe.configure_options << "CPPFLAGS=-I#{openssl_recipe.path}/include"
112
+
113
+ recipe.configure_options << "OPENSSL_CFLAGS=-L#{openssl_recipe.path}/lib"
114
+ recipe.configure_options << "OPENSSL_LIBS=-lssl -lcrypto #{"-lwsock32 -lgdi32 -lws2_32 -lcrypt32" if MiniPortile.windows?} #{"-ldl -lpthread" if MiniPortile.linux?}"
115
+
116
+ recipe.configure_options << "--with-openssl=#{openssl_recipe.path}"
117
+ recipe.configure_options << "--with-libiconv-prefix=#{libiconv_recipe.path}"
118
+ recipe.configure_options << "--sysconfdir=C:/Sites" if MiniPortile.windows?
119
+
120
+ recipe.gem_platform = gem_platform
121
+ recipe.cook_and_activate
246
122
  end
247
- end
248
123
 
249
- if RbConfig::CONFIG['target_os'] =~ /mswin32|mingw32/
250
- lib_prefix = 'lib' unless RbConfig::CONFIG['target_os'] =~ /mingw32/
251
- # There's no default include/lib dir on Windows. Let's just add the Ruby ones
252
- # and resort on the search path specified by INCLUDE and LIB environment
253
- # variables
254
- HEADER_DIRS = [INCLUDEDIR]
255
- LIB_DIRS = [LIBDIR]
124
+ # enable relative path to later load the FreeTDS shared library
125
+ $LDFLAGS << " '-Wl,-rpath=$$ORIGIN/../../../ports/#{gem_platform}/lib'" # standard:disable Style/GlobalVars
126
+
127
+ dir_config("freetds", "#{freetds_recipe.path}/include", "#{freetds_recipe.path}/lib")
256
128
  else
257
- lib_prefix = ''
258
- HEADER_DIRS = [
259
- # First search /opt/local for macports
260
- '/opt/local/include',
261
- # Then search /usr/local for people that installed from source
262
- '/usr/local/include',
263
- # Check the ruby install locations
264
- INCLUDEDIR,
265
- # Finally fall back to /usr
266
- '/usr/include'
267
- ].reject{ |dir| !File.directory?(dir) }
268
- LIB_DIRS = [
269
- # First search /opt/local for macports
270
- '/opt/local/lib',
271
- # Then search /usr/local for people that installed from source
272
- '/usr/local/lib',
273
- # Check the ruby install locations
274
- LIBDIR,
275
- # Finally fall back to /usr
276
- '/usr/lib',
277
- ].reject{ |dir| !File.directory?(dir) }
278
- end
129
+ # Make sure to check the ports path for the configured host
130
+ architecture = RbConfig::CONFIG["arch"]
131
+
132
+ project_dir = File.expand_path("../../..", __FILE__)
133
+ freetds_ports_dir = File.join(project_dir, "ports", architecture, "freetds", FREETDS_VERSION)
134
+ freetds_ports_dir = File.expand_path(freetds_ports_dir)
135
+
136
+ # Add all the special path searching from the original tiny_tds build
137
+ # order is important here! First in, first searched.
138
+ DIRS = %w[
139
+ /opt/local
140
+ /usr/local
141
+ ]
142
+
143
+ if /darwin/i.match?(RbConfig::CONFIG["host_os"])
144
+ # Ruby below 2.7 seems to label the host CPU on Apple Silicon as aarch64
145
+ # 2.7 and above print is as ARM64
146
+ target_host_cpu = (Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.7")) ? "aarch64" : "arm64"
147
+
148
+ if RbConfig::CONFIG["host_cpu"] == target_host_cpu
149
+ # Homebrew on Apple Silicon installs into /opt/hombrew
150
+ # https://docs.brew.sh/Installation
151
+ # On Intel Macs, it is /usr/local, so no changes necessary to DIRS
152
+ DIRS.unshift("/opt/homebrew")
153
+ end
154
+ end
279
155
 
280
- FREETDS_HEADER_DIRS = (searchable_paths_with_directories(['include'],['include','freetds']) + HEADER_DIRS).uniq
281
- FREETDS_LIB_DIRS = (searchable_paths_with_directories(['lib'],['lib','freetds']) + LIB_DIRS).uniq
156
+ if ENV["RI_DEVKIT"] && ENV["MINGW_PREFIX"] # RubyInstaller Support
157
+ DIRS.unshift(File.join(ENV["RI_DEVKIT"], ENV["MINGW_PREFIX"]))
158
+ end
282
159
 
283
- # lookup over searchable paths is great for native compilation, however, when
284
- # cross compiling we need to specify our own paths.
285
- if enable_config("lookup", true)
286
- dir_config('freetds', FREETDS_HEADER_DIRS, FREETDS_LIB_DIRS)
287
- else
288
- dir_config('freetds')
160
+ # Add the ports directory if it exists for local developer builds
161
+ DIRS.unshift(freetds_ports_dir) if File.directory?(freetds_ports_dir)
289
162
 
290
- # remove LDFLAGS
291
- $LDFLAGS = ENV.fetch("LDFLAGS", "")
292
- end
163
+ # Grab freetds environment variable for use by people on services like
164
+ # Heroku who they can't easily use bundler config to set directories
165
+ DIRS.unshift(ENV["FREETDS_DIR"]) if ENV.has_key?("FREETDS_DIR")
293
166
 
294
- def asplode(lib)
295
- msg = "-----\n"
296
- msg << "#{lib} is missing.\n"
297
- msg << "Do you have FreeTDS 0.95.80 or higher installed?\n" if lib == 'freetds'
298
- msg << "-----"
299
- abort(msg)
300
- end
167
+ # Add the search paths for freetds configured above
168
+ ldirs = DIRS.flat_map do |path|
169
+ ldir = "#{path}/lib"
170
+ [ldir, "#{ldir}/freetds"]
171
+ end
301
172
 
302
- def freetds_usable?(lib_prefix)
303
- have_header('sybfront.h') && have_header('sybdb.h') &&
304
- find_library("#{lib_prefix}sybdb", 'tdsdbopen') &&
305
- find_library("#{lib_prefix}sybdb", 'dbanydatecrack')
306
- end
173
+ idirs = DIRS.flat_map do |path|
174
+ idir = "#{path}/include"
175
+ [idir, "#{idir}/freetds"]
176
+ end
307
177
 
308
- # We use freetds, when available already, and fallback to compilation of ports
309
- system_freetds = enable_config('system-freetds', ENV['TINYTDS_SKIP_PORTS'] || freetds_usable?(lib_prefix))
310
-
311
- # We expect to have iconv and OpenSSL available on non-Windows systems
312
- host = RbConfig::CONFIG["host"]
313
- system_iconv = enable_config('system-iconv', host =~ /mingw|mswin/ ? false : true)
314
- system_openssl = enable_config('system-openssl', host =~ /mingw|mswin/ ? false : true )
315
- enable_gnutls = enable_config('gnutls', false )
316
- enable_openssl = enable_config('openssl', !enable_gnutls )
317
-
318
- unless system_freetds
319
- libssl = define_libssl_recipe(host).cook_and_activate unless system_openssl
320
- libiconv = define_libiconv_recipe(host).cook_and_activate unless system_iconv
321
- freetds = define_freetds_recipe(host, libiconv, libssl || enable_openssl, enable_gnutls).cook_and_activate
322
- dir_config('freetds', freetds.path + "/include", freetds.path + "/lib")
178
+ puts "looking for freetds headers in the following directories:\n#{idirs.map { |a| " - #{a}\n" }.join}"
179
+ puts "looking for freetds library in the following directories:\n#{ldirs.map { |a| " - #{a}\n" }.join}"
180
+ dir_config("freetds", idirs, ldirs)
323
181
  end
324
182
 
325
- asplode 'freetds' unless freetds_usable?(lib_prefix)
183
+ find_header("sybfront.h") or abort "Can't find the 'sybfront.h' header"
184
+ find_header("sybdb.h") or abort "Can't find the 'sybdb.h' header"
326
185
 
327
- create_makefile('tiny_tds/tiny_tds')
186
+ unless have_library("sybdb", "dbanydatecrack")
187
+ abort "Failed! Do you have FreeTDS 1.0.0 or higher installed?"
188
+ end
328
189
 
329
- # :startdoc:
190
+ create_makefile("tiny_tds/tiny_tds")
@@ -1,15 +1,8 @@
1
-
2
- ICONV_VERSION = ENV['TINYTDS_ICONV_VERSION'] || "1.14"
1
+ ICONV_VERSION = ENV["TINYTDS_ICONV_VERSION"] || "1.18"
3
2
  ICONV_SOURCE_URI = "http://ftp.gnu.org/pub/gnu/libiconv/libiconv-#{ICONV_VERSION}.tar.gz"
4
3
 
5
- OPENSSL_VERSION = ENV['TINYTDS_OPENSSL_VERSION'] || '1.0.2g'
4
+ OPENSSL_VERSION = ENV["TINYTDS_OPENSSL_VERSION"] || "3.4.0"
6
5
  OPENSSL_SOURCE_URI = "https://www.openssl.org/source/openssl-#{OPENSSL_VERSION}.tar.gz"
7
6
 
8
- FREETDS_VERSION = ENV['TINYTDS_FREETDS_VERSION'] || "1.00"
9
- FREETDS_VERSION_INFO = Hash.new { |h,k|
10
- h[k] = {files: "ftp://ftp.freetds.org/pub/freetds/stable/freetds-#{k}.tar.bz2"}
11
- }
12
- FREETDS_VERSION_INFO['1.00'] = {files: 'ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.00.tar.bz2'}
13
- FREETDS_VERSION_INFO['0.99'] = {files: 'ftp://ftp.freetds.org/pub/freetds/current/freetds-dev.0.99.678.tar.gz'}
14
- FREETDS_VERSION_INFO['0.95'] = {files: 'ftp://ftp.freetds.org/pub/freetds/stable/freetds-0.95.92.tar.gz'}
15
- FREETDS_SOURCE_URI = FREETDS_VERSION_INFO[FREETDS_VERSION][:files]
7
+ FREETDS_VERSION = ENV["TINYTDS_FREETDS_VERSION"] || "1.4.26"
8
+ FREETDS_SOURCE_URI = "http://www.freetds.org/files/stable/freetds-#{FREETDS_VERSION}.tar.bz2"