tiny_tds 1.0.4 → 2.1.5

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 (51) hide show
  1. checksums.yaml +5 -5
  2. data/.codeclimate.yml +20 -0
  3. data/.gitattributes +1 -0
  4. data/.rubocop.yml +31 -0
  5. data/.travis.yml +25 -0
  6. data/{CHANGELOG → CHANGELOG.md} +102 -26
  7. data/Gemfile +4 -1
  8. data/ISSUE_TEMPLATE.md +35 -2
  9. data/README.md +131 -56
  10. data/Rakefile +31 -88
  11. data/VERSION +1 -1
  12. data/appveyor.yml +38 -17
  13. data/docker-compose.yml +22 -0
  14. data/ext/tiny_tds/client.c +147 -60
  15. data/ext/tiny_tds/client.h +11 -5
  16. data/ext/tiny_tds/extconf.rb +41 -297
  17. data/ext/tiny_tds/extconsts.rb +7 -7
  18. data/ext/tiny_tds/result.c +40 -15
  19. data/lib/tiny_tds/bin.rb +45 -27
  20. data/lib/tiny_tds/client.rb +46 -34
  21. data/lib/tiny_tds/error.rb +0 -1
  22. data/lib/tiny_tds/gem.rb +32 -0
  23. data/lib/tiny_tds/result.rb +2 -3
  24. data/lib/tiny_tds/version.rb +1 -1
  25. data/lib/tiny_tds.rb +38 -14
  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/tasks/native_gem.rake +14 -0
  30. data/tasks/package.rake +8 -0
  31. data/tasks/ports/freetds.rb +37 -0
  32. data/tasks/ports/libiconv.rb +43 -0
  33. data/tasks/ports/openssl.rb +62 -0
  34. data/tasks/ports/recipe.rb +52 -0
  35. data/tasks/ports.rake +85 -0
  36. data/tasks/test.rake +9 -0
  37. data/test/appveyor/dbsetup.ps1 +1 -1
  38. data/test/bin/install-freetds.sh +20 -0
  39. data/test/bin/install-openssl.sh +18 -0
  40. data/test/bin/setup.sh +19 -0
  41. data/test/client_test.rb +124 -66
  42. data/test/gem_test.rb +179 -0
  43. data/test/result_test.rb +128 -42
  44. data/test/schema/sqlserver_2016.sql +140 -0
  45. data/test/schema_test.rb +23 -23
  46. data/test/test_helper.rb +65 -7
  47. data/test/thread_test.rb +1 -1
  48. data/tiny_tds.gemspec +9 -7
  49. metadata +60 -20
  50. /data/bin/{defncopy → defncopy-ttds} +0 -0
  51. /data/bin/{tsql → tsql-ttds} +0 -0
@@ -1,21 +1,20 @@
1
1
  module TinyTds
2
2
  class Client
3
3
 
