mkrf 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mkrf.rb +1 -1
- data/lib/mkrf/availability.rb +29 -5
- data/lib/mkrf/generator.rb +19 -8
- metadata +13 -13
data/lib/mkrf.rb
CHANGED
data/lib/mkrf/availability.rb
CHANGED
@@ -26,8 +26,7 @@ module Mkrf
|
|
26
26
|
# * <tt>:headers</tt> -- headers to load by default
|
27
27
|
# * <tt>:compiler</tt> -- which compiler to use when determining availability
|
28
28
|
# * <tt>:includes</tt> -- directories that should be searched for include files
|
29
|
-
def initialize(options = {})
|
30
|
-
|
29
|
+
def initialize(options = {})
|
31
30
|
@loaded_libs = (options[:loaded_libs] || Config::CONFIG["LIBS"].gsub('-l', '').split).to_a
|
32
31
|
@library_paths = (options[:library_paths] || "").to_a
|
33
32
|
# Not sure what COMMON_HEADERS looks like when populated
|
@@ -74,6 +73,7 @@ module Mkrf
|
|
74
73
|
def has_library?(library, function = "main", *paths)
|
75
74
|
logger.info "Checking for library: #{library}"
|
76
75
|
return true if library_already_loaded?(library)
|
76
|
+
return true if RUBY_PLATFORM =~ /mswin/ # TODO: find a way on windows
|
77
77
|
# Should this be only found_library? or a specialized version with
|
78
78
|
# path searching?
|
79
79
|
found_library?(library, function)
|
@@ -139,12 +139,36 @@ module Mkrf
|
|
139
139
|
|
140
140
|
# Returns a string of libraries formatted for compilation
|
141
141
|
def library_compile_string
|
142
|
-
|
142
|
+
if RUBY_PLATFORM =~ /mswin/
|
143
|
+
@loaded_libs.join(' ')
|
144
|
+
else
|
145
|
+
@loaded_libs.collect {|l| "-l#{l}"}.join(' ')
|
146
|
+
end
|
143
147
|
end
|
144
148
|
|
145
149
|
# Returns a string of libraries directories formatted for compilation
|
146
150
|
def library_paths_compile_string
|
147
|
-
|
151
|
+
if RUBY_PLATFORM =~ /mswin/
|
152
|
+
@library_paths.collect {|l| "/libpath:#{l}"}.join(' ')
|
153
|
+
else
|
154
|
+
@library_paths.collect {|l| "-L#{l}"}.join(' ')
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def ldshared_string
|
159
|
+
if RUBY_PLATFORM =~ /mswin/
|
160
|
+
"link -nologo -incremental:no -debug -opt:ref -opt:icf -dll"
|
161
|
+
else
|
162
|
+
Config::CONFIG['LDSHARED']
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def ld_outfile(filename) # :nodoc:
|
167
|
+
if RUBY_PLATFORM =~ /mswin/
|
168
|
+
"-out:#{filename}"
|
169
|
+
else
|
170
|
+
"-o #{filename}"
|
171
|
+
end
|
148
172
|
end
|
149
173
|
|
150
174
|
# Returns a string of include directories formatted for compilation
|
@@ -243,7 +267,7 @@ module Mkrf
|
|
243
267
|
def header_include_string
|
244
268
|
@headers.collect {|header| "#include <#{header}>"}.join('\n')
|
245
269
|
end
|
246
|
-
|
270
|
+
|
247
271
|
def link_command
|
248
272
|
# This current implementation just splats the library_paths in
|
249
273
|
# unconditionally. Is this problematic?
|
data/lib/mkrf/generator.rb
CHANGED
@@ -153,24 +153,34 @@ module Mkrf
|
|
153
153
|
def defines_compile_string # :nodoc:
|
154
154
|
@available.defines.collect {|define| "-D#{define}"}.join(' ')
|
155
155
|
end
|
156
|
-
|
156
|
+
|
157
|
+
def library_path(path) # :nodoc:
|
158
|
+
if RUBY_PLATFORM =~ /mswin/
|
159
|
+
"-libpath:#{path}"
|
160
|
+
else
|
161
|
+
"-L#{path}"
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
157
165
|
def rakefile_contents # :nodoc:
|
166
|
+
objext = CONFIG['OBJEXT']
|
167
|
+
|
158
168
|
<<-END_RAKEFILE
|
159
169
|
# Generated by mkrf
|
160
170
|
require 'rake/clean'
|
161
171
|
|
162
|
-
CLEAN.include('
|
172
|
+
CLEAN.include('*.#{objext}')
|
163
173
|
CLOBBER.include('#{@extension_name}', 'mkrf.log')
|
164
174
|
|
165
175
|
SRC = FileList[#{sources.join(',')}]
|
166
|
-
OBJ = SRC.ext('
|
176
|
+
OBJ = SRC.ext('#{objext}')
|
167
177
|
CC = '#{@cc}'
|
168
178
|
|
169
179
|
ADDITIONAL_OBJECTS = '#{objects}'
|
170
180
|
|
171
|
-
LDSHARED = "#{
|
181
|
+
LDSHARED = "#{@available.ldshared_string} #{ldshared}"
|
172
182
|
|
173
|
-
LIBPATH = "
|
183
|
+
LIBPATH = "#{library_path(CONFIG['libdir'])} #{@available.library_paths_compile_string}"
|
174
184
|
|
175
185
|
INCLUDES = "#{@available.includes_compile_string}"
|
176
186
|
|
@@ -179,16 +189,17 @@ LIBS = "#{@available.library_compile_string}"
|
|
179
189
|
CFLAGS = "#{cflags} #{defines_compile_string}"
|
180
190
|
|
181
191
|
RUBYARCHDIR = "\#{ENV["RUBYARCHDIR"]}"
|
192
|
+
LIBRUBYARG_SHARED = "#{CONFIG['LIBRUBYARG_SHARED']}"
|
182
193
|
|
183
194
|
task :default => ['#{@extension_name}']
|
184
195
|
|
185
|
-
rule '
|
186
|
-
sh "\#{CC} \#{CFLAGS} \#{INCLUDES} -c
|
196
|
+
rule '.#{objext}' => '.c' do |t|
|
197
|
+
sh "\#{CC} \#{CFLAGS} \#{INCLUDES} -c \#{t.source}"
|
187
198
|
end
|
188
199
|
|
189
200
|
desc "Build this extension"
|
190
201
|
file '#{@extension_name}' => OBJ do
|
191
|
-
sh "\#{LDSHARED} \#{LIBPATH}
|
202
|
+
sh "\#{LDSHARED} \#{LIBPATH} #{@available.ld_outfile(@extension_name)} \#{OBJ} \#{ADDITIONAL_OBJECTS} \#{LIBS} \#{LIBRUBYARG_SHARED}"
|
192
203
|
end
|
193
204
|
|
194
205
|
desc "Install this extension"
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.2
|
3
3
|
specification_version: 1
|
4
4
|
name: mkrf
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.2.1
|
7
|
+
date: 2007-04-14 00:00:00 +09:00
|
8
8
|
summary: Generate Rakefiles to Build C Extensions to Ruby
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -33,11 +33,11 @@ files:
|
|
33
33
|
- README
|
34
34
|
- CHANGELOG
|
35
35
|
- MIT-LICENSE
|
36
|
-
- lib/mkrf.rb
|
37
36
|
- lib/mkrf
|
38
|
-
- lib/mkrf
|
37
|
+
- lib/mkrf.rb
|
39
38
|
- lib/mkrf/rakehelper.rb
|
40
39
|
- lib/mkrf/generator.rb
|
40
|
+
- lib/mkrf/availability.rb
|
41
41
|
- test/integration
|
42
42
|
- test/sample_files
|
43
43
|
- test/fixtures
|
@@ -96,17 +96,18 @@ files:
|
|
96
96
|
- test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.h
|
97
97
|
- test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.c
|
98
98
|
- test/sample_files/syck-0.55/ext
|
99
|
+
- test/sample_files/syck-0.55/tests
|
100
|
+
- test/sample_files/syck-0.55/config
|
101
|
+
- test/sample_files/syck-0.55/lib
|
99
102
|
- test/sample_files/syck-0.55/CHANGELOG
|
100
103
|
- test/sample_files/syck-0.55/configure.in
|
101
104
|
- test/sample_files/syck-0.55/configure
|
102
105
|
- test/sample_files/syck-0.55/TODO
|
103
106
|
- test/sample_files/syck-0.55/config.h
|
104
107
|
- test/sample_files/syck-0.55/config.status
|
105
|
-
- test/sample_files/syck-0.55/tests
|
106
108
|
- test/sample_files/syck-0.55/README
|
107
109
|
- test/sample_files/syck-0.55/aclocal.m4
|
108
110
|
- test/sample_files/syck-0.55/RELEASE
|
109
|
-
- test/sample_files/syck-0.55/config
|
110
111
|
- test/sample_files/syck-0.55/Makefile.am
|
111
112
|
- test/sample_files/syck-0.55/config.h.in
|
112
113
|
- test/sample_files/syck-0.55/README.BYTECODE
|
@@ -114,18 +115,17 @@ files:
|
|
114
115
|
- test/sample_files/syck-0.55/bootstrap
|
115
116
|
- test/sample_files/syck-0.55/README.EXT
|
116
117
|
- test/sample_files/syck-0.55/Makefile
|
117
|
-
- test/sample_files/syck-0.55/lib
|
118
118
|
- test/sample_files/syck-0.55/stamp-h1
|
119
119
|
- test/sample_files/syck-0.55/COPYING
|
120
120
|
- test/sample_files/syck-0.55/ext/ruby
|
121
121
|
- test/sample_files/syck-0.55/ext/ruby/ext
|
122
|
-
- test/sample_files/syck-0.55/ext/ruby/CHANGELOG
|
123
|
-
- test/sample_files/syck-0.55/ext/ruby/install.rb
|
124
122
|
- test/sample_files/syck-0.55/ext/ruby/tests
|
125
|
-
- test/sample_files/syck-0.55/ext/ruby/README
|
126
123
|
- test/sample_files/syck-0.55/ext/ruby/samples
|
127
124
|
- test/sample_files/syck-0.55/ext/ruby/lib
|
128
125
|
- test/sample_files/syck-0.55/ext/ruby/yts
|
126
|
+
- test/sample_files/syck-0.55/ext/ruby/CHANGELOG
|
127
|
+
- test/sample_files/syck-0.55/ext/ruby/install.rb
|
128
|
+
- test/sample_files/syck-0.55/ext/ruby/README
|
129
129
|
- test/sample_files/syck-0.55/ext/ruby/ext/syck
|
130
130
|
- test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.c
|
131
131
|
- test/sample_files/syck-0.55/ext/ruby/ext/syck/bytecode.c
|
@@ -149,9 +149,9 @@ files:
|
|
149
149
|
- test/sample_files/syck-0.55/ext/ruby/samples/okayNews-modules.rb
|
150
150
|
- test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-client.rb
|
151
151
|
- test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-server.rb
|
152
|
-
- test/sample_files/syck-0.55/ext/ruby/lib/yaml.rb
|
153
152
|
- test/sample_files/syck-0.55/ext/ruby/lib/okay
|
154
153
|
- test/sample_files/syck-0.55/ext/ruby/lib/yaml
|
154
|
+
- test/sample_files/syck-0.55/ext/ruby/lib/yaml.rb
|
155
155
|
- test/sample_files/syck-0.55/ext/ruby/lib/okay.rb
|
156
156
|
- test/sample_files/syck-0.55/ext/ruby/lib/yod.rb
|
157
157
|
- test/sample_files/syck-0.55/ext/ruby/lib/okay/rpc.rb
|
@@ -230,9 +230,9 @@ files:
|
|
230
230
|
- test/sample_files/libtrivial/ext
|
231
231
|
- test/sample_files/libtrivial/ext/libtrivial.c
|
232
232
|
- test/sample_files/libtrivial/ext/extconf.rb
|
233
|
+
- test/fixtures/down_a_directory
|
233
234
|
- test/fixtures/stdmkrf.h
|
234
235
|
- test/fixtures/some_binary
|
235
|
-
- test/fixtures/down_a_directory
|
236
236
|
- test/fixtures/down_a_directory/header_down_a_directory.h
|
237
237
|
- test/unit/test_generator.rb
|
238
238
|
- test/unit/test_availability.rb
|