Skip to content

Commit 42f90a7

Browse files
committed
Fix cross build for binary Windows gems
1 parent a18a275 commit 42f90a7

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

ext/tiny_tds/extconf.rb

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,39 @@ def do_help
2222

2323
# Make sure to check the ports path for the configured host
2424
host = RbConfig::CONFIG['host']
25-
project_dir = File.join(['..']*4)
25+
project_dir = File.expand_path("../../..", __FILE__)
2626
freetds_ports_dir = File.join(project_dir, 'ports', host, 'freetds', FREETDS_VERSION)
2727
freetds_ports_dir = File.expand_path(freetds_ports_dir)
2828

2929
# Add all the special path searching from the original tiny_tds build
30-
# order is important here! First in, last searched.
30+
# order is important here! First in, first searched.
3131
DIRS = %w(
32-
/usr/local
3332
/opt/local
33+
/usr/local
3434
)
3535

36+
# Add the ports directory if it exists for local developer builds
37+
DIRS.unshift(freetds_ports_dir) if File.directory?(freetds_ports_dir)
38+
3639
# Grab freetds environment variable for use by people on services like
3740
# Heroku who they can't easily use bundler config to set directories
38-
DIRS.push(ENV['FREETDS_DIR']) if ENV.has_key?('FREETDS_DIR')
39-
40-
# Add the ports directory if it exists for local developer builds
41-
DIRS.push(freetds_ports_dir) if File.directory?(freetds_ports_dir)
41+
DIRS.unshift(ENV['FREETDS_DIR']) if ENV.has_key?('FREETDS_DIR')
4242

4343
# Add the search paths for freetds configured above
44-
DIRS.each do |path|
45-
idir = "#{path}/include"
44+
ldirs = DIRS.flat_map do |path|
4645
ldir = "#{path}/lib"
46+
[ldir, "#{ldir}/freetds"]
47+
end
4748

48-
dir_config('freetds',
49-
[idir, "#{idir}/freetds"],
50-
[ldir, "#{ldir}/freetds"]
51-
)
49+
idirs = DIRS.flat_map do |path|
50+
idir = "#{path}/include"
51+
[idir, "#{idir}/freetds"]
5252
end
5353

54+
puts "looking for freetds headers in the following directories:\n#{idirs.map{|a| " - #{a}\n"}.join}"
55+
puts "looking for freetds library in the following directories:\n#{ldirs.map{|a| " - #{a}\n"}.join}"
56+
dir_config('freetds', idirs, ldirs)
57+
5458
have_dependencies = [
5559
find_header('sybfront.h'),
5660
find_header('sybdb.h'),

tasks/ports.rake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ namespace :ports do
1212
freetds = Ports::Freetds.new(FREETDS_VERSION)
1313

1414
directory "ports"
15+
CLEAN.include "ports/*mingw32*"
16+
CLEAN.include "ports/*.installed"
1517

1618
task :openssl, [:host] do |task, args|
1719
args.with_defaults(host: RbConfig::CONFIG['host'])
@@ -69,15 +71,13 @@ namespace :ports do
6971
task 'cross' do
7072
require 'rake_compiler_dock'
7173

72-
# make sure to install our bundle
73-
build = ['bundle']
74-
7574
# build the ports for all our cross compile hosts
7675
GEM_PLATFORM_HOSTS.each do |gem_platform, host|
76+
# make sure to install our bundle
77+
build = ['bundle']
7778
build << "rake ports:compile[#{host}] MAKE='make -j`nproc`'"
79+
RakeCompilerDock.sh build.join(' && '), platform: gem_platform
7880
end
79-
80-
RakeCompilerDock.sh build.join(' && ')
8181
end
8282
end
8383

0 commit comments

Comments
 (0)