1
- require ' mkmf'
2
- require_relative ' extconsts'
3
-
4
- if ENV [ ' MAINTAINER_MODE' ]
5
- $stderr . puts "Maintainer mode enabled."
6
- $CFLAGS <<
7
- ' -Wall' <<
8
- ' -ggdb' <<
9
- ' -DDEBUG' <<
10
- ' -pedantic'
11
- $LDFLAGS <<
12
- ' -ggdb'
1
+ require " mkmf"
2
+ require_relative " extconsts"
3
+
4
+ if ENV [ " MAINTAINER_MODE" ]
5
+ warn "Maintainer mode enabled."
6
+ $CFLAGS << # standard:disable Style/GlobalVars
7
+ " -Wall" \
8
+ " -ggdb" \
9
+ " -DDEBUG" \
10
+ " -pedantic"
11
+ $LDFLAGS << # standard:disable Style/GlobalVars
12
+ " -ggdb"
13
13
end
14
14
15
- if gem_platform = with_config ( "cross-build" )
16
- require ' mini_portile2'
15
+ if ( gem_platform = with_config ( "cross-build" ) )
16
+ require " mini_portile2"
17
17
18
18
openssl_platform = with_config ( "openssl-platform" )
19
19
@@ -23,7 +23,7 @@ class BuildRecipe < MiniPortile
23
23
def initialize ( name , version , files )
24
24
super ( name , version )
25
25
self . files = files
26
- rootdir = File . expand_path ( ' ../../..' , __FILE__ )
26
+ rootdir = File . expand_path ( " ../../.." , __FILE__ )
27
27
self . target = File . join ( rootdir , "ports" )
28
28
self . patch_files = Dir [ File . join ( "patches" , self . name , self . version , "*.patch" ) ] . sort
29
29
end
@@ -34,35 +34,35 @@ def port_path
34
34
end
35
35
36
36
def cook_and_activate
37
- checkpoint = File . join ( self . target , "#{ self . name } -#{ self . version } -#{ gem_platform } .installed" )
38
-
37
+ checkpoint = File . join ( target , "#{ name } -#{ version } -#{ gem_platform } .installed" )
38
+
39
39
unless File . exist? ( checkpoint )
40
- self . cook
41
- FileUtils . touch checkpoint
42
- end
43
-
44
- self . activate
40
+ cook
41
+ FileUtils . touch checkpoint
42
+ end
43
+
44
+ activate
45
45
self
46
46
end
47
47
end
48
48
49
49
openssl_recipe = BuildRecipe . new ( "openssl" , OPENSSL_VERSION , [ OPENSSL_SOURCE_URI ] ) . tap do |recipe |
50
- class << recipe
50
+ class << recipe
51
51
attr_accessor :openssl_platform
52
-
52
+
53
53
def configure
54
54
envs = [ ]
55
55
envs << "CFLAGS=-DDSO_WIN32 -DOPENSSL_THREADS" if MiniPortile . windows?
56
56
envs << "CFLAGS=-fPIC -DOPENSSL_THREADS" if MiniPortile . linux?
57
- execute ( ' configure' , [ ' env' , *envs , "./Configure" , openssl_platform , "threads" , "-static" , "CROSS_COMPILE=#{ host } -" , configure_prefix , "--libdir=lib" ] , altlog : "config.log" )
57
+ execute ( " configure" , [ " env" , *envs , "./Configure" , openssl_platform , "threads" , "-static" , "CROSS_COMPILE=#{ host } -" , configure_prefix , "--libdir=lib" ] , altlog : "config.log" )
58
58
end
59
-
59
+
60
60
def compile
61
- execute ( ' compile' , "#{ make_cmd } build_libs" )
61
+ execute ( " compile" , "#{ make_cmd } build_libs" )
62
62
end
63
-
63
+
64
64
def install
65
- execute ( ' install' , "#{ make_cmd } install_dev" )
65
+ execute ( " install" , "#{ make_cmd } install_dev" )
66
66
end
67
67
end
68
68
@@ -122,30 +122,30 @@ def configure_defaults
122
122
end
123
123
124
124
# enable relative path to later load the FreeTDS shared library
125
- $LDFLAGS << " '-Wl,-rpath=$$ORIGIN/../../../ports/#{ gem_platform } /lib'"
125
+ $LDFLAGS << " '-Wl,-rpath=$$ORIGIN/../../../ports/#{ gem_platform } /lib'" # standard:disable Style/GlobalVars
126
126
127
- dir_config ( ' freetds' , "#{ freetds_recipe . path } /include" , "#{ freetds_recipe . path } /lib" )
127
+ dir_config ( " freetds" , "#{ freetds_recipe . path } /include" , "#{ freetds_recipe . path } /lib" )
128
128
else
129
129
# Make sure to check the ports path for the configured host
130
- architecture = RbConfig ::CONFIG [ ' arch' ]
130
+ architecture = RbConfig ::CONFIG [ " arch" ]
131
131
132
132
project_dir = File . expand_path ( "../../.." , __FILE__ )
133
- freetds_ports_dir = File . join ( project_dir , ' ports' , architecture , ' freetds' , FREETDS_VERSION )
133
+ freetds_ports_dir = File . join ( project_dir , " ports" , architecture , " freetds" , FREETDS_VERSION )
134
134
freetds_ports_dir = File . expand_path ( freetds_ports_dir )
135
-
135
+
136
136
# Add all the special path searching from the original tiny_tds build
137
137
# order is important here! First in, first searched.
138
- DIRS = %w(
138
+ DIRS = %w[
139
139
/opt/local
140
140
/usr/local
141
- )
141
+ ]
142
142
143
- if RbConfig ::CONFIG [ ' host_os' ] =~ /darwin/i
143
+ if /darwin/i . match? ( RbConfig ::CONFIG [ " host_os" ] )
144
144
# Ruby below 2.7 seems to label the host CPU on Apple Silicon as aarch64
145
145
# 2.7 and above print is as ARM64
146
- target_host_cpu = Gem ::Version . new ( RUBY_VERSION ) < Gem ::Version . new ( ' 2.7' ) ? ' aarch64' : ' arm64'
146
+ target_host_cpu = ( Gem ::Version . new ( RUBY_VERSION ) < Gem ::Version . new ( " 2.7" ) ) ? " aarch64" : " arm64"
147
147
148
- if RbConfig ::CONFIG [ ' host_cpu' ] == target_host_cpu
148
+ if RbConfig ::CONFIG [ " host_cpu" ] == target_host_cpu
149
149
# Homebrew on Apple Silicon installs into /opt/hombrew
150
150
# https://docs.brew.sh/Installation
151
151
# On Intel Macs, it is /usr/local, so no changes necessary to DIRS
@@ -162,7 +162,7 @@ def configure_defaults
162
162
163
163
# Grab freetds environment variable for use by people on services like
164
164
# Heroku who they can't easily use bundler config to set directories
165
- DIRS . unshift ( ENV [ ' FREETDS_DIR' ] ) if ENV . has_key? ( ' FREETDS_DIR' )
165
+ DIRS . unshift ( ENV [ " FREETDS_DIR" ] ) if ENV . has_key? ( " FREETDS_DIR" )
166
166
167
167
# Add the search paths for freetds configured above
168
168
ldirs = DIRS . flat_map do |path |
@@ -175,15 +175,15 @@ def configure_defaults
175
175
[ idir , "#{ idir } /freetds" ]
176
176
end
177
177
178
- puts "looking for freetds headers in the following directories:\n #{ idirs . map { |a | " - #{ a } \n " } . join } "
179
- puts "looking for freetds library in the following directories:\n #{ ldirs . map { |a | " - #{ a } \n " } . join } "
180
- dir_config ( ' freetds' , idirs , ldirs )
178
+ puts "looking for freetds headers in the following directories:\n #{ idirs . map { |a | " - #{ a } \n " } . join } "
179
+ puts "looking for freetds library in the following directories:\n #{ ldirs . map { |a | " - #{ a } \n " } . join } "
180
+ dir_config ( " freetds" , idirs , ldirs )
181
181
end
182
182
183
- find_header ( ' sybfront.h' ) or abort "Can't find the 'sybfront.h' header"
184
- find_header ( ' sybdb.h' ) or abort "Can't find the 'sybdb.h' header"
183
+ find_header ( " sybfront.h" ) or abort "Can't find the 'sybfront.h' header"
184
+ find_header ( " sybdb.h" ) or abort "Can't find the 'sybdb.h' header"
185
185
186
- unless have_library ( ' sybdb' , ' dbanydatecrack' )
186
+ unless have_library ( " sybdb" , " dbanydatecrack" )
187
187
abort "Failed! Do you have FreeTDS 1.0.0 or higher installed?"
188
188
end
189
189
0 commit comments