@@ -7,9 +7,11 @@ require_relative 'ports/freetds'
77require_relative '../ext/tiny_tds/extconsts'
88
99namespace :ports do
10- openssl = Ports ::Openssl . new ( OPENSSL_VERSION )
11- libiconv = Ports ::Libiconv . new ( ICONV_VERSION )
12- freetds = Ports ::Freetds . new ( FREETDS_VERSION )
10+ libraries_to_compile = {
11+ freetds : Ports ::Freetds . new ( FREETDS_VERSION ) ,
12+ libiconv : Ports ::Libiconv . new ( ICONV_VERSION ) ,
13+ openssl : Ports ::Openssl . new ( OPENSSL_VERSION )
14+ }
1315
1416 directory "ports"
1517 CLEAN . include "ports/*mingw32*"
@@ -18,51 +20,51 @@ namespace :ports do
1820 task :openssl , [ :host ] do |task , args |
1921 args . with_defaults ( host : RbConfig ::CONFIG [ 'host' ] )
2022
21- openssl . files = [ OPENSSL_SOURCE_URI ]
22- openssl . host = args . host
23- openssl . cook
24- openssl . activate
23+ libraries_to_compile [ : openssl] . files = [ OPENSSL_SOURCE_URI ]
24+ libraries_to_compile [ : openssl] . host = args . host
25+ libraries_to_compile [ : openssl] . cook
26+ libraries_to_compile [ : openssl] . activate
2527 end
2628
2729 task :libiconv , [ :host ] do |task , args |
2830 args . with_defaults ( host : RbConfig ::CONFIG [ 'host' ] )
2931
30- libiconv . files = [ ICONV_SOURCE_URI ]
31- libiconv . host = args . host
32- libiconv . cook
33- libiconv . activate
32+ libraries_to_compile [ : libiconv] . files = [ ICONV_SOURCE_URI ]
33+ libraries_to_compile [ : libiconv] . host = args . host
34+ libraries_to_compile [ : libiconv] . cook
35+ libraries_to_compile [ : libiconv] . activate
3436 end
3537
3638 task :freetds , [ :host ] do |task , args |
3739 args . with_defaults ( host : RbConfig ::CONFIG [ 'host' ] )
3840
39- freetds . files = [ FREETDS_SOURCE_URI ]
40- freetds . host = args . host
41+ libraries_to_compile [ : freetds] . files = [ FREETDS_SOURCE_URI ]
42+ libraries_to_compile [ : freetds] . host = args . host
4143
42- if openssl
44+ if libraries_to_compile [ : openssl]
4345 # freetds doesn't have an option that will provide an rpath
4446 # so we do it manually
45- ENV [ 'OPENSSL_CFLAGS' ] = "-Wl,-rpath -Wl,#{ openssl . path } /lib"
47+ ENV [ 'OPENSSL_CFLAGS' ] = "-Wl,-rpath -Wl,#{ libraries_to_compile [ : openssl] . path } /lib"
4648 # Add the pkgconfig file with MSYS2'ish path, to prefer our ports build
4749 # 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+ ENV [ 'PKG_CONFIG_PATH' ] = "#{ libraries_to_compile [ : openssl] . path . gsub ( /^(\w ):/i ) { "/" + $1. downcase } } /lib/pkgconfig:#{ ENV [ 'PKG_CONFIG_PATH' ] } "
51+ libraries_to_compile [ : freetds] . configure_options << "--with-openssl=#{ libraries_to_compile [ : openssl] . path } "
5052 end
5153
52- if libiconv
53- freetds . configure_options << "--with-libiconv-prefix=#{ libiconv . path } "
54+ if libraries_to_compile [ : libiconv]
55+ libraries_to_compile [ : freetds] . configure_options << "--with-libiconv-prefix=#{ libraries_to_compile [ : libiconv] . path } "
5456 end
5557
56- freetds . cook
57- freetds . activate
58+ libraries_to_compile [ : freetds] . cook
59+ libraries_to_compile [ : freetds] . activate
5860 end
5961
60- task :compile , [ :host ] do |task , args |
62+ task :compile , [ :host ] do |task , args |
6163 args . with_defaults ( host : RbConfig ::CONFIG [ 'host' ] )
6264
6365 puts "Compiling ports for #{ args . host } ..."
6466
65- [ 'openssl' , 'libiconv' , 'freetds' ] . each do |lib |
67+ libraries_to_compile . keys . each do |lib |
6668 Rake ::Task [ "ports:#{ lib } " ] . invoke ( args . host )
6769 end
6870 end
@@ -79,6 +81,19 @@ namespace :ports do
7981 RakeCompilerDock . sh build . join ( ' && ' ) , platform : gem_platform
8082 end
8183 end
84+
85+ desc "Notes the actual versions for the compiled ports into a file"
86+ task "version_file" do
87+ ports_version = { }
88+
89+ libraries_to_compile . each do |library , library_recipe |
90+ ports_version [ library ] = library_recipe . version
91+ end
92+
93+ File . open ( ".ports_versions" , "w" ) do |f |
94+ f . write ports_version
95+ end
96+ end
8297end
8398
8499desc 'Build ports and activate libraries for the current architecture.'
0 commit comments