Permalink
Browse files

Cleanup method missing hack and add tests for ldshared and cflags acc…

…essors

git-svn-id: http://mkrf.rubyforge.org/svn/trunk@34 6e48df83-f314-0410-b1e7-e69642b30866
  • Loading branch information...
1 parent 6ace065 commit 9524066463d1641910d6c20349dc3a1d183a2a41 kevinclark committed Oct 5, 2006
Showing with 29 additions and 10 deletions.
  1. +10 −9 lib/mkrf/availability.rb
  2. +1 −1 lib/mkrf/generator.rb
  3. +18 −0 test/unit/test_generator.rb
View
@@ -107,13 +107,16 @@ def can_link?(function_body)
FileUtils.rm_f TEMP_EXECUTABLE
end
- def method_missing(method, *args, &b)
- if match = /^with_([_a-zA-Z]\w*)$/.match(method.to_s)
- super unless STACKABLE_ATTRIBUTES.include? match[1]
- with_stackable_attribute(match[1], *args, &b)
- else
- super
- end
+ def with_headers(*args, &b)
+ with_stackable_attribute('headers', *args, &b)
+ end
+
+ def with_loaded_libs(*args, &b)
+ with_stackable_attribute('loaded_libs', *args, &b)
+ end
+
+ def with_includes(*args, &b)
+ with_stackable_attribute('includes', *args, &b)
end
# Returns a string of libraries formatted for compilation
@@ -179,8 +182,6 @@ def header_found_in_paths?(header, paths)
return false
end
- STACKABLE_ATTRIBUTES = ['loaded_libs', 'headers', 'includes']
-
def with_stackable_attribute(attribute, *args)
args = args.to_a
instance_variable_set("@#{attribute}",
View
@@ -161,7 +161,7 @@ def rakefile_contents # :nodoc:
LIBS = "#{@available.library_compile_string}"
-CFLAGS = "#{cflags} #{defines_compile_string}"
+CFLAGS = "#{cflags} #{defines_compile_string}"
task :default => ['#{@extension_name}']
@@ -64,6 +64,24 @@ def test_additional_objects
assert_match obj_string, generator.rakefile_contents
end
+ def test_ldshared
+ ldshared = 'this_normally_isnt_here'
+ generator = Mkrf::Generator.new('testlib') do |g|
+ g.ldshared = ldshared
+ end
+
+ assert_match Regexp.new("LDSHARED = .*#{ldshared}.*"), generator.rakefile_contents
+ end
+
+ def test_cflags
+ cflags = 'this_normally_isnt_here'
+ generator = Mkrf::Generator.new('testlib') do |g|
+ g.cflags = cflags
+ end
+
+ assert_match Regexp.new("CFLAGS = .*#{cflags}.*"), generator.rakefile_contents
+ end
+
protected
def spec_code

0 comments on commit 9524066

Please sign in to comment.