@@ -7,9 +7,11 @@ require_relative 'ports/freetds'
7
7
require_relative '../ext/tiny_tds/extconsts'
8
8
9
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 )
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
+ }
13
15
14
16
directory "ports"
15
17
CLEAN . include "ports/*mingw32*"
@@ -18,51 +20,51 @@ namespace :ports do
18
20
task :openssl , [ :host ] do |task , args |
19
21
args . with_defaults ( host : RbConfig ::CONFIG [ 'host' ] )
20
22
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
25
27
end
26
28
27
29
task :libiconv , [ :host ] do |task , args |
28
30
args . with_defaults ( host : RbConfig ::CONFIG [ 'host' ] )
29
31
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
34
36
end
35
37
36
38
task :freetds , [ :host ] do |task , args |
37
39
args . with_defaults ( host : RbConfig ::CONFIG [ 'host' ] )
38
40
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
41
43
42
- if openssl
44
+ if libraries_to_compile [ : openssl]
43
45
# freetds doesn't have an option that will provide an rpath
44
46
# 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"
46
48
# Add the pkgconfig file with MSYS2'ish path, to prefer our ports build
47
49
# 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 } "
50
52
end
51
53
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 } "
54
56
end
55
57
56
- freetds . cook
57
- freetds . activate
58
+ libraries_to_compile [ : freetds] . cook
59
+ libraries_to_compile [ : freetds] . activate
58
60
end
59
61
60
- task :compile , [ :host ] do |task , args |
62
+ task :compile , [ :host ] do |task , args |
61
63
args . with_defaults ( host : RbConfig ::CONFIG [ 'host' ] )
62
64
63
65
puts "Compiling ports for #{ args . host } ..."
64
66
65
- [ 'openssl' , 'libiconv' , 'freetds' ] . each do |lib |
67
+ libraries_to_compile . keys . each do |lib |
66
68
Rake ::Task [ "ports:#{ lib } " ] . invoke ( args . host )
67
69
end
68
70
end
@@ -79,6 +81,19 @@ namespace :ports do
79
81
RakeCompilerDock . sh build . join ( ' && ' ) , platform : gem_platform
80
82
end
81
83
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
82
97
end
83
98
84
99
desc 'Build ports and activate libraries for the current architecture.'
0 commit comments