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, #extra_options, #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_options(for_platform = nil) ⇒ Object


77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/rake/extensiontask.rb', line 77

def cross_config_options(for_platform=nil)
  return @cross_config_options unless for_platform

  # apply options for this platform, only
  @cross_config_options.map do |option|
    if option.kind_of?(Hash)
      option[for_platform] || []
    else
      option
    end
  end.flatten
end

#cross_platformObject


32
33
34
# File 'lib/rake/extensiontask.rb', line 32

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


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

def binary(platform = nil)
  if platform == "java"
    "#{name}.#{RbConfig::MAKEFILE_CONFIG['DLEXT']}"
  else
    super
  end
end

#cross_compiling(&block) ⇒ Object


36
37
38
# File 'lib/rake/extensiontask.rb', line 36

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

#defineObject


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

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

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