mkrf 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/CHANGELOG +13 -0
  2. data/README +22 -15
  3. data/Rakefile +10 -1
  4. data/lib/mkrf/availability.rb +19 -15
  5. data/lib/mkrf/generator.rb +71 -50
  6. data/lib/mkrf.rb +1 -1
  7. data/test/{test_sample_projects.rb → integration/test_sample_projects.rb} +5 -5
  8. data/test/mkrf.log +1 -0
  9. data/test/sample_files/libtrivial/Rakefile +33 -0
  10. data/test/sample_files/libtrivial/libtrivial.bundle +0 -0
  11. data/test/sample_files/libtrivial/mkrf.log +2 -0
  12. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/Rakefile +33 -0
  13. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/cbg.o +0 -0
  14. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.o +0 -0
  15. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml_so.bundle +0 -0
  16. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/mkrf.log +21 -0
  17. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.o +0 -0
  18. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.o +0 -0
  19. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.o +0 -0
  20. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.o +0 -0
  21. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.o +0 -0
  22. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.o +0 -0
  23. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.o +0 -0
  24. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.o +0 -0
  25. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.o +0 -0
  26. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.o +0 -0
  27. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.o +0 -0
  28. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.o +0 -0
  29. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.o +0 -0
  30. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.o +0 -0
  31. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.o +0 -0
  32. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.o +0 -0
  33. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.o +0 -0
  34. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.o +0 -0
  35. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/Rakefile +33 -0
  36. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/bytecode.o +0 -0
  37. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/emitter.o +0 -0
  38. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/extconf.rb +0 -1
  39. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.o +0 -0
  40. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/handler.o +0 -0
  41. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/implicit.o +0 -0
  42. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/mkrf.log +3 -0
  43. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/node.o +0 -0
  44. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/rubyext.o +0 -0
  45. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.bundle +0 -0
  46. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.o +0 -0
  47. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/token.o +0 -0
  48. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yaml2byte.o +0 -0
  49. data/test/{test_availability.rb → unit/test_availability.rb} +25 -3
  50. data/test/{test_generator.rb → unit/test_generator.rb} +36 -2
  51. metadata +51 -7
