Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make availability accessable in Generator

git-svn-id: http://mkrf.rubyforge.org/svn/trunk@28 6e48df83-f314-0410-b1e7-e69642b30866
  • Loading branch information...
commit aec193eec520211cbfc351c3392ddc91b999f73e 1 parent 70a5595
kevinclark authored
View
1  CHANGELOG
@@ -1,4 +1,5 @@
= 0.1.1 8/17/06
+* [FIXED] Can now modify Availability options from the Generator contructor. This may break some existing extconfs that use the .new('libname','file_pattern_a', 'file_pattern_b') syntax. File patterns now only belong as arg 2 and should be an array or a string.
* [FIXED] No indenting generated Rakefile code. [26]
* [NEW] Logging! [22]
* [NEW] Added a description to the extension building task [21]
View
18 TODO
@@ -0,0 +1,18 @@
+* install task for output Rakefile
+* command-line configuration options
+
+BUGS
+* Fix libpath (shouldn't default to /usr/local/lib)
+
+
+From Tim Hunter:
+
+I'm trying to write a Rakefile for RMagick with mkrf. The first thing I miss is the equivalent of autoconf's AC_CHECK_PROGS. I think this is the find_executable method in mkmf
+
+It would also be nice to have some kind of automatic option processing for --with-THING, --without-THING, --enable-THING, --disable-THING options.
+
+Two more things.
+
+1) How do I add arbitrary strings to the gcc options such as the values of LDFLAGS, CPPFLAGS, and CFLAGS?
+
+2) RMagick uses about 100 feature test symbols (HAVE_xxx, etc.), too many to specify on the command line. It must be possible to create a configuration header file from a template, like the file created by AC_CONFIG_HEADERS.
View
2  lib/mkrf/availability.rb
@@ -25,7 +25,7 @@ class Availability
# * <tt>:compiler</tt> -- which compiler to use when determining availability
# * <tt>:includes</tt> -- directories that should be searched for include files
def initialize(options = {})
- @loaded_libs = options[:loaded_libs] || DEFAULT_LIBS
+ @loaded_libs = options[:loaded_libs].to_a || DEFAULT_LIBS
@headers = options[:headers] || []
@compiler = options[:compiler] || "gcc"
@includes = (options[:includes].to_a) || []
View
12 lib/mkrf/generator.rb
@@ -38,12 +38,14 @@ class Generator
#
# Params:
# * +extension_name+ -- the name of the extension
- # * +source_patterns+ -- a pattern describing source files to be compiled, "lib/*.c" by default
- def initialize(extension_name, *source_patterns)
- @sources = (source_patterns.empty? ? ["lib/*.c"] : source_patterns)
+ # * +source_patterns+ -- an array of patterns describing source files to be compiled, ["lib/*.c"] by default
+ def initialize(extension_name, source_patterns = ["lib/*.c"], availability_options = {})
+ @sources = source_patterns
@extension_name = extension_name + ".#{CONFIG['DLEXT']}"
- @available = Mkrf::Availability.new(:includes => [CONFIG['includedir'], CONFIG["archdir"],
- CONFIG['sitelibdir'], "."] )
+ default_availability_options = {
+ :includes => [CONFIG['includedir'], CONFIG["archdir"], CONFIG['sitelibdir'], "."]
+ }
+ @available = Mkrf::Availability.new(default_availability_options.merge(availability_options))
@defines = []
yield self if block_given?
View
7 test/test_generator.rb
@@ -5,6 +5,8 @@ module Mkrf
class Generator
def write_rakefile(file = "Rakefile")
end
+
+ attr_reader :available
end
end
@@ -48,6 +50,11 @@ def test_logging_defaults_to_info_level
assert_match(/WARN/, logs)
end
+ def test_availability_options_accessible_in_initialize
+ generator = Mkrf::Generator.new('testlib', ['lib/*.c'], {:loaded_libs => 'static_ruby'})
+ assert_equal ['static_ruby'], generator.available.loaded_libs
+ end
+
protected
def spec_code

0 comments on commit aec193e

Please sign in to comment.
Something went wrong with that request. Please try again.