tiny_tds 0.6.3.rc1 → 0.6.3.rc2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74cf755ff3bd0cfe314ff8df7630ff974787c009
4
- data.tar.gz: 25bab39df87ed93bbbc708e0ae7eae13c032396d
3
+ metadata.gz: 93f0e6a826fc86c7517b4c7735b7d39b46075689
4
+ data.tar.gz: d64e8e16bdb9cbf6c83e427c70aa7a1e70c206f9
5
5
  SHA512:
6
- metadata.gz: 2cff679d4e28c193b6e1eb3228039c7175ba72dd531f4bc78c2f71ff94c117dd873c8b7a512ac7a07f13360ae43053748cfe1b4c35789ccefc8812f903b9014b
7
- data.tar.gz: af9e12104d0bcbd6c6a9e603452db52727186fa7d15d6c8b0b7e900a44cc2858767b087e04af8117d3f886de9e996b3ee10cda1d8d070c916b1972c4a0befa8d
6
+ metadata.gz: 55811f95960940a21c87c4235ab84b910b2ae465c73f06e9eca6305f0486569d7b8ca2c41223ac6b8c499ce55ab4404a5081f168dd9a739c07c77326ed267f62
7
+ data.tar.gz: c654528c4174aee664b40c8a4c281bc51de2df4a697efb7f881a5e0f681b3d88b4e97369ec57471fcbf2adfafe36a8e6c4abb0fa944ddea6d07d3c0ce15120ba
data/.gitignore CHANGED
@@ -16,4 +16,3 @@ Gemfile.lock
16
16
  misc
17
17
  *.gem
18
18
  ports
19
- rake-compiler-dev-box/
data/CHANGELOG CHANGED
@@ -1,6 +1,10 @@
1
1
 
2
2
  * 0.6.3.rc1 *
3
3
 
4
+ * Ensure zero terminated strings, where C-str pointers are expected. Use StringValueCStr() Fixes #208.
5
+
6
+ * Revert 999fa571 so timeouts do not kill the client. Fixes #179.
7
+
4
8
  * Remove `sspi_w_kerberos.diff` patch. Not needed anymore.
5
9
 
6
10
  * Tested again on Azure. Added notes to README on recommended settings.
