class Detroit::ExtConf
The ExtConf
tool utilizes extconf.rb script and Autotools standard Makefile to compile native extensions.
Targets the following standard toolchain stations:
-
compile
-
clean
-
purge
@note By neccessity this tool shells out to the command line.
@todo Can we implement a win32 cross-compile?
Constants
- MAKE_COMMAND
Platform specific make command.
- MANPAGE
Location of manpage for tool.
Attributes
Compile statically? Applies only to compile method. (false)
Public Instance Methods
This tool ties into the `compile`, `clean` and `purge` stations of the standard assembly.
@return [Boolean]
# File lib/detroit-extconf.rb, line 107 def assemble?(station, options={}) return true if station == :compile return true if station == :clean return true if station == :purge return false end
Remove enough compile products for a clean compile.
# File lib/detroit-extconf.rb, line 67 def clean make 'clean' end
Compile extensions.
# File lib/detroit-extconf.rb, line 57 def compile configure if static make 'static' else make end end
Check to see if this project has extensions that need to be compiled.
# File lib/detroit-extconf.rb, line 83 def compiles? !extensions.empty? end
Create Makefile(s).
@return [void]
# File lib/detroit-extconf.rb, line 46 def configure extensions.each do |directory| next if File.exist?(File.join(directory, 'Makefile')) report "configuring #{directory}" cd(directory) do sh "ruby extconf.rb" end end end
Remove all compile products.
# File lib/detroit-extconf.rb, line 72 def distclean make 'distclean' extensions.each do |directory| makefile = File.join(directory, 'Makefile') rm(makefile) if File.exist?(makefile) end end
Extension directories. Often this will simply be 'ext'. but sometimes more then one extension is needed and are kept in separate directories. This works by looking for ext/*/.c files, where ever they are is considered an extension directory.
# File lib/detroit-extconf.rb, line 95 def extensions @extensions ||= Dir['ext/**/*.c'].collect{ |file| File.dirname(file) }.uniq end
Set attribute defaults.
@return [void]
# File lib/detroit-extconf.rb, line 36 def prerequisite @static = false end
Private Instance Methods
# File lib/detroit-extconf.rb, line 117 def make(target='') extensions.each do |directory| report "compiling #{directory}" cd(directory) do shell "#{MAKE_COMMAND} #{target}" end end end