Class: Rake::ExtensionTask

Inherits:
BaseExtensionTask show all
Defined in:
lib/rake/extensiontask.rb

Instance Attribute Summary collapse

Attributes inherited from BaseExtensionTask

#config_options, #ext_dir, #gem_spec, #lib_dir, #name, #platform, #source_pattern, #tmp_dir

Instance Method Summary collapse

Methods inherited from BaseExtensionTask

#initialize

Constructor Details

This class inherits a constructor from Rake::BaseExtensionTask

Instance Attribute Details

#config_includesObject

Returns the value of attribute config_includes



16
17
18
# File 'lib/rake/extensiontask.rb', line 16

def config_includes
  @config_includes
end

#config_scriptObject

Returns the value of attribute config_script



11
12
13
# File 'lib/rake/extensiontask.rb', line 11

def config_script
  @config_script
end

#cross_compileObject

Returns the value of attribute cross_compile



12
13
14
# File 'lib/rake/extensiontask.rb', line 12

def cross_compile
  @cross_compile
end

#cross_config_optionsObject

Returns the value of attribute cross_config_options



14
15
16
# File 'lib/rake/extensiontask.rb', line 14

def cross_config_options
  @cross_config_options
end

#cross_platformObject

Returns the value of attribute cross_platform



13
14
15
# File 'lib/rake/extensiontask.rb', line 13

def cross_platform
  @cross_platform ||= 'i386-mingw32'
end

#no_nativeObject

Returns the value of attribute no_native



15
16
17
# File 'lib/rake/extensiontask.rb', line 15

def no_native
  @no_native
end

Instance Method Details

#binary(platform = nil) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rake/extensiontask.rb', line 38

def binary(platform = nil)
  if platform == "java"
	warn_once <<-EOF
Compiling a native C extension on JRuby. This is discouraged and a 
Java extension should be preferred.
    EOF
    "#{name}.#{RbConfig::MAKEFILE_CONFIG['DLEXT']}"
  else
    super
  end
end

#cross_compiling(&block) ⇒ Object



34
35
36
# File 'lib/rake/extensiontask.rb', line 34

def cross_compiling(&block)
  @cross_compiling = block if block_given?
end

#defineObject



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
# File 'lib/rake/extensiontask.rb', line 50

def define
  if (defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby')
    warn_once <<-EOF
WARNING: You're attempting to (cross-)compile C extensions from a platform
(#{RUBY_ENGINE}) that does not support native extensions or mkmf.rb.
Rerun `rake` under MRI Ruby 1.8.x/1.9.x to cross/native compile.
    EOF
    return
  end

  super

  unless compiled_files.empty?
    warn "WARNING: rake-compiler found compiled files in '#{@ext_dir}' directory. Please remove them."
  end

  # only gems with 'ruby' platforms are allowed to define native tasks
  define_native_tasks if !@no_native && (@gem_spec && @gem_spec.platform == 'ruby')

  # only define cross platform functionality when enabled
  return unless @cross_compile

  if cross_platform.is_a?(Array) then
    cross_platform.each { |platf| define_cross_platform_tasks(platf) }
  else
    define_cross_platform_tasks(cross_platform)
  end
end

#init(name = nil, gem_spec = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rake/extensiontask.rb', line 18

def init(name = nil, gem_spec = nil)
  super
  @config_script = 'extconf.rb'
  @source_pattern = "*.c"
  @compiled_pattern = "*.{o,obj,so,bundle,dSYM}"
  @cross_compile = false
  @cross_config_options = []
  @cross_compiling = nil
  @no_native = false
  @config_includes = []
end