@@ -0,0 +1,31 @@
1
+ Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all
4
+ people who contribute through reporting issues, posting feature requests,
5
+ updating documentation, submitting pull requests or patches, and other
6
+ activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, or religion.
12
+
13
+ Examples of unacceptable behavior by participants include the use of sexual
14
+ language or imagery, derogatory comments or personal attacks, trolling, public
15
+ or private harassment, insults, or other unprofessional conduct.
16
+
17
+ Project maintainers have the right and responsibility to remove, edit, or
18
+ reject comments, commits, code, wiki edits, issues, and other contributions
19
+ that are not aligned to this Code of Conduct. Project maintainers who do not
20
+ follow the Code of Conduct may be removed from the project team.
21
+
22
+ This code of conduct applies both within project spaces and in public spaces
23
+ when an individual is representing the project or its community.
24
+
25
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
26
+ reported by opening an issue or contacting one or more of the project
27
+ maintainers.
28
+
29
+ This Code of Conduct is adapted from the Contributor Covenant
30
+ (http://contributor-covenant.org), version 1.1.0, available at
31
+ http://contributor-covenant.org/version/1/1/0/
data/README.md CHANGED
@@ -318,27 +318,15 @@ To find out more about the FreeTDS release system [visit this thread](http://lis
318
318
 
319
319
  ## Compiling Gems for Windows
320
320
 
321
- For the convenience of Windows users, TinyTDS ships pre-compiled for Ruby 1.9.3, 2.0 and 2.1 on Windows. In order to generate these gems, [rake-compiler-dev-box](https://github.com/tjschuck/rake-compiler-dev-box) is used. This project provides a [Vagrant](http://www.vagrantup.com/) box with rvm, cross-compilers and a number of different versions of ruby.
321
+ For the convenience of Windows users, TinyTDS ships pre-compiled for Ruby 1.9.3, 2.0, 2.1 and 2.2 on Windows. In order to generate these gems, [rake-compiler-dock](https://github.com/rake-compiler/rake-compiler-dock) is used. This project provides a [Docker image](https://registry.hub.docker.com/u/larskanis/rake-compiler-dock/) with rvm, cross-compilers and a number of different target versions of ruby.
322
322
 
323
- There are a handful of rake tasks that are part of TinyTDS that make cross-compiling simple. Ensure that you have VirtualBox, Vagrant and git installed, and then run the following to download the box and perform initial setup:
323
+ Run the following rake task to compile the gem for Windows. This will check the availability of [Docker](https://www.docker.com/) (and boot2docker on Windows or OS-X) and will give some advice for download and installation. When docker is running, it will download the docker image (once-only) and start the build:
324
324
 
325
325
  ```
326
- $ rake cross-compile:setup
326
+ $ rake gem:windows
327
327
  ```
328
328
 
329
- Once the setup is complete, run the following rake task to compile the gem for Windows. The first time this will take a while since the `rake-compiler` gem will need to compile a few different versions of ruby:
330
-
331
- ```
332
- $ rake cross-compile
333
- ```
334
-
335
- The compiled gems will exist in `./rake-compile-dev-box/tiny_tds/pkg/`.
336
-
337
- If you want to clean up the dependent ports, temp files and resulting gems, run:
338
-
339
- ```
340
- $ rake cross-compile:clean
341
- ```
329
+ The compiled gems will exist in `./pkg/`.
342
330
 
343
331
 
344
332
  ## Development & Testing
@@ -372,7 +360,6 @@ $ rake TINYTDS_SKIP_PORTS=1
372
360
 
373
361
  ## TODO List
374
362
 
375
- * Include OpenSSL with Windows binaries for SQL Azure.
376
363
  * Install an interrupt handler.
377
364
  * Allow #escape to accept all ruby primitives.
378
365
 
data/Rakefile CHANGED
@@ -18,6 +18,20 @@ def test_files
18
18
  end
19
19
  end
20
20
 
21
+ def add_file_to_gem(spec, relative_path)
22
+ target_path = File.join gem_build_path(spec), relative_path
23
+ target_dir = File.dirname(target_path)
24
+ mkdir_p target_dir
25
+ rm_f target_path
26
+ safe_ln relative_path, target_path
27
+ spec.files += [relative_path]
28
+ end
29
+
30
+ def gem_build_path(spec)
31
+ File.join 'pkg', spec.full_name
32
+ end
33
+
34
+
21
35
  gemspec = Gem::Specification::load(File.expand_path('../tiny_tds.gemspec', __FILE__))
22
36
 
23
37
  Rake::TestTask.new do |t|
@@ -31,7 +45,7 @@ Gem::PackageTask.new(gemspec) do |pkg|
31
45
  pkg.need_zip = false
32
46
  end
33
47
 
34
- task :compile => ["ports:freetds"] unless ENV['TINYTDS_SKIP_PORTS']
48
+ task :compile
35
49
 
36
50
  task :build => [:clean, :compile]
37
51
 
@@ -41,71 +55,50 @@ Dir["tasks/*.rake"].sort.each { |f| load f }
41
55
 
42
56
  Rake::ExtensionTask.new('tiny_tds', gemspec) do |ext|
43
57
  ext.lib_dir = 'lib/tiny_tds'
44
- if RUBY_PLATFORM =~ /mswin|mingw/ then
45
- # Define target for extension (supporting fat binaries).
46
- RUBY_VERSION =~ /(\d+\.\d+)/
47
- ext.lib_dir = "lib/tiny_tds/#{$1}"
48
- else
49
- ext.cross_compile = true
50
- ext.cross_platform = []
51
- ext.cross_config_options << "--disable-lookup"
52
- config_opts = {}
58
+ ext.cross_compile = true
59
+ ext.cross_platform = ['x86-mingw32', 'x64-mingw32']
60
+ ext.cross_config_options += %w[ --disable-lookup --enable-cross-build ]
61
+
62
+ # Add dependent DLLs to the cross gems
63
+ ext.cross_compiling do |spec|
53
64
  platform_host_map = {
54
- 'x86-mingw32' => 'i586-mingw32msvc',
65
+ 'x86-mingw32' => 'i686-w64-mingw32',
55
66
  'x64-mingw32' => 'x86_64-w64-mingw32'
56
67
  }
57
- # This section ensures we setup up rake dependencies and that libiconv
58
- # and freetds are compiled using the cross-compiler and then passed to
59
- # extconf.rb in such a way that library detection works.
60
- platform_host_map.each do |plat, host|
61
- ext.cross_platform << plat
62
- libiconv = define_libiconv_recipe(plat, host)
63
- freetds = define_freetds_recipe(plat, host, libiconv)
64
- task "native:#{plat}" => ["ports:freetds:#{plat}"] unless ENV['TINYTDS_SKIP_PORTS']
65
- # For some reason --with-freetds-dir and --with-iconv-dir would not work.
66
- # It seems the default params that extconf.rb constructs include
67
- # --without-freetds-include, --without-freetds-lib, --without-iconv-lib
68
- # and --without-iconv-include. Thus we must explicitly override them.
69
- config_opts[plat] = " --with-freetds-include=#{freetds.path}/include"
70
- config_opts[plat] += " --with-freetds-lib=#{freetds.path}/lib"
71
- config_opts[plat] += " --with-iconv-include=#{libiconv.path}/include"
72
- config_opts[plat] += " --with-iconv-lib=#{libiconv.path}/lib"
68
+
69
+ gemplat = spec.platform.to_s
70
+ host = platform_host_map[gemplat]
71
+
72
+ dlls = [
73
+ "libeay32-1.0.2d-#{host}.dll",
74
+ "ssleay32-1.0.2d-#{host}.dll",
75
+ "libiconv-2.dll",
76
+ "libsybdb-5.dll",
77
+ ]
78
+
79
+ # We don't need the sources in a fat binary gem
80
+ spec.files = spec.files.reject{|f| f=~/^ports\/archives/ }
81
+ spec.files += dlls.map{|dll| "ports/#{host}/bin/#{File.basename(dll)}" }
82
+
83
+ dlls.each do |dll|
84
+ file "ports/#{host}/bin/#{dll}" do |t|
85
+ sh "x86_64-w64-mingw32-strip", t.name
86
+ end
73
87
  end
74
- ext.cross_config_options << config_opts
75
88
  end
76
- end
77
89
 
78
- desc "Checks out rake-compiler-dev-box and sets up the cross-compiling box. This can take a long time."
79
- task 'cross-compile:setup' do
80
- # Make sure we have the command-line programs we need
81
- sh 'git', '--version'
82
- sh 'vagrant', '-v'
83
- if Dir.exists? 'rake-compiler-dev-box'
84
- Dir.chdir 'rake-compiler-dev-box'
85
- else
86
- sh 'git', 'clone', 'https://github.com/tjschuck/rake-compiler-dev-box.git'
87
- Dir.chdir 'rake-compiler-dev-box'
88
- sh 'patch -p1 < ../compile/rake-compiler-dev-box.patch'
89
- end
90
- sh 'vagrant', 'up'
91
90
  end
92
91
 
93
- desc "Invokes the cross-compiler to generate gems for windows"
94
- task 'cross-compile' do
95
- build_dir = './rake-compiler-dev-box/tiny_tds/'
96
- if not Dir.exists?(build_dir)
97
- Dir.mkdir build_dir
98
- end
99
- # Copy the current version of tiny_tds into the box directory
100
- Dir.entries('./').each do |entry|
101
- next if ['.', '..', 'rake-compiler-dev-box'].include?(entry)
102
- cp_r entry, build_dir, :remove_destination => true
103
- end
104
- Dir.chdir './rake-compiler-dev-box'
105
- sh 'vagrant ssh -c "package_win32_fat_binary tiny_tds"'
92
+ # Bundle the freetds sources to avoid download while gem install
93
+ task gem_build_path(gemspec) do
94
+ add_file_to_gem(gemspec, "ports/archives/freetds-0.91.112.tar.gz")
106
95
  end
107
96
 
108
- desc "Cleans up all of the compiled ports, gems and tmp files from cross-compile"
109
- task 'cross-compile:clean' do
110
- rm_r './rake-compiler-dev-box/tiny_tds'
97
+ desc "Build the windows binary gems per rake-compiler-dock"
98
+ task 'gem:windows' do
99
+ require 'rake_compiler_dock'
100
+ RakeCompilerDock.sh <<-EOT
101
+ # bundle install &&
102
+ rake cross native gem RUBY_CC_VERSION=1.9.3:2.0.0:2.1.6:2.2.2
103
+ EOT
111
104
  end
@@ -0,0 +1,48 @@
1
+ services:
2
+ - mssql2014
3
+
4
+ install:
5
+ - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
6
+ - SET PATH=C:\MinGW\msys\1.0\bin;%PATH%
7
+ - SET RAKEOPT=-rdevkit
8
+ - SET TINYTDS_UNIT_DATASERVER=localhost\SQL2014
9
+ - SET TINYTDS_UNIT_DATABASE=master
10
+ - SET TINYTDS_UNIT_USER=sa
11
+ - SET TINYTDS_UNIT_PASS=Password12!
12
+ - ruby --version
13
+ - gem --version
14
+ - bundle install
15
+ - ps: |
16
+ [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null
17
+ [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SqlWmiManagement") | Out-Null
18
+
19
+ $serverName = $env:COMPUTERNAME
20
+ $instanceName = 'SQL2014'
21
+ $smo = 'Microsoft.SqlServer.Management.Smo.'
22
+ $wmi = new-object ($smo + 'Wmi.ManagedComputer')
23
+
24
+ # Enable TCP/IP
25
+ $uri = "ManagedComputer[@Name='$serverName']/ServerInstance[@Name='$instanceName']/ServerProtocol[@Name='Tcp']"
26
+ $Tcp = $wmi.GetSmoObject($uri)
27
+ $Tcp.IsEnabled = $true
28
+ $TCP.alter()
29
+
30
+ # Start services
31
+ Set-Service SQLBrowser -StartupType Manual
32
+ Start-Service SQLBrowser
33
+ Start-Service "MSSQL`$$instanceName"
34
+
35
+ build: off
36
+
37
+ test_script:
38
+ - bundle exec rake
39
+
40
+ environment:
41
+ matrix:
42
+ - ruby_version: "193"
43
+ #- ruby_version: "200"
44
+ #- ruby_version: "200-x64"
45
+ #- ruby_version: "21"
46
+ #- ruby_version: "21-x64"
47
+ #- ruby_version: "22"
48
+ - ruby_version: "22-x64"
@@ -233,7 +233,7 @@ static VALUE rb_tinytds_execute(VALUE self, VALUE sql) {
233
233
  GET_CLIENT_WRAPPER(self);
234
234
  rb_tinytds_client_reset_userdata(cwrap->userdata);
235
235
  REQUIRE_OPEN_CLIENT(cwrap);
236
- dbcmd(cwrap->client, StringValuePtr(sql));
236
+ dbcmd(cwrap->client, StringValueCStr(sql));
237
237
  if (dbsqlsend(cwrap->client) == FAIL) {
238
238
  rb_warn("TinyTds: dbsqlsend() returned FAIL.\n");
239
239
  return Qfalse;
@@ -316,25 +316,25 @@ static VALUE rb_tinytds_connect(VALUE self, VALUE opts) {
316
316
  if (!NIL_P(version))
317
317
  dbsetlversion(cwrap->login, NUM2INT(version));
318
318
  if (!NIL_P(user))
319
- dbsetluser(cwrap->login, StringValuePtr(user));
319
+ dbsetluser(cwrap->login, StringValueCStr(user));
320
320
  if (!NIL_P(pass))
321
- dbsetlpwd(cwrap->login, StringValuePtr(pass));
321
+ dbsetlpwd(cwrap->login, StringValueCStr(pass));
322
322
  if (!NIL_P(app))
323
- dbsetlapp(cwrap->login, StringValuePtr(app));
323
+ dbsetlapp(cwrap->login, StringValueCStr(app));
324
324
  if (!NIL_P(ltimeout))
325
325
  dbsetlogintime(NUM2INT(ltimeout));
326
326
  if (!NIL_P(timeout))
327
327
  dbsettime(NUM2INT(timeout));
328
328
  if (!NIL_P(charset))
329
- DBSETLCHARSET(cwrap->login, StringValuePtr(charset));
329
+ DBSETLCHARSET(cwrap->login, StringValueCStr(charset));
330
330
  if (!NIL_P(database) && (azure == Qtrue)) {
331
331
  #ifdef DBSETLDBNAME
332
- DBSETLDBNAME(cwrap->login, StringValuePtr(database));
332
+ DBSETLDBNAME(cwrap->login, StringValueCStr(database));
333
333
  #else
334
334
  rb_warn("TinyTds: Azure connections not supported in this version of FreeTDS.\n");
335
335
  #endif
336
336
  }
337
- cwrap->client = dbopen(cwrap->login, StringValuePtr(dataserver));
337
+ cwrap->client = dbopen(cwrap->login, StringValueCStr(dataserver));
338
338
  if (cwrap->client) {
339
339
  cwrap->closed = 0;
340
340
  cwrap->charset = charset;
@@ -343,10 +343,10 @@ static VALUE rb_tinytds_connect(VALUE self, VALUE opts) {
343
343
  dbsetuserdata(cwrap->client, (BYTE*)cwrap->userdata);
344
344
  cwrap->userdata->closed = 0;
345
345
  if (!NIL_P(database) && (azure != Qtrue)) {
346
- dbuse(cwrap->client, StringValuePtr(database));
346
+ dbuse(cwrap->client, StringValueCStr(database));
347
347
  }
348
348
  VALUE transposed_encoding = rb_funcall(cTinyTdsClient, intern_transpose_iconv_encoding, 1, charset);
349
- cwrap->encoding = rb_enc_find(StringValuePtr(transposed_encoding));
349
+ cwrap->encoding = rb_enc_find(StringValueCStr(transposed_encoding));
350
350
  if (dbtds(cwrap->client) <= 7) {
351
351
  cwrap->identity_insert_sql = "SELECT CAST(@@IDENTITY AS bigint) AS Ident";
352
352
  } else {
@@ -3,10 +3,54 @@ ENV['RC_ARCHS'] = '' if RUBY_PLATFORM =~ /darwin/
3
3
  # :stopdoc:
4
4
 
5
5
  require 'mkmf'
6
+ require 'mini_portile'
7
+ require 'fileutils'
8
+
9
+ # If your using 0.82, you may have to make a conf file to get it to work. For example:
10
+ # $ export FREETDSCONF='/opt/local/etc/freetds/freetds.conf'
11
+ ICONV_VERSION = ENV['TINYTDS_ICONV_VERSION'] || "1.14"
12
+ ICONV_SOURCE_URI = "http://ftp.gnu.org/pub/gnu/libiconv/libiconv-#{ICONV_VERSION}.tar.gz"
13
+
14
+ OPENSSL_VERSION = ENV['TINYTDS_OPENSSL_VERSION'] || '1.0.2d'
15
+ OPENSSL_SOURCE_URI = "http://www.openssl.org/source/openssl-#{OPENSSL_VERSION}.tar.gz"
16
+
17
+ FREETDS_VERSION = ENV['TINYTDS_FREETDS_VERSION'] || "0.91"
18
+ FREETDS_VERSION_INFO = Hash.new { |h,k|
19
+ h[k] = {:files => "ftp://ftp.freetds.org/pub/freetds/stable/freetds-#{k}.tar.gz"}
20
+ }.merge({
21
+ "0.82" => {:files => "ftp://ftp.freetds.org/pub/freetds/old/0.82/freetds-0.82.tar.gz"},
22
+ "0.91" => {:files => "ftp://ftp.freetds.org/pub/freetds/stable/freetds-0.91.112.tar.gz"},
23
+ "current" => {:files => "ftp://ftp.freetds.org/pub/freetds/current/freetds-current.tar.gz"}
24
+ })
25
+ FREETDS_SOURCE_URI = FREETDS_VERSION_INFO[FREETDS_VERSION][:files]
6
26
 
7
27
  # Shamelessly copied from nokogiri
8
28
  #
9
29
 
30
+ def do_help
31
+ print <<HELP
32
+ usage: ruby #{$0} [options]
33
+
34
+ --enable-system-freetds / --disable-system-freetds
35
+ --enable-system-iconv / --disable-system-iconv
36
+ --enable-system-openssl / --disable-system-openssl
37
+ Force use of system or builtin freetds/iconv/openssl library.
38
+ Default is to prefer system libraries and fallback to builtin.
39
+
40
+ --with-freetds-dir=DIR
41
+ Use the freetds library placed under DIR.
42
+
43
+ --enable-lookup
44
+ Search for freetds through all paths in the PATH environment variable.
45
+
46
+ --enable-cross-build
47
+ Do cross-build.
48
+ HELP
49
+ exit! 0
50
+ end
51
+
52
+ do_help if arg_config('--help')
53
+
10
54
  FREETDSDIR = ENV['FREETDS_DIR']
11
55
 
12
56
  if FREETDSDIR.nil? || FREETDSDIR.empty?
@@ -40,6 +84,144 @@ def searchable_paths_with_directories(*directories)
40
84
  end.flatten.compact
41
85
  end
42
86
 
87
+ class BuildRecipe < MiniPortile
88
+ def initialize(name, version, files)
89
+ super(name, version)
90
+ self.files = files
91
+ self.target = File.expand_path('../../../ports', __FILE__)
92
+ # Prefer host_alias over host in order to use i586-mingw32msvc as
93
+ # correct compiler prefix for cross build, but use host if not set.
94
+ self.host = consolidated_host(RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"])
95
+ self.patch_files = Dir[File.join(self.target, "patches", self.name, self.version, "*.diff")].sort
96
+ end
97
+
98
+ def consolidated_host(name)
99
+ # For ruby-1.9.3 we use newer mingw-w64 (i686-w64-mingw32) to build the shared libraries
100
+ # and mingw32 (i586-mingw32msvc) to build the extension.
101
+ name.gsub('i586-mingw32msvc', 'i686-w64-mingw32').
102
+ gsub('i686-pc-mingw32', 'i686-w64-mingw32')
103
+ end
104
+
105
+ def configure_defaults
106
+ [
107
+ "--host=#{host}", # build for specific target (host)
108
+ "--disable-static",
109
+ "--enable-shared",
110
+ ]
111
+ end
112
+
113
+ def port_path
114
+ "#{target}/#{host}"
115
+ end
116
+
117
+ # When using rake-compiler-dock on Windows, the underlying Virtualbox shared
118
+ # folders don't support symlinks, but libiconv expects it for a build on
119
+ # Linux. We work around this limitation by using the temp dir for cooking.
120
+ def chdir_for_build
121
+ build_dir = ENV['RCD_HOST_RUBY_PLATFORM'].to_s =~ /mingw|mswin|cygwin/ ? '/tmp' : '.'
122
+ Dir.chdir(build_dir) do
123
+ yield
124
+ end
125
+ end
126
+
127
+ def cook_and_activate
128
+ checkpoint = File.join(self.target, "#{self.name}-#{self.version}-#{self.host}.installed")
129
+ unless File.exist?(checkpoint)
130
+ chdir_for_build do
131
+ self.cook
132
+ end
133
+ FileUtils.touch checkpoint
134
+ end
135
+ self.activate
136
+ self
137
+ end
138
+ end
139
+
140
+ def define_libssl_recipe(host)
141
+ BuildRecipe.new("openssl", OPENSSL_VERSION, [OPENSSL_SOURCE_URI]).tap do |recipe|
142
+ class << recipe
143
+ def extract_file(file, target)
144
+ filename = File.basename(file)
145
+ FileUtils.mkdir_p target
146
+
147
+ message "Extracting #{filename} into #{target}... "
148
+ result = `#{tar_exe} #{tar_compression_switch(filename)}xf "#{file}" -C "#{target}" 2>&1`
149
+ if $?.success?
150
+ output "OK"
151
+ else
152
+ # tar on windows returns error exit code, because it can not extract symlinks
153
+ output "ERROR (ignored)"
154
+ end
155
+ end
156
+
157
+ def configure
158
+ config = if host=~/mingw/
159
+ host=~/x86_64/ ? 'mingw64' : 'mingw'
160
+ end
161
+ args = [ "CFLAGS=-DDSO_WIN32",
162
+ "./Configure",
163
+ "no-shared",
164
+ configure_prefix,
165
+ config,
166
+ ]
167
+ args.unshift("CROSS_COMPILE=#{host}-") if enable_config("cross-build")
168
+
169
+ execute "configure", "sh -c \"#{args.join(" ")}\""
170
+ end
171
+
172
+ def compile
173
+ super
174
+ # OpenSSL DLLs are called "libeay32.dll" and "ssleay32.dll" per default,
175
+ # regardless to the version. This is best suited to meet the Windows DLL hell.
176
+ # To avoid any conflicts we do a static build and build DLLs afterwards,
177
+ # with our own naming scheme.
178
+ execute "mkdef-libeay32", "(perl util/mkdef.pl 32 libeay >libeay32.def)"
179
+ execute "mkdef-ssleay32", "(perl util/mkdef.pl 32 ssleay >ssleay32.def)"
180
+ dllwrap = consolidated_host(RbConfig::CONFIG["DLLWRAP"])
181
+ execute "dllwrap-libeay32", "#{dllwrap} --dllname libeay32-#{version}-#{host}.dll --output-lib libcrypto.dll.a --def libeay32.def libcrypto.a -lwsock32 -lgdi32 -lcrypt32"
182
+ execute "dllwrap-ssleay32", "#{dllwrap} --dllname ssleay32-#{version}-#{host}.dll --output-lib libssl.dll.a --def ssleay32.def libssl.a libcrypto.dll.a"
183
+ end
184
+
185
+ def install
186
+ super
187
+ FileUtils.cp "#{work_path}/libeay32-#{version}-#{host}.dll", "#{path}/bin/"
188
+ FileUtils.cp "#{work_path}/ssleay32-#{version}-#{host}.dll", "#{path}/bin/"
189
+ FileUtils.cp "#{work_path}/libcrypto.dll.a", "#{path}/lib/"
190
+ FileUtils.cp "#{work_path}/libssl.dll.a", "#{path}/lib/"
191
+ end
192
+ end
193
+ end
194
+ end
195
+
196
+ def define_libiconv_recipe(host)
197
+ BuildRecipe.new("libiconv", ICONV_VERSION, [ICONV_SOURCE_URI])
198
+ .tap do |recipe|
199
+ # always produce position independent code
200
+ recipe.configure_options << "CFLAGS=-fPIC"
201
+ end
202
+ end
203
+
204
+ def define_freetds_recipe(host, libiconv, libssl)
205
+ BuildRecipe.new("freetds", FREETDS_VERSION, [FREETDS_SOURCE_URI])
206
+ .tap do |recipe|
207
+ with_tdsver = FREETDS_VERSION =~ /0\.8/ ? "--with-tdsver=8.0" : "--with-tdsver=7.1"
208
+ for_windows = recipe.host =~ /mswin|mingw/i
209
+ recipe.configure_options << '--with-pic'
210
+ recipe.configure_options << "--with-libiconv-prefix=#{libiconv.path}" if libiconv
211
+ recipe.configure_options << "--with-openssl=#{libssl.path}" if libssl
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
222
+ end
223
+ end
224
+
43
225
  if RbConfig::CONFIG['target_os'] =~ /mswin32|mingw32/
44
226
  lib_prefix = 'lib' unless RbConfig::CONFIG['target_os'] =~ /mingw32/
45
227
  # There's no default include/lib dir on Windows. Let's just add the Ruby ones
@@ -77,10 +259,8 @@ FREETDS_LIB_DIRS = (searchable_paths_with_directories(['lib'],['lib','freetds'])
77
259
  # lookup over searchable paths is great for native compilation, however, when
78
260
  # cross compiling we need to specify our own paths.
79
261
  if enable_config("lookup", true)
80
- dir_config('iconv', FREETDS_HEADER_DIRS, FREETDS_LIB_DIRS)
81
262
  dir_config('freetds', FREETDS_HEADER_DIRS, FREETDS_LIB_DIRS)
82
263
  else
83
- dir_config('iconv')
84
264
  dir_config('freetds')
85
265
 
86
266
  # remove LDFLAGS
@@ -91,11 +271,28 @@ def asplode(lib)
91
271
  abort "-----\n#{lib} is missing.\n-----"
92
272
  end
93
273
 
94
- asplode 'libiconv' unless have_func('iconv_open', 'iconv.h') || have_library('iconv', 'iconv_open', 'iconv.h')
95
- asplode 'freetds' unless have_header('sybfront.h') && have_header('sybdb.h')
274
+ def freetds_usable?(lib_prefix)
275
+ have_header('sybfront.h') && have_header('sybdb.h') &&
276
+ find_library("#{lib_prefix}sybdb", 'tdsdbopen') &&
277
+ find_library("#{lib_prefix}ct", 'ct_bind')
278
+ end
279
+
280
+ # We use freetds, when available already, and fallback to compilation of ports
281
+ system_freetds = enable_config('system-freetds', ENV['TINYTDS_SKIP_PORTS'] || freetds_usable?(lib_prefix))
282
+
283
+ # We expect to have iconv and OpenSSL available on non-Windows systems
284
+ host = RbConfig::CONFIG["host"]
285
+ system_iconv = enable_config('system-iconv', host =~ /mingw|mswin/ ? false : true)
286
+ system_openssl = enable_config('system-openssl', host =~ /mingw|mswin/ ? false : true )
287
+
288
+ unless system_freetds
289
+ libssl = define_libssl_recipe(host).cook_and_activate unless system_openssl
290
+ libiconv = define_libiconv_recipe(host).cook_and_activate unless system_iconv
291
+ freetds = define_freetds_recipe(host, libiconv, libssl).cook_and_activate
292
+ dir_config('freetds', freetds.path + "/include", freetds.path + "/lib")
293
+ end
96
294
 
97
- asplode 'freetds' unless find_library("#{lib_prefix}sybdb", 'tdsdbopen')
98
- asplode 'freetds' unless find_library("#{lib_prefix}ct", 'ct_bind')
295
+ asplode 'freetds' unless freetds_usable?(lib_prefix)
99
296
 
100
297
  create_makefile('tiny_tds/tiny_tds')
101
298
 
@@ -9,11 +9,30 @@ require 'tiny_tds/client'
9
9
  require 'tiny_tds/result'
10
10
 
11
11
  # Support multiple ruby versions, fat binaries under Windows.
12
- begin
13
- RUBY_VERSION =~ /(\d+.\d+)/
14
- require "tiny_tds/#{$1}/tiny_tds"
15
- rescue LoadError
12
+ 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('i586-mingw32msvc', 'i686-w64-mingw32').
19
+ gsub('i686-pc-mingw32', 'i686-w64-mingw32')
20
+ ENV['PATH'] = "#{File.expand_path("../../ports/#{ports_dir}/bin", __FILE__)};#{old_path}"
21
+ require "tiny_tds/#{ver}/tiny_tds"
22
+ rescue LoadError
23
+ require 'tiny_tds/tiny_tds'
24
+ ensure
25
+ ENV['PATH'] = old_path
26
+ end
27
+ else
28
+ # Load dependent shared libraries into the process, so that they are already present,
29
+ # when tiny_tds.so is loaded. This ensures, that shared libraries are loaded even when
30
+ # the path is different between build and run time (e.g. Heroku).
31
+ ports_libs = File.expand_path("../../ports/#{RbConfig::CONFIG["host"]}/lib/*.so", __FILE__)
32
+ Dir[ports_libs].each do |lib|
33
+ require "fiddle"
34
+ Fiddle.dlopen(lib)
35
+ end
36
+
16
37
  require 'tiny_tds/tiny_tds'
17
38
  end
18
-
19
-
@@ -1,3 +1,3 @@
1
1
  module TinyTds
2
- VERSION = '0.6.3.rc1'
2
+ VERSION = '0.6.3.rc2'
3
3
  end
@@ -78,7 +78,7 @@ module TinyTds
78
78
  :tds_version => ENV['TINYTDS_UNIT_VERSION'],
79
79
  :username => username,
80
80
  :password => password,
81
- :database => 'tinytdstest',
81
+ :database => ENV['TINYTDS_UNIT_DATABASE'] || 'tinytdstest',
82
82
  :appname => 'TinyTds Dev',
83
83
  :login_timeout => 5,
84
84
  :timeout => connection_timeout,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_tds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3.rc1
4
+ version: 0.6.3.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Collins
@@ -10,8 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-05-14 00:00:00.000000000 Z
13
+ date: 2015-07-31 00:00:00.000000000 Z
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mini_portile
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.6.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - '='
27
+ - !ruby/object:Gem::Version
28
+ version: 0.6.2
15
29
  - !ruby/object:Gem::Dependency
16
30
  name: rake
17
31
  requirement: !ruby/object:Gem::Requirement
@@ -27,33 +41,33 @@ dependencies:
27
41
  - !ruby/object:Gem::Version
28
42
  version: '10.4'
29
43
  - !ruby/object:Gem::Dependency
30
- name: mini_portile
44
+ name: rake-compiler
31
45
  requirement: !ruby/object:Gem::Requirement
32
46
  requirements:
33
47
  - - '='
34
48
  - !ruby/object:Gem::Version
35
- version: 0.6.2
49
+ version: 0.9.5
36
50
  type: :development
37
51
  prerelease: false
38
52
  version_requirements: !ruby/object:Gem::Requirement
39
53
  requirements:
40
54
  - - '='
41
55
  - !ruby/object:Gem::Version
42
- version: 0.6.2
56
+ version: 0.9.5
43
57
  - !ruby/object:Gem::Dependency
44
- name: rake-compiler
58
+ name: rake-compiler-dock
45
59
  requirement: !ruby/object:Gem::Requirement
46
60
  requirements:
47
- - - '='
61
+ - - "~>"
48
62
  - !ruby/object:Gem::Version
49
- version: 0.9.5
63
+ version: 0.4.3
50
64
  type: :development
51
65
  prerelease: false
52
66
  version_requirements: !ruby/object:Gem::Requirement
53
67
  requirements:
54
- - - '='
68
+ - - "~>"
55
69
  - !ruby/object:Gem::Version
56
- version: 0.9.5
70
+ version: 0.4.3
57
71
  - !ruby/object:Gem::Dependency
58
72
  name: minitest
59
73
  requirement: !ruby/object:Gem::Requirement
@@ -94,13 +108,12 @@ extra_rdoc_files: []
94
108
  files:
95
109
  - ".gitignore"
96
110
  - CHANGELOG
111
+ - CODE_OF_CONDUCT.md
97
112
  - Gemfile
98
113
  - MIT-LICENSE
99
114
  - README.md
100
115
  - Rakefile
101
- - compile/rake-compiler-dev-box.patch
102
- - ext/patch/Makefile.in.diff
103
- - ext/patch/dblib-30-char-username.diff
116
+ - appveyor.yml
104
117
  - ext/tiny_tds/client.c
105
118
  - ext/tiny_tds/client.h
106
119
  - ext/tiny_tds/extconf.rb
@@ -113,7 +126,9 @@ files:
113
126
  - lib/tiny_tds/error.rb
114
127
  - lib/tiny_tds/result.rb
115
128
  - lib/tiny_tds/version.rb
116
- - tasks/ports.rake
129
+ - ports/archives/freetds-0.91.112.tar.gz
130
+ - ports/patches/freetds/0.91/Makefile.in.diff
131
+ - ports/patches/freetds/0.91/dblib-30-char-username.diff
117
132
  - test/benchmark/query.rb
118
133
  - test/benchmark/query_odbc.rb
119
134
  - test/benchmark/query_tinytds.rb
@@ -150,23 +165,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
165
  version: 1.3.1
151
166
  requirements: []
152
167
  rubyforge_project:
153
- rubygems_version: 2.4.6
168
+ rubygems_version: 2.4.8
154
169
  signing_key:
155
170
  specification_version: 4
156
171
  summary: TinyTDS - A modern, simple and fast FreeTDS library for Ruby using DB-Library.
157
- test_files:
158
- - test/benchmark/query.rb
159
- - test/benchmark/query_odbc.rb
160
- - test/benchmark/query_tinytds.rb
161
- - test/client_test.rb
162
- - test/result_test.rb
163
- - test/schema/1px.gif
164
- - test/schema/sqlserver_2000.sql
165
- - test/schema/sqlserver_2005.sql
166
- - test/schema/sqlserver_2008.sql
167
- - test/schema/sqlserver_2014.sql
168
- - test/schema/sqlserver_azure.sql
169
- - test/schema/sybase_ase.sql
170
- - test/schema_test.rb
171
- - test/test_helper.rb
172
- - test/thread_test.rb
172
+ test_files: []
@@ -1,31 +0,0 @@
1
- diff --git a/bin/package_win32_fat_binary b/bin/package_win32_fat_binary
2
- index b336eb7..8ef4f98 100755
3
- --- a/bin/package_win32_fat_binary
4
- +++ b/bin/package_win32_fat_binary
5
- @@ -12,9 +12,8 @@ cd '/vagrant'
6
- # passed in path of gem to be cross-compiled
7
- cd $1
8
-
9
- -# need to use 1.8.7 for fat-binaries (1.9.3 can't cross-build 1.8.7)
10
- -rvm use 1.8.7
11
- +rvm use 1.9.3
12
- bundle install
13
-
14
- bundle exec rake clean
15
- -bundle exec rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.3:2.0.0
16
- +bundle exec rake cross native gem RUBY_CC_VERSION=1.9.3:2.0.0:2.1.1
17
- diff --git a/bin/prepare_xrubies b/bin/prepare_xrubies
18
- index 0e2043c..bd1d3c8 100755
19
- --- a/bin/prepare_xrubies
20
- +++ b/bin/prepare_xrubies
21
- @@ -18,10 +18,6 @@ rvm all do gem install rake-compiler -v "~> 0.9.2"
22
- # Use just one CPU for building 1.8.7 and 1.9.3
23
- export MAKE="make"
24
-
25
- -# Build 1.8.7 with mingw32 compiler (GCC 4.2)
26
- -rvm use 1.8.7
27
- -rake-compiler cross-ruby VERSION=1.8.7-p374 HOST=i586-mingw32msvc
28
- -
29
- # Build 1.9.3 using 1.9.3 as base
30
- rvm use 1.9.3
31
- rake-compiler cross-ruby VERSION=1.9.3-p545 HOST=i586-mingw32msvc
@@ -1,29 +0,0 @@
1
- --- a/Makefile.in 2011-08-17 18:57:36.000000000 -0700
2
- +++ b/Makefile.in 2014-05-02 10:27:01.275813000 -0700
3
- @@ -772,13 +772,6 @@
4
-
5
-
6
- install-data-local:
7
- - $(mkinstalldirs) $(ETC)
8
- - if test ! -f $(ETC)/freetds.conf; then \
9
- - $(INSTALL_DATA) $(srcdir)/freetds.conf $(ETC)/freetds.conf; \
10
- - fi
11
- - if test ! -f $(ETC)/locales.conf; then \
12
- - $(INSTALL_DATA) $(srcdir)/locales.conf $(ETC)/locales.conf; \
13
- - fi
14
-
15
- clean-local:
16
- find . \( -name \*.test_output -o -name \*.bb -o -name \*.bbg -o -name \*.da -o -name \*.gc\* \) -exec rm -f {} \;
17
- --- a/src/pool/Makefile.in 2011-08-17 18:57:36.000000000 -0700
18
- +++ b/src/pool/Makefile.in 2014-05-02 10:32:39.628347600 -0700
19
- @@ -574,10 +574,6 @@
20
-
21
-
22
- install-data-local:
23
- - $(mkinstalldirs) $(ETC)
24
- - if test ! -f $(ETC)/pool.conf; then \
25
- - $(INSTALL_DATA) $(srcdir)/pool.conf $(ETC)/pool.conf; \
26
- - fi
27
-
28
- # Tell versions [3.59,3.63) of GNU make to not export all variables.
29
- # Otherwise a system limit (for SysV at least) may be exceeded.
@@ -1,11 +0,0 @@
1
- --- a/src/dblib/dblib.c
2
- +++ b/src/dblib/dblib.c
3
- @@ -765,7 +765,7 @@ dbsetlname(LOGINREC * login, const char *value, int which)
4
- return FAIL;
5
- }
6
-
7
- - if (TDS_MAX_LOGIN_STR_SZ < strlen(value)) {
8
- + if (login->tds_login->tds_version < 0x700 && TDS_MAX_LOGIN_STR_SZ < strlen(value)) {
9
- dbperror(NULL, SYBENTLL, 0);
10
- return FAIL;
11
- }
@@ -1,73 +0,0 @@
1
- require 'mini_portile'
2
-
3
- # If your using 0.82, you may have to make a conf file to get it to work. For example:
4
- # $ export FREETDSCONF='/opt/local/etc/freetds/freetds.conf'
5
- ICONV_VERSION = "1.14"
6
- FREETDS_VERSION = ENV['TINYTDS_FREETDS_VERSION'] || "0.91"
7
- FREETDS_VERSION_INFO = Hash.new { |h,k|
8
- h[k] = {:files => "ftp://ftp.freetds.org/pub/freetds/stable/freetds-#{k}.tar.gz"}
9
- }.merge({
10
- "0.82" => {:files => "ftp://ftp.freetds.org/pub/freetds/old/0.82/freetds-0.82.tar.gz"},
11
- "0.91" => {:files => "ftp://ftp.freetds.org/pub/freetds/stable/freetds-0.91.112.tar.gz"},
12
- "current" => {:files => "ftp://ftp.freetds.org/pub/freetds/current/freetds-current.tgz"}
13
- })
14
-
15
- # all ports depends on this directory to exist
16
- directory "ports"
17
-
18
- def define_libiconv_recipe(platform, host)
19
- recipe = MiniPortile.new "libiconv", ICONV_VERSION
20
- recipe.files << "http://ftp.gnu.org/pub/gnu/libiconv/libiconv-#{ICONV_VERSION}.tar.gz"
21
- recipe.host = host
22
- desc "Compile libiconv for '#{platform}' (#{host})"
23
- task "ports:libiconv:#{platform}" => ["ports"] do
24
- checkpoint = "ports/.#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
25
- unless File.exist?(checkpoint)
26
- # always produce position independent code
27
- recipe.configure_options << "CFLAGS='-fPIC'"
28
- recipe.cook
29
- touch checkpoint
30
- recipe.activate
31
- end
32
- end
33
- recipe
34
- end
35
-
36
- def define_freetds_recipe(platform, host, libiconv)
37
- recipe = MiniPortile.new "freetds", FREETDS_VERSION
38
- recipe.files << FREETDS_VERSION_INFO[FREETDS_VERSION][:files]
39
- recipe.host = host
40
- if recipe.respond_to?(:patch_files) && FREETDS_VERSION == "0.91"
41
- recipe.patch_files << File.expand_path(File.join('..', '..', 'ext', 'patch', 'dblib-30-char-username.diff'), __FILE__)
42
- unless RUBY_PLATFORM =~ /mswin|mingw/
43
- recipe.patch_files << File.expand_path(File.join('..', '..', 'ext', 'patch', 'Makefile.in.diff'), __FILE__)
44
- end
45
- end
46
- desc "Compile freetds for '#{platform}' (#{host})"
47
- task "ports:freetds:#{platform}" => ["ports", "ports:libiconv:#{platform}"] do
48
- checkpoint = "ports/.#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
49
- unless File.exist?(checkpoint)
50
- with_tdsver = ENV['TINYTDS_FREETDS_VERSION'] =~ /0\.8/ ? "--with-tdsver=8.0" : "--with-tdsver=7.1"
51
- for_windows = recipe.host =~ /mswin|mingw/i
52
- recipe.configure_options << '--with-pic'
53
- recipe.configure_options << "--with-libiconv-prefix=#{libiconv.path}"
54
- recipe.configure_options << '--sysconfdir="C:/Sites"' if for_windows
55
- recipe.configure_options << '--enable-sspi' if for_windows
56
- recipe.configure_options << "--disable-odbc"
57
- recipe.configure_options << with_tdsver
58
- recipe.cook
59
- touch checkpoint
60
- recipe.activate
61
- end
62
- end
63
- recipe
64
- end
65
-
66
- # native compilation of ports
67
- host = RbConfig::CONFIG["host"]
68
- libiconv = define_libiconv_recipe(RUBY_PLATFORM, host)
69
- freetds = define_freetds_recipe(RUBY_PLATFORM, host, libiconv)
70
-
71
- # compile native FreeTDS
72
- desc "Compile native freetds"
73
- task "ports:freetds" => ["ports:freetds:#{RUBY_PLATFORM}"]