Class: Mkrf::Generator
- Inherits:
-
Object
- Object
- Mkrf::Generator
- Defined in:
- ext/mkrf-monkey.rb
Instance Method Summary collapse
-
#rakefile_contents ⇒ Object
:nodoc:.
Instance Method Details
#rakefile_contents ⇒ Object
:nodoc:
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'ext/mkrf-monkey.rb', line 9 def rakefile_contents # :nodoc: objext = CONFIG['OBJEXT'] cc = CONFIG['CC'] || 'gcc' cpp = CONFIG['CXX'] || 'g++' extension_sym = File.basename( @extension_name, ".#{CONFIG['DLEXT']}" ).to_sym <<-END_RAKEFILE # Generated by mkrf, monkey patched for opencv-ffi require 'rake/clean' SRC = FileList[#{sources.join(',')}] OBJ = SRC.ext('#{objext}') CC = '#{cc}' CPP = '#{cpp}' CLEAN.include(OBJ) CLOBBER.include('#{@extension_name}', 'mkrf.log', 'Rakefile') ADDITIONAL_OBJECTS = '#{objects}' LDSHARED = "#{@available.ldshared_string} #{ldshared}" LIBPATH = "#{library_path(CONFIG['libdir'])} #{@available.library_paths_compile_string}" INCLUDES = "#{@available.includes_compile_string}" LIBS = "#{@available.library_compile_string}" CFLAGS = "#{cflags} #{defines_compile_string}" RUBYARCHDIR = "\#{ENV["RUBYARCHDIR"]}" LIBRUBYARG_SHARED = "#{CONFIG['LIBRUBYARG_SHARED']}" task :default => :build_library # Add one layer of indirection so I can generically call "rake build_library" # and have it work ... or not work if the wrong rakefile is being run task :build_library => '#{@extension_name}' rule '.#{objext}' => '.c' do |t| sh "\#{CC} \#{CFLAGS} \#{INCLUDES} -o \#{t.name} -c \#{t.source}" end rule '.#{objext}' => '.cpp' do |t| sh "\#{CPP} \#{CFLAGS} \#{INCLUDES} -o \#{t.name} -c \#{t.source}" end DEPS = OBJ.clone.add('Rakefile') desc "Build this extension" file '#{@extension_name}' => DEPS do sh "\#{LDSHARED} \#{LIBPATH} #{@available.ld_outfile(@extension_name)} \#{OBJ} \#{ADDITIONAL_OBJECTS} \#{LIBS} \#{LIBRUBYARG_SHARED}" end desc "Rebuild rakefile" file 'Rakefile' => 'mkrf_conf.rb' do |t| ruby 'mkrf_conf.rb' puts "Rebuilt Rakefile. Run \'rake #{extension_sym.to_s}\' again" end desc "Install this extension" task :install => '#{@extension_name}' do makedirs "\#{RUBYARCHDIR}" install "#{@extension_name}", "\#{RUBYARCHDIR}" end #{additional_code} END_RAKEFILE end |