4
- @@default_query_options = {
5
- :as => :hash,
6
- :symbolize_keys => false,
7
- :cache_rows => true,
8
- :timezone => :local,
9
- :empty_sets => true
4
+ @default_query_options = {
5
+ as: :hash,
6
+ symbolize_keys: false,
7
+ cache_rows: true,
8
+ timezone: :local,
9
+ empty_sets: true
10
10
  }
11
11
 
12
12
  attr_reader :query_options
13
+ attr_reader :message_handler
13
14
 
14
15
  class << self
15
16
 
16
- def default_query_options
17
- @@default_query_options
18
- end
17
+ attr_reader :default_query_options
19
18
 
20
19
  # Most, if not all, iconv encoding names can be found by ruby. Just in case, you can
21
20
  # overide this method to return a string name that Encoding.find would work with. Default
@@ -25,21 +24,39 @@ module TinyTds
25
24
  encoding
26
25
  end
27
26
 
27
+ def local_offset
28
+ ::Time.local(2010).utc_offset.to_r / 86_400
29
+ end
30
+
28
31
  end
29
32
 
33
+ # rubocop:disable Metrics/AbcSize
34
+ # rubocop:disable Metrics/MethodLength
35
+ # rubocop:disable Metrics/CyclomaticComplexity
36
+ # rubocop:disable Metrics/PerceivedComplexity
37
+ def initialize(opts = {})
38
+ if opts[:dataserver].to_s.empty? && opts[:host].to_s.empty?
39
+ raise ArgumentError, 'missing :host option if no :dataserver given'
40
+ end
41
+
42
+ @message_handler = opts[:message_handler]
43
+ if @message_handler && !@message_handler.respond_to?(:call)
44
+ raise ArgumentError, ':message_handler must implement `call` (eg, a Proc or a Method)'
45
+ end
30
46
 
31
- def initialize(opts={})
32
- raise ArgumentError, 'missing :host option if no :dataserver given' if opts[:dataserver].to_s.empty? && opts[:host].to_s.empty?
33
47
  opts[:username] = parse_username(opts)
34
- @query_options = @@default_query_options.dup
48
+ @query_options = self.class.default_query_options.dup
35
49
  opts[:password] = opts[:password].to_s if opts[:password] && opts[:password].to_s.strip != ''
36
50
  opts[:appname] ||= 'TinyTds'
37
51
  opts[:tds_version] = tds_versions_setter(opts)
52
+ opts[:use_utf16] = opts[:use_utf16].nil? || ["true", "1", "yes"].include?(opts[:use_utf16].to_s)
38
53
  opts[:login_timeout] ||= 60
39
54
  opts[:timeout] ||= 5
40
- opts[:encoding] = (opts[:encoding].nil? || opts[:encoding].downcase == 'utf8') ? 'UTF-8' : opts[:encoding].upcase
55
+ opts[:encoding] = opts[:encoding].nil? || opts[:encoding].casecmp('utf8').zero? ? 'UTF-8' : opts[:encoding].upcase
41
56
  opts[:port] ||= 1433
42
57
  opts[:dataserver] = "#{opts[:host]}:#{opts[:port]}" if opts[:dataserver].to_s.empty?
58
+ forced_integer_keys = [:login_timeout, :port, :timeout]
59
+ forced_integer_keys.each { |k| opts[k] = opts[k].to_i if opts[k] }
43
60
  connect(opts)
44
61
  end
45
62
 
@@ -56,24 +73,19 @@ module TinyTds
56
73
  !closed? && !dead?
57
74
  end
58
75
 
59
-
60
76
  private
61
77
 
62
- def self.local_offset
63
- ::Time.local(2010).utc_offset.to_r / 86400
64
- end
65
-
66
78
  def parse_username(opts)
67
79
  host = opts[:host]
68
80
  username = opts[:username]
69
81
  return username if username.nil? || !opts[:azure]
70
- return username if username.include?("@") && !username.include?("database.windows.net")
71
- user, domain = username.split("@")
82
+ return username if username.include?('@') && !username.include?('database.windows.net')
83
+ user, domain = username.split('@')
72
84
  domain ||= host
73
85
  "#{user}@#{domain.split('.').first}"
74
86
  end
75
87
 
76
- def tds_versions_setter(opts={})
88
+ def tds_versions_setter(opts = {})
77
89
  v = opts[:tds_version] || ENV['TDSVER'] || '7.3'
78
90
  TDS_VERSIONS_SETTERS[v.to_s]
79
91
  end
@@ -105,19 +117,19 @@ module TinyTds
105
117
  # The integer values of the constants are poorly chosen.
106
118
  #
107
119
  TDS_VERSIONS_GETTERS = {
108
- 0 => {:name => 'DBTDS_UNKNOWN', :description => 'Unknown'},
109
- 1 => {:name => 'DBTDS_2_0', :description => 'Pre 4.0 SQL Server'},
110
- 2 => {:name => 'DBTDS_3_4', :description => 'Microsoft SQL Server (3.0)'},
111
- 3 => {:name => 'DBTDS_4_0', :description => '4.0 SQL Server'},
112
- 4 => {:name => 'DBTDS_4_2', :description => '4.2 SQL Server'},
113
- 5 => {:name => 'DBTDS_4_6', :description => '2.0 OpenServer and 4.6 SQL Server.'},
114
- 6 => {:name => 'DBTDS_4_9_5', :description => '4.9.5 (NCR) SQL Server'},
115
- 7 => {:name => 'DBTDS_5_0', :description => '5.0 SQL Server'},
116
- 8 => {:name => 'DBTDS_7_0', :description => 'Microsoft SQL Server 7.0'},
117
- 9 => {:name => 'DBTDS_7_1/DBTDS_8_0', :description => 'Microsoft SQL Server 2000'},
118
- 10 => {:name => 'DBTDS_7_2/DBTDS_9_0', :description => 'Microsoft SQL Server 2005'},
119
- 11 => {:name => 'DBTDS_7_3', :description => 'Microsoft SQL Server 2008'},
120
- 12 => {:name => 'DBTDS_7_4', :description => 'Microsoft SQL Server 2012/2014'}
120
+ 0 => { name: 'DBTDS_UNKNOWN', description: 'Unknown' },
121
+ 1 => { name: 'DBTDS_2_0', description: 'Pre 4.0 SQL Server' },
122
+ 2 => { name: 'DBTDS_3_4', description: 'Microsoft SQL Server (3.0)' },
123
+ 3 => { name: 'DBTDS_4_0', description: '4.0 SQL Server' },
124
+ 4 => { name: 'DBTDS_4_2', description: '4.2 SQL Server' },
125
+ 5 => { name: 'DBTDS_4_6', description: '2.0 OpenServer and 4.6 SQL Server.' },
126
+ 6 => { name: 'DBTDS_4_9_5', description: '4.9.5 (NCR) SQL Server' },
127
+ 7 => { name: 'DBTDS_5_0', description: '5.0 SQL Server' },
128
+ 8 => { name: 'DBTDS_7_0', description: 'Microsoft SQL Server 7.0' },
129
+ 9 => { name: 'DBTDS_7_1/DBTDS_8_0', description: 'Microsoft SQL Server 2000' },
130
+ 10 => { name: 'DBTDS_7_2/DBTDS_9_0', description: 'Microsoft SQL Server 2005' },
131
+ 11 => { name: 'DBTDS_7_3', description: 'Microsoft SQL Server 2008' },
132
+ 12 => { name: 'DBTDS_7_4', description: 'Microsoft SQL Server 2012/2014' }
121
133
  }.freeze
122
134
 
123
135
  end
@@ -10,6 +10,5 @@ module TinyTds
10
10
  @os_error_number = nil
11
11
  end
12
12
 
13
-
14
13
  end
15
14
  end
@@ -0,0 +1,32 @@
1
+ require 'rbconfig'
2
+
3
+ module TinyTds
4
+ module Gem
5
+ class << self
6
+ def root_path
7
+ File.expand_path '../../..', __FILE__
8
+ end
9
+
10
+ def ports_root_path
11
+ File.join(root_path,'ports')
12
+ end
13
+
14
+ def ports_bin_paths
15
+ Dir.glob(File.join(ports_root_path,ports_host,'**','bin'))
16
+ end
17
+
18
+ def ports_lib_paths
19
+ Dir.glob(File.join(ports_root_path,ports_host,'**','lib'))
20
+ end
21
+
22
+ def ports_host
23
+ h = RbConfig::CONFIG['host']
24
+
25
+ # Our fat binary builds with a i686-w64-mingw32 toolchain
26
+ # but ruby for windows x32-mingw32 reports i686-pc-mingw32
27
+ # so correct the host here
28
+ h.gsub('i686-pc-mingw32', 'i686-w64-mingw32')
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,8 +1,7 @@
1
1
  module TinyTds
2
2
  class Result
3
-
3
+
4
4
  include Enumerable
5
-
6
-
5
+
7
6
  end
8
7
  end
@@ -1,3 +1,3 @@
1
1
  module TinyTds
2
- VERSION = File.read(File.expand_path("../../../VERSION", __FILE__)).chomp
2
+ VERSION = File.read(File.expand_path('../../../VERSION', __FILE__)).chomp
3
3
  end
data/lib/tiny_tds.rb CHANGED
@@ -7,29 +7,53 @@ require 'tiny_tds/version'
7
7
  require 'tiny_tds/error'
8
8
  require 'tiny_tds/client'
9
9
  require 'tiny_tds/result'
10
+ require 'tiny_tds/gem'
10
11
 
11
12
  # Support multiple ruby versions, fat binaries under Windows.
12
13
  if RUBY_PLATFORM =~ /mingw|mswin/ && RUBY_VERSION =~ /(\d+.\d+)/
13
- ver = $1
14
- # Set the PATH environment variable, so that the DLLs can be found.
15
- old_path = ENV['PATH']
16
- begin
17
- # Do the same host consolidation as in extconf.rb
18
- ports_dir = RbConfig::CONFIG["host"].gsub('i686-pc-mingw32', 'i686-w64-mingw32')
19
- ENV['PATH'] = "#{File.expand_path("../../ports/#{ports_dir}/bin", __FILE__)};#{old_path}"
20
- require "tiny_tds/#{ver}/tiny_tds"
21
- rescue LoadError
22
- require 'tiny_tds/tiny_tds'
23
- ensure
24
- ENV['PATH'] = old_path
14
+ ver = Regexp.last_match(1)
15
+
16
+ add_dll_path = proc do |path, &block|
17
+ begin
18
+ require 'ruby_installer/runtime'
19
+ RubyInstaller::Runtime.add_dll_directory(path, &block)
20
+ rescue LoadError
21
+ old_path = ENV['PATH']
22
+ ENV['PATH'] = "#{path};#{old_path}"
23
+ begin
24
+ block.call
25
+ ensure
26
+ ENV['PATH'] = old_path
27
+ end
28
+ end
29
+ end
30
+
31
+ add_dll_paths = proc do |paths, &block|
32
+ if path=paths.shift
33
+ add_dll_path.call(path) do
34
+ add_dll_paths.call(paths, &block)
35
+ end
36
+ else
37
+ block.call
38
+ end
39
+ end
40
+
41
+ # Temporary add bin directories for DLL search, so that freetds DLLs can be found.
42
+ add_dll_paths.call( TinyTds::Gem.ports_bin_paths ) do
43
+ begin
44
+ require "tiny_tds/#{ver}/tiny_tds"
45
+ rescue LoadError
46
+ require 'tiny_tds/tiny_tds'
47
+ end
25
48
  end
26
49
  else
27
50
  # Load dependent shared libraries into the process, so that they are already present,
28
51
  # when tiny_tds.so is loaded. This ensures, that shared libraries are loaded even when
29
52
  # the path is different between build and run time (e.g. Heroku).
30
- ports_libs = File.expand_path("../../ports/#{RbConfig::CONFIG["host"]}/lib/*.so", __FILE__)
53
+ ports_libs = File.join(TinyTds::Gem.ports_root_path,
54
+ "#{RbConfig::CONFIG['host']}/lib/*.so")
31
55
  Dir[ports_libs].each do |lib|
32
- require "fiddle"
56
+ require 'fiddle'
33
57
  Fiddle.dlopen(lib)
34
58
  end
35
59
 
@@ -1,16 +1,16 @@
1
1
  diff --git a/src/tds/tls.c b/src/tds/tls.c
2
- index 0d11a33..b8ab2ba 100644
2
+ index 09e7fa0..1da18f6 100644
3
3
  --- a/src/tds/tls.c
4
4
  +++ b/src/tds/tls.c
5
- @@ -72,6 +72,29 @@
6
- #define SSL_PTR bio->ptr
5
+ @@ -101,6 +101,29 @@
6
+ #define SSL_PTR BIO_get_data(bio)
7
7
  #endif
8
8
 
9
9
  +/*
10
10
  + * Add a workaround for older Mingw versions without inet_pton().
11
11
  + * This means RubyInstallers DevKit-4.7.2 in particular.
12
12
  + */
13
- +#if defined(__MINGW64_VERSION_MAJOR) && !defined(InetPtonA)
13
+ +#if defined(__MINGW32__) && !defined(InetPtonA)
14
14
  + #include <windows.h>
15
15
  +
16
16
  + static HMODULE ws2_32 = NULL;
@@ -0,0 +1,28 @@
1
+ From 56e8972f66c3e948e2ad6885595c58fd23dcdb37 Mon Sep 17 00:00:00 2001
2
+ From: Lars Kanis <kanis@comcard.de>
3
+ Date: Thu, 6 Jul 2017 17:09:40 +0200
4
+ Subject: [PATCH] Don't use MSYS2 file libws2_32.a for MINGW build
5
+
6
+ This file is intended for MSYS2/cygwin builds and blocks OpenSSL
7
+ detection of freetds on i686.
8
+ ---
9
+ configure | 2 --
10
+ configure.ac | 2 --
11
+ 2 files changed, 4 deletions(-)
12
+
13
+ diff --git a/configure b/configure
14
+ index 9495a49..31eb01d 100644
15
+ --- a/configure
16
+ +++ b/configure
17
+ @@ -15915,8 +15915,6 @@ case $host in
18
+ tds_mingw=yes
19
+ if test "$host_cpu" = "x86_64"; then
20
+ LIBS="-lws2_32"
21
+ - elif test -r /usr/lib/w32api/libws2_32.a; then
22
+ - LIBS="-L/usr/lib/w32api -lws2_32"
23
+ else
24
+ LIBS="-lws2_32"
25
+ fi
26
+ --
27
+ 2.6.2.windows.1
28
+
@@ -0,0 +1,17 @@
1
+ --- a/srclib/stdio.in.h 2017-01-22 01:23:00.000000000 -0400
2
+ +++ b/srclib/stdio.in.h 2017-01-22 01:24:00.000000000 -0400
3
+ @@ -695,8 +695,14 @@
4
+ /* It is very rare that the developer ever has full control of stdin,
5
+ so any use of gets warrants an unconditional warning. Assume it is
6
+ always declared, since it is required by C89. */
7
+ +#if defined(__GLIBC__) && !defined(__UCLIBC__)
8
+ +# ifdef __GLIBC_PREREQ
9
+ +# if !__GLIBC_PREREQ(2, 16)
10
+ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
11
+ +# endif
12
+ +# endif
13
+ +#endif
14
+ #endif
15
+
16
+
17
+ #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
@@ -0,0 +1,14 @@
1
+ # encoding: UTF-8
2
+
3
+ desc 'Build the windows binary gems per rake-compiler-dock'
4
+ task 'gem:windows' => ['ports:cross'] do
5
+ require 'rake_compiler_dock'
6
+
7
+ # make sure to install our bundle
8
+ build = ['bundle']
9
+
10
+ # and finally build the native gem
11
+ build << 'rake cross native gem RUBY_CC_VERSION=2.7.0:2.6.0:2.5.0:2.4.0 CFLAGS="-Wall" MAKE="make -j`nproc`"'
12
+
13
+ RakeCompilerDock.sh build.join(' && ')
14
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: UTF-8
2
+ require 'rubygems/package_task'
3
+
4
+ Gem::PackageTask.new(SPEC) do |pkg|
5
+ pkg.need_tar = false
6
+ pkg.need_zip = false
7
+ end
8
+
@@ -0,0 +1,37 @@
1
+ require_relative './recipe'
2
+
3
+ module Ports
4
+ class Freetds < Recipe
5
+ def initialize(version)
6
+ super('freetds', version)
7
+
8
+ set_patches
9
+ end
10
+
11
+ private
12
+
13
+ def configure_defaults
14
+ opts = super
15
+
16
+ opts << '--with-pic'
17
+ opts << '--disable-odbc'
18
+
19
+ if version =~ /0\.91/
20
+ opts << '--with-tdsver=7.1'
21
+ else
22
+ opts << '--with-tdsver=7.3'
23
+ end
24
+
25
+ if windows?
26
+ opts << '--sysconfdir=C:/Sites'
27
+ opts << '--enable-sspi'
28
+ end
29
+
30
+ opts
31
+ end
32
+
33
+ def set_patches
34
+ self.patch_files.concat get_patches(name, version)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,43 @@
1
+ require_relative './recipe'
2
+
3
+ module Ports
4
+ class Libiconv < Recipe
5
+ def initialize(version)
6
+ super('libiconv', version)
7
+
8
+ set_patches
9
+ end
10
+
11
+ def cook
12
+ chdir_for_build do
13
+ super
14
+ end
15
+ self
16
+ end
17
+
18
+ private
19
+
20
+ # When using rake-compiler-dock on Windows, the underlying Virtualbox shared
21
+ # folders don't support symlinks, but libiconv expects it for a build on
22
+ # Linux. We work around this limitation by using the temp dir for cooking.
23
+ def chdir_for_build
24
+ build_dir = ENV['RCD_HOST_RUBY_PLATFORM'].to_s =~ /mingw|mswin|cygwin/ ? '/tmp' : '.'
25
+ Dir.chdir(build_dir) do
26
+ yield
27
+ end
28
+ end
29
+
30
+ def configure_defaults
31
+ [
32
+ "--host=#{@host}",
33
+ '--disable-static',
34
+ '--enable-shared',
35
+ 'CFLAGS=-fPIC -O2'
36
+ ]
37
+ end
38
+
39
+ def set_patches
40
+ self.patch_files.concat get_patches(name, version)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,62 @@
1
+ require_relative './recipe'
2
+
3
+ module Ports
4
+ class Openssl < Recipe
5
+ def initialize(version)
6
+ super('openssl', version)
7
+
8
+ set_patches
9
+ end
10
+
11
+ def configure
12
+ return if configured?
13
+
14
+ md5_file = File.join(tmp_path, 'configure.md5')
15
+ digest = Digest::MD5.hexdigest(computed_options.to_s)
16
+ File.open(md5_file, "w") { |f| f.write digest }
17
+
18
+ # Windows doesn't recognize the shebang so always explicitly use sh
19
+ execute('configure', "sh -c \"./Configure #{computed_options.join(' ')}\"")
20
+ end
21
+
22
+ def install
23
+ unless installed?
24
+ execute('install', %Q(#{make_cmd} install_sw install_ssldirs))
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def configure_defaults
31
+ opts = [
32
+ 'shared',
33
+ target_arch,
34
+ "--openssldir=#{path}",
35
+ ]
36
+
37
+ if cross_build?
38
+ opts << "--cross-compile-prefix=#{host}-"
39
+ end
40
+
41
+ opts
42
+ end
43
+
44
+ def target_arch
45
+ if windows?
46
+ arch = ''
47
+ arch = '64' if host=~ /x86_64/
48
+
49
+ "mingw#{arch}"
50
+ else
51
+ arch = 'x32'
52
+ arch = 'x86_64' if host=~ /x86_64/
53
+
54
+ "linux-#{arch}"
55
+ end
56
+ end
57
+
58
+ def set_patches
59
+ self.patch_files.concat get_patches(name, version)
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,52 @@
1
+ # encoding: UTF-8
2
+ require 'mini_portile2'
3
+ require 'fileutils'
4
+ require 'rbconfig'
5
+
6
+ module Ports
7
+ class Recipe < MiniPortile
8
+ def cook
9
+ checkpoint = "ports/#{name}-#{version}-#{host}.installed"
10
+
11
+ unless File.exist? checkpoint
12
+ super
13
+ FileUtils.touch checkpoint
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def configure_defaults
20
+ [
21
+ "--host=#{@host}",
22
+ '--disable-static',
23
+ '--enable-shared'
24
+ ]
25
+ end
26
+
27
+ def windows?
28
+ host =~ /mswin|mingw32/
29
+ end
30
+
31
+ def system_host
32
+ RbConfig::CONFIG['host']
33
+ end
34
+
35
+ def cross_build?
36
+ host != system_host
37
+ end
38
+
39
+ def get_patches(libname, version)
40
+ patches = []
41
+
42
+ patch_path = File.expand_path(
43
+ File.join('..','..','..','patches',libname,version),
44
+ __FILE__
45
+ )
46
+
47
+ patches.concat(Dir[File.join(patch_path, '*.patch')].sort)
48
+ patches.concat(Dir[File.join(patch_path, '*.diff')].sort)
49
+ end
50
+ end
51
+ end
52
+
data/tasks/ports.rake ADDED
@@ -0,0 +1,85 @@
1
+ # encoding: UTF-8
2
+ require 'mini_portile2'
3
+ require 'fileutils'
4
+ require_relative 'ports/libiconv'
5
+ require_relative 'ports/openssl'
6
+ require_relative 'ports/freetds'
7
+ require_relative '../ext/tiny_tds/extconsts'
8
+
9
+ namespace :ports do
10
+ openssl = Ports::Openssl.new(OPENSSL_VERSION)
11
+ libiconv = Ports::Libiconv.new(ICONV_VERSION)
12
+ freetds = Ports::Freetds.new(FREETDS_VERSION)
13
+
14
+ directory "ports"
15
+ CLEAN.include "ports/*mingw32*"
16
+ CLEAN.include "ports/*.installed"
17
+
18
+ task :openssl, [:host] do |task, args|
19
+ args.with_defaults(host: RbConfig::CONFIG['host'])
20
+
21
+ openssl.files = [OPENSSL_SOURCE_URI]
22
+ openssl.host = args.host
23
+ openssl.cook
24
+ openssl.activate
25
+ end
26
+
27
+ task :libiconv, [:host] do |task, args|
28
+ args.with_defaults(host: RbConfig::CONFIG['host'])
29
+
30
+ libiconv.files = [ICONV_SOURCE_URI]
31
+ libiconv.host = args.host
32
+ libiconv.cook
33
+ libiconv.activate
34
+ end
35
+
36
+ task :freetds, [:host] do |task, args|
37
+ args.with_defaults(host: RbConfig::CONFIG['host'])
38
+
39
+ freetds.files = [FREETDS_SOURCE_URI]
40
+ freetds.host = args.host
41
+
42
+ if openssl
43
+ # freetds doesn't have an option that will provide an rpath
44
+ # so we do it manually
45
+ ENV['OPENSSL_CFLAGS'] = "-Wl,-rpath -Wl,#{openssl.path}/lib"
46
+ # Add the pkgconfig file with MSYS2'ish path, to prefer our ports build
47
+ # over MSYS2 system OpenSSL.
48
+ ENV['PKG_CONFIG_PATH'] = "#{openssl.path.gsub(/^(\w):/i){"/"+$1.downcase}}/lib/pkgconfig:#{ENV['PKG_CONFIG_PATH']}"
49
+ freetds.configure_options << "--with-openssl=#{openssl.path}"
50
+ end
51
+
52
+ if libiconv
53
+ freetds.configure_options << "--with-libiconv-prefix=#{libiconv.path}"
54
+ end
55
+
56
+ freetds.cook
57
+ freetds.activate
58
+ end
59
+
60
+ task :compile, [:host] do |task,args|
61
+ args.with_defaults(host: RbConfig::CONFIG['host'])
62
+
63
+ puts "Compiling ports for #{args.host}..."
64
+
65
+ ['openssl','libiconv','freetds'].each do |lib|
66
+ Rake::Task["ports:#{lib}"].invoke(args.host)
67
+ end
68
+ end
69
+
70
+ desc 'Build the ports windows binaries via rake-compiler-dock'
71
+ task 'cross' do
72
+ require 'rake_compiler_dock'
73
+
74
+ # build the ports for all our cross compile hosts
75
+ GEM_PLATFORM_HOSTS.each do |gem_platform, host|
76
+ # make sure to install our bundle
77
+ build = ['bundle']
78
+ build << "rake ports:compile[#{host}] MAKE='make -j`nproc`'"
79
+ RakeCompilerDock.sh build.join(' && '), platform: gem_platform
80
+ end
81
+ end
82
+ end
83
+
84
+ desc 'Build ports and activate libraries for the current architecture.'
85
+ task :ports => ['ports:compile']
data/tasks/test.rake ADDED
@@ -0,0 +1,9 @@
1
+ # encoding: UTF-8
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ t.test_files = FileList['test/**/*_test.rb']
7
+ t.verbose = true
8
+ end
9
+
@@ -5,7 +5,7 @@ Write-Output "Setting up..."
5
5
 
6
6
  Write-Output "Setting variables..."
7
7
  $serverName = $env:COMPUTERNAME
8
- $instances = @('SQL2008R2SP2', 'SQL2012SP1', 'SQL2014')
8
+ $instances = @('SQL2012SP1', 'SQL2014', 'SQL2016')
9
9
  $smo = 'Microsoft.SqlServer.Management.Smo.'
10
10
  $wmi = new-object ($smo + 'Wmi.ManagedComputer')
11
11