data/CHANGELOG CHANGED
@@ -1,3 +1,16 @@
1
+ = 0.1.2 10/4/06
2
+ * [CLEAN-UP] Removed useless add_source from Generator. We've got a constructor for that. [35]
3
+ * [FIXED] Generator.new defaults to sources in the local directory, so extconfs can (and should) be kept in the same directory as the extension files (PROJ_ROOT/ext) and won't clobber pre-existing Rakefiles. [35]
4
+ * [CLEAN-UP] Goodbye ugly method missing hack! [34]
5
+ * [NEW] Added objs to Generator. Access it as you might ldshared. -John G.
6
+ * [CLEAN-UP] Removed the redundant .so rule from the generated rakefile. -John G.
7
+ * [FIXED] Correct defaults in Availability. [29]
8
+ * [NEW] Using rubylibdir from rbconfig for library path. [29]
9
+ * [NEW] Availability options go straight to availability without generator modification. [29]
10
+ * [NEW] CFLAGS and LDSHARED now accessible through .cflags and .ldshared. [29]
11
+ * [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.
12
+ * [FIXED] No indenting generated Rakefile code. [26]
13
+
1
14
  = 0.1.1 8/17/06
2
15
  * [NEW] Logging! [22]
3
16
  * [NEW] Added a description to the extension building task [21]
data/README CHANGED
@@ -1,37 +1,44 @@
1
1
  = mkrf -- making C extensions for Ruby a bit easier
2
2
 
3
- <tt>mkrf</tt> is intended to replace <tt>mkmf</tt>, a library for building
4
- Makefiles to build C extensions to Ruby. Its major goals are easy code reuse of
5
- its <tt>Availability</tt> class and simple, well documented, use of the
6
- <tt>Generator</tt> class for Rakefile generation for extensions.
3
+ <tt>mkrf</tt> is intended to replace <tt>mkmf</tt> which is a library for building
4
+ Makefiles to build C extensions to Ruby. The major differences between the two is
5
+ that +mkrf+ builds you a Rakefile instead of a Makefile, and also that +mkrf+
6
+ provides an object-oriented interface.
7
+
8
+ Major goals of mkrf are
9
+ * easy code reuse of its <tt>Availability</tt> class and
10
+ * simple, well documented, use of the <tt>Generator</tt> class.
7
11
 
8
12
  == Basic Usage
9
13
 
10
14
  <tt>mkrf</tt> works similarly to <tt>mkmf</tt> in that a user writes an
11
- extension configuration (usually <tt>extconf.rb</tt>) and then runs it, which
12
- generates a <tt>Rakefile</tt>.
15
+ extension configuration file (usually named <tt>extconf.rb</tt>) and then runs
16
+ it (<tt>ruby ./extconf.rb</tt>), which generates a <tt>Rakefile</tt> in the
17
+ current directory.
13
18
 
14
19
  In general, <tt>extconf.rb</tt> should be placed in the root directory of the
15
- extension and it expects by default that files to be compiled have a <tt>.c</tt>
16
- extension and are in the <tt>lib/</tt> directory.
20
+ extension (ex. <tt>PROJECT_ROOT/ext/<i>name_of_module</i></tt>) and it expects,
21
+ by default, that files to be compiled have a <tt>.c</tt> extension and reside in
22
+ that same directory. If your project contains multiple extension modules, then
23
+ each one would get its own subdirectory under <tt>PROJECT_ROOT/ext/</tt> and
24
+ have its own <tt>extconf.rb</tt> file.
17
25
 
18
- The most basic usage looks like this, with the name of the library to be linked
19
- as the first argument to <tt>Mkrf::Generator.new</tt>:
26
+ The most basic usage looks like the following, where the name of the extension
27
+ module being built is "libtrivial":
20
28
 
21
29
  require 'mkrf'
22
30
  Mkrf::Generator.new('libtrivial')
23
31
 
24
- Extra arguments may be passed to the generator in a block:
32
+ Extra arguments may be passed to the Rakefile generator in a block:
25
33
 
26
- Mkrf::Generator.new('libtrivial) do |g|
34
+ Mkrf::Generator.new('libtrivial') do |g|
27
35
  g.logger.level = Logger::WARN
28
36
  g.include_library('z')
29
37
  end
30
38
 
31
- If the extension does not follow the source in <tt>lib/</tt> / <tt>.c</tt>
32
- extension convention, it may be overridden in the constructor:
39
+ Another example:
33
40
 
34
- Mkrf::Generator.new('libxml', '*.c') do |g|
41
+ Mkrf::Generator.new('libxml') do |g|
35
42
  g.include_library('socket','socket')
36
43
  g.include_header('libxml/xmlversion.h',
37
44
  '/opt/include/libxml2',
data/Rakefile CHANGED
@@ -24,7 +24,14 @@ namespace :test do
24
24
 
25
25
  desc "Run basic tests"
26
26
  Rake::TestTask.new("units") { |t|
27
- t.pattern = 'test/test_*.rb'
27
+ t.pattern = 'test/unit/test_*.rb'
28
+ t.verbose = true
29
+ t.warning = true
30
+ }
31
+
32
+ desc "Run integration tests"
33
+ Rake::TestTask.new("integration") { |t|
34
+ t.pattern = 'test/integration/test_*.rb'
28
35
  t.verbose = true
29
36
  t.warning = true
30
37
  }
@@ -99,6 +106,8 @@ spec = Gem::Specification.new do |s|
99
106
  s.requirements << 'rake'
100
107
  s.require_path = 'lib'
101
108
  s.autorequire = 'mkrf'
109
+
110
+ s.extra_rdoc_files = [ "README", "MIT-LICENSE", "CHANGELOG" ]
102
111
 
103
112
  s.files = [ "Rakefile", "README", "CHANGELOG", "MIT-LICENSE" ]
104
113
  s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
@@ -9,8 +9,9 @@ module Mkrf
9
9
  # which need to determine functionality based on what libraries are available
10
10
  # on the current system.
11
11
  class Availability
12
- DEFAULT_LIBS = ["ruby", "dl"]
13
-
12
+ DEFAULT_INCLUDES = [Config::CONFIG['includedir'], Config::CONFIG["archdir"],
13
+ Config::CONFIG['sitelibdir'], "."]
14
+
14
15
  # These really shouldn't be static like this..
15
16
  TEMP_SOURCE_FILE = "temp_source.c"
16
17
  TEMP_EXECUTABLE = "temp_executable"
@@ -25,10 +26,12 @@ module Mkrf
25
26
  # * <tt>:compiler</tt> -- which compiler to use when determining availability
26
27
  # * <tt>:includes</tt> -- directories that should be searched for include files
27
28
  def initialize(options = {})
28
- @loaded_libs = options[:loaded_libs] || DEFAULT_LIBS
29
- @headers = options[:headers] || []
30
- @compiler = options[:compiler] || "gcc"
31
- @includes = (options[:includes].to_a) || []
29
+
30
+ @loaded_libs = (options[:loaded_libs] || Config::CONFIG["LIBS"].gsub('-l', '').split).to_a
31
+ # Not sure what COMMON_HEADERS looks like when populated
32
+ @headers = options[:headers] || [] # Config::CONFIG["COMMON_HEADERS"]
33
+ @compiler = options[:compiler] || Config::CONFIG["CC"]
34
+ @includes = (options[:includes] || DEFAULT_INCLUDES).to_a
32
35
  @logger = Logger.new('mkrf.log')
33
36
  end
34
37
 
@@ -104,13 +107,16 @@ module Mkrf
104
107
  FileUtils.rm_f TEMP_EXECUTABLE
105
108
  end
106
109
 
107
- def method_missing(method, *args, &b)
108
- if match = /^with_([_a-zA-Z]\w*)$/.match(method.to_s)
109
- super unless STACKABLE_ATTRIBUTES.include? match[1]
110
- with_stackable_attribute(match[1], *args, &b)
111
- else
112
- super
113
- end
110
+ def with_headers(*args, &b)
111
+ with_stackable_attribute('headers', *args, &b)
112
+ end
113
+
114
+ def with_loaded_libs(*args, &b)
115
+ with_stackable_attribute('loaded_libs', *args, &b)
116
+ end
117
+
118
+ def with_includes(*args, &b)
119
+ with_stackable_attribute('includes', *args, &b)
114
120
  end
115
121
 
116
122
  # Returns a string of libraries formatted for compilation
@@ -176,8 +182,6 @@ module Mkrf
176
182
  return false
177
183
  end
178
184
 
179
- STACKABLE_ATTRIBUTES = ['loaded_libs', 'headers', 'includes']
180
-
181
185
  def with_stackable_attribute(attribute, *args)
182
186
  args = args.to_a
183
187
  instance_variable_set("@#{attribute}",
@@ -6,9 +6,15 @@ require 'rake/tasklib'
6
6
  module Mkrf
7
7
 
8
8
  # +Generator+ is concerned with taking configuration for an extension
9
- # and writing a +Rakefile+ to the local filesystem to build the extension.
9
+ # and writing a +Rakefile+ to the local filesystem which will later be
10
+ # used to build the extension.
11
+ #
12
+ # You will typically only create one +Generator+ per <tt>extconf.rb</tt>
13
+ # file, which in turn will generate a Rakefile for building one extension
14
+ # module.
10
15
  #
11
16
  # = Usage
17
+ #
12
18
  # In the most basic usage, +Generator+ simply takes the name of the library
13
19
  # to compile:
14
20
  #
@@ -18,7 +24,7 @@ module Mkrf
18
24
  # Configuration of the build can be passed to the +Generator+ constructor
19
25
  # as a block:
20
26
  #
21
- # Mkrf::Generator.new('libxml', '*.c') do |g|
27
+ # Mkrf::Generator.new('libxml') do |g|
22
28
  # g.include_library('socket','socket')
23
29
  # g.include_header('libxml/xmlversion.h',
24
30
  # '/opt/include/libxml2',
@@ -31,30 +37,46 @@ module Mkrf
31
37
 
32
38
  CONFIG = Config::CONFIG
33
39
 
34
- attr_accessor :additional_code # Any extra code to be added to the Rakefile as a string
40
+ # Any extra code, given as a string, to be appended to the Rakefile.
41
+ attr_accessor :additional_code
42
+
43
+ # You may append to these attributes directly in your Generator.new block,
44
+ # for example: <tt>g.objects << ' ../common/foo.o ../common/bar.so -lmystuff'</tt> or
45
+ # <tt>g.cflags << ' -ansi -Wall'</tt>
46
+ #
47
+ # Note the extra space at the beginning of those strings.
48
+ attr_accessor :cflags
49
+
50
+ # +objects+ is for adding _additional_ object files to the link-edit command -- outside
51
+ # of the ones that correspond to the source files.
52
+ attr_accessor :objects
53
+
54
+ # Any additional options you'd like appended to your system-specific linker command
55
+ # (which is used to build the shared library).
56
+ attr_accessor :ldshared
57
+
58
+
35
59
 
36
- # Create a new generator which will write a new +Rakefile+ to the local
60
+ # Create a +Generator+ object which writes a Rakefile to the current directory of the local
37
61
  # filesystem.
38
62
  #
39
63
  # Params:
40
64
  # * +extension_name+ -- the name of the extension
41
- # * +source_patterns+ -- a pattern describing source files to be compiled, "lib/*.c" by default
42
- def initialize(extension_name, *source_patterns)
43
- @sources = (source_patterns.empty? ? ["lib/*.c"] : source_patterns)
65
+ # * +source_patterns+ -- an array of patterns describing source files to be compiled. ["*.c"] is the default.
66
+ def initialize(extension_name, source_patterns = ["*.c"], availability_options = {})
67
+ @sources = source_patterns
44
68
  @extension_name = extension_name + ".#{CONFIG['DLEXT']}"
45
- @available = Mkrf::Availability.new(:includes => [CONFIG['includedir'], CONFIG["archdir"],
46
- CONFIG['sitelibdir'], "."] )
69
+ @available = Mkrf::Availability.new(availability_options)
47
70
  @defines = []
48
71
 
72
+ objects = ''
73
+ ldshared = CONFIG['LDSHARED']
74
+ cflags = "#{CONFIG['CCDLFLAGS']} #{CONFIG['CFLAGS']} #{CONFIG['ARCH_FLAG']}"
75
+
49
76
  yield self if block_given?
50
77
  write_rakefile
51
78
  end
52
79
 
53
- # Add a new pattern to the list of source patterns
54
- def add_source(pattern)
55
- @sources << pattern
56
- end
57
-
58
80
  # An array of the source patterns as single quoted strings
59
81
  def sources
60
82
  @sources.collect {|s| "'#{s}'"}
@@ -62,7 +84,7 @@ module Mkrf
62
84
 
63
85
  # Add a define to the compile string. Example:
64
86
  #
65
- # Mkrf::Generator.new('my_library.bundle') do |g|
87
+ # Mkrf::Generator.new('my_library') do |g|
66
88
  # g.add_define(HAVE_PTHREADS)
67
89
  # end
68
90
  #
@@ -123,41 +145,40 @@ module Mkrf
123
145
 
124
146
  def rakefile_contents # :nodoc:
125
147
  <<-END_RAKEFILE
126
- require 'rake/clean'
127
-
128
- CLEAN.include('*.o')
129
- CLOBBER.include('#{@extension_name}', 'mkrf.log')
130
-
131
- SRC = FileList[#{sources.join(',')}]
132
- OBJ = SRC.ext('o')
133
- CC = "gcc"
134
-
135
- LDSHARED = "#{CONFIG['LDSHARED']}"
136
- LIBPATH = '-L"/usr/local/lib"'
137
-
138
- INCLUDES = "#{@available.includes_compile_string}"
139
-
140
- LIBS = "#{@available.library_compile_string}"
141
-
142
- CFLAGS = "#{CONFIG['CCDLFLAGS']} #{CONFIG['CFLAGS']} #{CONFIG['ARCH_FLAG']} #{defines_compile_string}"
143
-
144
- task :default => ['#{@extension_name}']
145
-
146
- rule '.o' => '.c' do |t|
147
- sh "\#{CC} \#{CFLAGS} \#{INCLUDES} -c -o \#{t.name} \#{t.source}"
148
- end
149
-
150
- rule '.so' => '.o' do |t|
151
- sh "\#{LDSHARED} \#{LIBPATH} -o \#{OBJ} \#{LOCAL_LIBS} \#{LIBS}"
152
- end
153
-
154
- desc "Build this extension"
155
- file '#{@extension_name}' => OBJ do
156
- sh "\#{LDSHARED} \#{LIBPATH} -o #{@extension_name} \#{OBJ} \#{LIBS}"
157
- end
158
-
159
- #{additional_code}
148
+ require 'rake/clean'
149
+
150
+ CLEAN.include('*.o')
151
+ CLOBBER.include('#{@extension_name}', 'mkrf.log')
152
+
153
+ SRC = FileList[#{sources.join(',')}]
154
+ OBJ = SRC.ext('o')
155
+ CC = "gcc"
156
+
157
+ ADDITIONAL_OBJECTS = '#{objects}'
158
+
159
+ LDSHARED = "#{CONFIG['LDSHARED']} #{ldshared}"
160
+
161
+ LIBPATH = '-L"#{CONFIG['rubylibdir']}"'
162
+
163
+ INCLUDES = "#{@available.includes_compile_string}"
164
+
165
+ LIBS = "#{@available.library_compile_string}"
166
+
167
+ CFLAGS = "#{cflags} #{defines_compile_string}"
168
+
169
+ task :default => ['#{@extension_name}']
170
+
171
+ rule '.o' => '.c' do |t|
172
+ sh "\#{CC} \#{CFLAGS} \#{INCLUDES} -c -o \#{t.name} \#{t.source}"
173
+ end
174
+
175
+ desc "Build this extension"
176
+ file '#{@extension_name}' => OBJ do
177
+ sh "\#{LDSHARED} \#{LIBPATH} -o #{@extension_name} \#{OBJ} \#{ADDITIONAL_OBJECTS} \#{LIBS}"
178
+ end
179
+
180
+ #{additional_code}
160
181
  END_RAKEFILE
161
182
  end
162
183
  end
163
- end
184
+ end
data/lib/mkrf.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  require File.dirname(__FILE__) + '/mkrf/availability'
2
2
  require File.dirname(__FILE__) + '/mkrf/generator'
3
3
 
4
- Mkrf::VERSION = "0.1.1"
4
+ Mkrf::VERSION = "0.1.2"
@@ -1,12 +1,12 @@
1
- require File.dirname(__FILE__) + '/abstract_unit'
1
+ require File.dirname(__FILE__) + '/../abstract_unit'
2
2
 
3
3
  class TestSampleProjects < Test::Unit::TestCase
4
- SAMPLES_DIR = File.dirname(__FILE__) + '/sample_files'
4
+ SAMPLES_DIR = File.dirname(__FILE__) + '/../sample_files'
5
5
 
6
6
  SAMPLE_LIBS = {
7
- :trivial => '/libtrivial/libtrivial.bundle',
8
- :syck => '/syck-0.55/ext/ruby/ext/syck/syck.bundle',
9
- :libxml => '/libxml-ruby-0.3.8/ext/xml/libxml_so.bundle'
7
+ :trivial => "/libtrivial/libtrivial.#{Config::CONFIG['DLEXT']}",
8
+ :syck => "/syck-0.55/ext/ruby/ext/syck/syck.#{Config::CONFIG['DLEXT']}",
9
+ :libxml => "/libxml-ruby-0.3.8/ext/xml/libxml_so.#{Config::CONFIG['DLEXT']}"
10
10
  }
11
11
 
12
12
  # Set to true for full command line output
data/test/mkrf.log ADDED
@@ -0,0 +1 @@
1
+ # Logfile created on Mon Sep 04 16:10:06 PDT 2006 by logger.rb/1.5.2.7
@@ -0,0 +1,33 @@
1
+ require 'rake/clean'
2
+
3
+ CLEAN.include('*.o')
4
+ CLOBBER.include('libtrivial.bundle', 'mkrf.log')
5
+
6
+ SRC = FileList['*.c']
7
+ OBJ = SRC.ext('o')
8
+ CC = "gcc"
9
+
10
+ ADDITIONAL_OBJECTS = ''
11
+
12
+ LDSHARED = "cc -dynamic -bundle -undefined suppress -flat_namespace "
13
+
14
+ LIBPATH = '-L"/usr/local/lib/ruby/1.8"'
15
+
16
+ INCLUDES = "-I/usr/local/include -I/usr/local/lib/ruby/1.8/i686-darwin8.6.1 -I/usr/local/lib/ruby/site_ruby/1.8 -I."
17
+
18
+ LIBS = "-lpthread -ldl -lobjc"
19
+
20
+ CFLAGS = " "
21
+
22
+ task :default => ['libtrivial.bundle']
23
+
24
+ rule '.o' => '.c' do |t|
25
+ sh "#{CC} #{CFLAGS} #{INCLUDES} -c -o #{t.name} #{t.source}"
26
+ end
27
+
28
+ desc "Build this extension"
29
+ file 'libtrivial.bundle' => OBJ do
30
+ sh "#{LDSHARED} #{LIBPATH} -o libtrivial.bundle #{OBJ} #{ADDITIONAL_OBJECTS} #{LIBS}"
31
+ end
32
+
33
+
@@ -0,0 +1,2 @@
1
+ # Logfile created on Wed Oct 04 18:07:33 PDT 2006 by logger.rb/1.5.2.7
2
+ I, [2006-10-04T18:07:33.115099 #20208] INFO -- : Rakefile written
@@ -0,0 +1,33 @@
1
+ require 'rake/clean'
2
+
3
+ CLEAN.include('*.o')
4
+ CLOBBER.include('libxml_so.bundle', 'mkrf.log')
5
+
6
+ SRC = FileList['*.c']
7
+ OBJ = SRC.ext('o')
8
+ CC = "gcc"
9
+
10
+ ADDITIONAL_OBJECTS = ''
11
+
12
+ LDSHARED = "cc -dynamic -bundle -undefined suppress -flat_namespace "
13
+
14
+ LIBPATH = '-L"/usr/local/lib/ruby/1.8"'
15
+
16
+ INCLUDES = "-I/usr/local/include -I/usr/local/lib/ruby/1.8/i686-darwin8.6.1 -I/usr/local/lib/ruby/site_ruby/1.8 -I. -I/usr/local/include/libxml2"
17
+
18
+ LIBS = "-lpthread -ldl -lobjc -lz -liconv -lxml2 -lxml2"
19
+
20
+ CFLAGS = " -DHAVE_ZLIB_H -DHAVE_LIBXML_XMLVERSION_H"
21
+
22
+ task :default => ['libxml_so.bundle']
23
+
24
+ rule '.o' => '.c' do |t|
25
+ sh "#{CC} #{CFLAGS} #{INCLUDES} -c -o #{t.name} #{t.source}"
26
+ end
27
+
28
+ desc "Build this extension"
29
+ file 'libxml_so.bundle' => OBJ do
30
+ sh "#{LDSHARED} #{LIBPATH} -o libxml_so.bundle #{OBJ} #{ADDITIONAL_OBJECTS} #{LIBS}"
31
+ end
32
+
33
+
@@ -0,0 +1,21 @@
1
+ # Logfile created on Wed Oct 04 18:07:24 PDT 2006 by logger.rb/1.5.2.7
2
+ I, [2006-10-04T18:07:24.726052 #19953] INFO -- : Checking for library: socket
3
+ W, [2006-10-04T18:07:24.899729 #19953] WARN -- : Function not found: socket()
4
+ W, [2006-10-04T18:07:24.899924 #19953] WARN -- : Library not found: socket
5
+ I, [2006-10-04T18:07:24.900035 #19953] INFO -- : Checking for library: nsl
6
+ W, [2006-10-04T18:07:25.077383 #19953] WARN -- : Function not found: gethostbyname()
7
+ W, [2006-10-04T18:07:25.077586 #19953] WARN -- : Library not found: nsl
8
+ I, [2006-10-04T18:07:25.077742 #19953] INFO -- : Checking for library: z
9
+ I, [2006-10-04T18:07:25.222610 #19953] INFO -- : Function found: inflate()
10
+ I, [2006-10-04T18:07:25.222960 #19953] INFO -- : Library found: z
11
+ I, [2006-10-04T18:07:25.223161 #19953] INFO -- : Checking for library: iconv
12
+ I, [2006-10-04T18:07:25.356626 #19953] INFO -- : Function found: iconv_open()
13
+ I, [2006-10-04T18:07:25.356894 #19953] INFO -- : Library found: iconv
14
+ I, [2006-10-04T18:07:25.357068 #19953] INFO -- : Checking for library: xml2
15
+ I, [2006-10-04T18:07:25.504460 #19953] INFO -- : Function found: xmlParseDoc()
16
+ I, [2006-10-04T18:07:25.504701 #19953] INFO -- : Library found: xml2
17
+ I, [2006-10-04T18:07:25.863306 #19953] INFO -- : Header found: libxml/xmlversion.h
18
+ I, [2006-10-04T18:07:25.863622 #19953] INFO -- : Checking for library: xml2
19
+ I, [2006-10-04T18:07:25.863692 #19953] INFO -- : Library already loaded: xml2
20
+ I, [2006-10-04T18:07:26.006086 #19953] INFO -- : Function found: docbCreateFileParserCtxt()
21
+ I, [2006-10-04T18:07:26.006870 #19953] INFO -- : Rakefile written
@@ -0,0 +1,33 @@
1
+ require 'rake/clean'
2
+
3
+ CLEAN.include('*.o')
4
+ CLOBBER.include('syck.bundle', 'mkrf.log')
5
+
6
+ SRC = FileList['*.c']
7
+ OBJ = SRC.ext('o')
8
+ CC = "gcc"
9
+
10
+ ADDITIONAL_OBJECTS = ''
11
+
12
+ LDSHARED = "cc -dynamic -bundle -undefined suppress -flat_namespace "
13
+
14
+ LIBPATH = '-L"/usr/local/lib/ruby/1.8"'
15
+
16
+ INCLUDES = "-I/usr/local/include -I/usr/local/lib/ruby/1.8/i686-darwin8.6.1 -I/usr/local/lib/ruby/site_ruby/1.8 -I."
17
+
18
+ LIBS = "-lpthread -ldl -lobjc"
19
+
20
+ CFLAGS = " -DHAVE_ST_H"
21
+
22
+ task :default => ['syck.bundle']
23
+
24
+ rule '.o' => '.c' do |t|
25
+ sh "#{CC} #{CFLAGS} #{INCLUDES} -c -o #{t.name} #{t.source}"
26
+ end
27
+
28
+ desc "Build this extension"
29
+ file 'syck.bundle' => OBJ do
30
+ sh "#{LDSHARED} #{LIBPATH} -o syck.bundle #{OBJ} #{ADDITIONAL_OBJECTS} #{LIBS}"
31
+ end
32
+
33
+
@@ -6,5 +6,4 @@ end
6
6
 
7
7
  Mkrf::Generator.new('syck') do |g|
8
8
  g.include_header("st.h")
9
- g.add_source('*.c') # We can actually do this in the contructor, but this tests add_source
10
9
  end
@@ -0,0 +1,3 @@
1
+ # Logfile created on Wed Oct 04 18:07:30 PDT 2006 by logger.rb/1.5.2.7
2
+ I, [2006-10-04T18:07:30.428737 #20126] INFO -- : Header found: st.h
3
+ I, [2006-10-04T18:07:30.429626 #20126] INFO -- : Rakefile written
@@ -1,9 +1,9 @@
1
- require File.dirname(__FILE__) + '/abstract_unit'
1
+ require File.dirname(__FILE__) + '/../abstract_unit'
2
2
 
3
3
 
4
4
  class TestAvailability < Test::Unit::TestCase
5
5
  def setup
6
- @avail = Mkrf::Availability.new(:includes => File.join(File.dirname(__FILE__), 'fixtures'))
6
+ @avail = Mkrf::Availability.new(:includes => File.join(File.dirname(__FILE__), '..', 'fixtures'))
7
7
  end
8
8
 
9
9
  def teardown
@@ -46,7 +46,7 @@ class TestAvailability < Test::Unit::TestCase
46
46
 
47
47
  def test_has_header_should_check_many_paths
48
48
  assert !@avail.has_header?('header_down_a_directory.h')
49
- assert @avail.has_header?('header_down_a_directory.h', File.join(File.dirname(__FILE__), 'fixtures', 'down_a_directory'))
49
+ assert @avail.has_header?('header_down_a_directory.h', File.join(File.dirname(__FILE__), '..', 'fixtures', 'down_a_directory'))
50
50
  end
51
51
 
52
52
  def test_include_header
@@ -94,4 +94,26 @@ class TestAvailability < Test::Unit::TestCase
94
94
  assert_match log_items, source
95
95
  end
96
96
  end
97
+ end
98
+
99
+ class TestAvailabilityDefaults < Test::Unit::TestCase
100
+ def setup
101
+ @avail = Mkrf::Availability.new
102
+ @config = Config::CONFIG
103
+ end
104
+
105
+ def test_default_libs_should_be_from_rbconfig
106
+ assert_equal @config["LIBS"].chomp(" "), @avail.library_compile_string
107
+ end
108
+
109
+ def test_default_compiler_should_be_from_rbconfig
110
+ assert_equal @config["CC"], @avail.send(:instance_variable_get, :@compiler)
111
+ end
112
+
113
+ def test_default_include_dir_should_be_from_rbconfig
114
+ expected = [Config::CONFIG['includedir'], Config::CONFIG["archdir"],
115
+ Config::CONFIG['sitelibdir'], "."]
116
+
117
+ assert_equal expected, @avail.send(:instance_variable_get, :@includes)
118
+ end
97
119
  end
@@ -1,10 +1,12 @@
1
- require File.dirname(__FILE__) + '/abstract_unit'
1
+ require File.dirname(__FILE__) + '/../abstract_unit'
2
2
 
3
3
  # stubb this out so we don't overwrite our test rakefile
4
4
  module Mkrf
5
5
  class Generator
6
6
  def write_rakefile(file = "Rakefile")
7
7
  end
8
+
9
+ attr_reader :available
8
10
  end
9
11
  end
10
12
 
@@ -15,7 +17,7 @@ class TestGenerator < Test::Unit::TestCase
15
17
 
16
18
  def test_default_sources
17
19
  g = Mkrf::Generator.new('testlib')
18
- assert_equal ["'lib/*.c'"], g.sources, "Default sources incorrect"
20
+ assert_equal ["'*.c'"], g.sources, "Default sources incorrect"
19
21
  end
20
22
 
21
23
  def test_additional_code
@@ -48,6 +50,38 @@ class TestGenerator < Test::Unit::TestCase
48
50
  assert_match(/WARN/, logs)
49
51
  end
50
52
 
53
+ def test_availability_options_accessible_in_initialize
54
+ generator = Mkrf::Generator.new('testlib', ['lib/*.c'], {:loaded_libs => 'static_ruby'})
55
+ assert_equal ['static_ruby'], generator.available.loaded_libs
56
+ end
57
+
58
+ def test_additional_objects
59
+ obj_string = 'somedir/somefile.o'
60
+ generator = Mkrf::Generator.new('testlib') do |g|
61
+ g.objects = obj_string
62
+ end
63
+
64
+ assert_match obj_string, generator.rakefile_contents
65
+ end
66
+
67
+ def test_ldshared
68
+ ldshared = 'this_normally_isnt_here'
69
+ generator = Mkrf::Generator.new('testlib') do |g|
70
+ g.ldshared = ldshared
71
+ end
72
+
73
+ assert_match Regexp.new("LDSHARED = .*#{ldshared}.*"), generator.rakefile_contents
74
+ end
75
+
76
+ def test_cflags
77
+ cflags = 'this_normally_isnt_here'
78
+ generator = Mkrf::Generator.new('testlib') do |g|
79
+ g.cflags = cflags
80
+ end
81
+
82
+ assert_match Regexp.new("CFLAGS = .*#{cflags}.*"), generator.rakefile_contents
83
+ end
84
+
51
85
  protected
52
86
 
53
87
  def spec_code
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: mkrf
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.1
7
- date: 2006-08-17 00:00:00 -07:00
6
+ version: 0.1.2
7
+ date: 2006-10-04 00:00:00 -07:00
8
8
  summary: Generate Rakefiles to Build C Extensions to Ruby
9
9
  require_paths:
10
10
  - lib
@@ -39,18 +39,22 @@ files:
39
39
  - lib/mkrf/generator.rb
40
40
  - test/abstract_unit.rb
41
41
  - test/fixtures
42
+ - test/integration
43
+ - test/mkrf.log
42
44
  - test/sample_files
43
- - test/test_availability.rb
44
- - test/test_generator.rb
45
- - test/test_sample_projects.rb
45
+ - test/unit
46
46
  - test/fixtures/down_a_directory
47
47
  - test/fixtures/stdmkrf.h
48
48
  - test/fixtures/down_a_directory/header_down_a_directory.h
49
+ - test/integration/test_sample_projects.rb
49
50
  - test/sample_files/libtrivial
50
51
  - test/sample_files/libxml-ruby-0.3.8
51
52
  - test/sample_files/syck-0.55
52
53
  - test/sample_files/libtrivial/extconf.rb
53
54
  - test/sample_files/libtrivial/lib
55
+ - test/sample_files/libtrivial/libtrivial.bundle
56
+ - test/sample_files/libtrivial/mkrf.log
57
+ - test/sample_files/libtrivial/Rakefile
54
58
  - test/sample_files/libtrivial/lib/libtrivial.c
55
59
  - test/sample_files/libtrivial/lib/libtrivial.o
56
60
  - test/sample_files/libxml-ruby-0.3.8/CHANGELOG
@@ -59,47 +63,70 @@ files:
59
63
  - test/sample_files/libxml-ruby-0.3.8/README
60
64
  - test/sample_files/libxml-ruby-0.3.8/ext/xml
61
65
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/cbg.c
66
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/cbg.o
62
67
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/extconf.rb
63
68
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.c
64
69
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.h
70
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.o
65
71
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.rb
72
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml_so.bundle
73
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/mkrf.log
66
74
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/old_extconf.rb
75
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/Rakefile
67
76
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.c
68
77
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.h
78
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.o
69
79
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.c
70
80
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.h
81
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.o
71
82
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.c
72
83
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.h
84
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.o
73
85
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.c
74
86
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.h
87
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.o
75
88
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.c
76
89
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.h
90
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.o
77
91
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.c
78
92
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.h
93
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.o
79
94
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.c
80
95
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.h
96
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.o
81
97
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.c
82
98
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.h
99
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.o
83
100
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.c
84
101
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.h
102
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.o
85
103
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.c
86
104
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.h
105
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.o
87
106
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.c
88
107
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.h
108
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.o
89
109
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.c
90
110
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.h
111
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.o
91
112
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.c
92
113
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.h
114
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.o
93
115
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.c
94
116
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.h
117
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.o
95
118
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.c
96
119
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.h
120
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.o
97
121
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.c
98
122
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.h
123
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.o
99
124
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.c
100
125
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.h
126
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.o
101
127
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.c
102
128
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.h
129
+ - test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.o
103
130
  - test/sample_files/libxml-ruby-0.3.8/ext/xml/sax_parser_callbacks.inc
104
131
  - test/sample_files/syck-0.55/aclocal.m4
105
132
  - test/sample_files/syck-0.55/bootstrap
@@ -138,19 +165,32 @@ files:
138
165
  - test/sample_files/syck-0.55/ext/ruby/yts
139
166
  - test/sample_files/syck-0.55/ext/ruby/ext/syck
140
167
  - test/sample_files/syck-0.55/ext/ruby/ext/syck/bytecode.c
168
+ - test/sample_files/syck-0.55/ext/ruby/ext/syck/bytecode.o
141
169
  - test/sample_files/syck-0.55/ext/ruby/ext/syck/emitter.c
170
+ - test/sample_files/syck-0.55/ext/ruby/ext/syck/emitter.o
142
171
  - test/sample_files/syck-0.55/ext/ruby/ext/syck/extconf.rb
143
172
  - test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.c
144
173
  - test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.h
174
+ - test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.o
145
175
  - test/sample_files/syck-0.55/ext/ruby/ext/syck/handler.c
176
+ - test/sample_files/syck-0.55/ext/ruby/ext/syck/handler.o
146
177
  - test/sample_files/syck-0.55/ext/ruby/ext/syck/implicit.c
178
+ - test/sample_files/syck-0.55/ext/ruby/ext/syck/implicit.o
147
179
  - test/sample_files/syck-0.55/ext/ruby/ext/syck/MANIFEST
180
+ - test/sample_files/syck-0.55/ext/ruby/ext/syck/mkrf.log
148
181
  - test/sample_files/syck-0.55/ext/ruby/ext/syck/node.c
182
+ - test/sample_files/syck-0.55/ext/ruby/ext/syck/node.o
183
+ - test/sample_files/syck-0.55/ext/ruby/ext/syck/Rakefile
149
184
  - test/sample_files/syck-0.55/ext/ruby/ext/syck/rubyext.c
185
+ - test/sample_files/syck-0.55/ext/ruby/ext/syck/rubyext.o
186
+ - test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.bundle
150
187
  - test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.c
151
188
  - test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.h
189
+ - test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.o
152
190
  - test/sample_files/syck-0.55/ext/ruby/ext/syck/token.c
191
+ - test/sample_files/syck-0.55/ext/ruby/ext/syck/token.o
153
192
  - test/sample_files/syck-0.55/ext/ruby/ext/syck/yaml2byte.c
193
+ - test/sample_files/syck-0.55/ext/ruby/ext/syck/yaml2byte.o
154
194
  - test/sample_files/syck-0.55/ext/ruby/ext/syck/yamlbyte.h
155
195
  - test/sample_files/syck-0.55/ext/ruby/lib/okay
156
196
  - test/sample_files/syck-0.55/ext/ruby/lib/okay.rb
@@ -233,12 +273,16 @@ files:
233
273
  - test/sample_files/syck-0.55/tests/YTS.c
234
274
  - test/sample_files/syck-0.55/tests/YTS.c.erb
235
275
  - test/sample_files/syck-0.55/tests/YTS.c.rb
276
+ - test/unit/test_availability.rb
277
+ - test/unit/test_generator.rb
236
278
  test_files: []
237
279
 
238
280
  rdoc_options: []
239
281
 
240
- extra_rdoc_files: []
241
-
282
+ extra_rdoc_files:
283
+ - README
284
+ - MIT-LICENSE
285
+ - CHANGELOG
242
286
  executables: []
243
287
 
244
288
  extensions: []