Class: ExtconfTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/extconf_task.rb

Overview

Note:

ExtconfTask search files by the pattern “**/extconf.rb”

and create tasks for the found ‘extconf.rb’.

ExtconfTask.new do |et|

et.extconf_pattern = "pattern/extconf.rb"

end

ExtconfTask.new do |et|

et.extconf_paths << "path1/extconf.rb"
et.extconf_paths << "path2/extconf.rb"

end

Examples:

If you want to change the pattern, we write code as below.


If you want to specify paths of extconf.rb, we write code as below. At this time, extconf_pattern are ignored.


Constant Summary collapse

VERSION =
ExtconfTaskVersion::VERSION
DEFAULT_COMMAND_MAKE =
"make"
DEFAULT_COMMAND_RUBY =
"ruby"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ ExtconfTask

Returns a new instance of ExtconfTask.

Yields:

  • (_self)

Yield Parameters:

  • _self (ExtconfTask)

    the object that the method was called on



28
29
30
31
32
33
34
35
# File 'lib/extconf_task.rb', line 28

def initialize(&block)
  @extconf_pattern = "**/extconf.rb"
  @extconf_paths = []
  @command_ruby = nil
  @command_make = nil
  yield(self) if block_given?
  define
end

Instance Attribute Details

#command_makeObject

Returns the value of attribute command_make.



23
24
25
# File 'lib/extconf_task.rb', line 23

def command_make
  @command_make
end

#command_rubyObject

Returns the value of attribute command_ruby.



22
23
24
# File 'lib/extconf_task.rb', line 22

def command_ruby
  @command_ruby
end

#extconf_pathsObject (readonly)

Returns the value of attribute extconf_paths.



21
22
23
# File 'lib/extconf_task.rb', line 21

def extconf_paths
  @extconf_paths
end

#extconf_patternObject

Returns the value of attribute extconf_pattern.



20
21
22
# File 'lib/extconf_task.rb', line 20

def extconf_pattern
  @extconf_pattern
end

Instance Method Details

#defineObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/extconf_task.rb', line 78

def define
  desc "Create Makefile from extconf.rb"
  task "extconf:makefile" do |t|
    each_extconf_directory do |extconf|
      create_makefile(extconf)
    end
  end

  desc "Compile according to Makefile"
  task "extconf:compile" do |t|
    each_extconf_directory do |extconf|
      create_makefile(extconf)
      compile_according_to_makefile
    end
  end

  desc "Clean generated files (exclude Makefile)"
  task "extconf:clean" do |t|
    each_extconf_directory do |extconf|
      if makefile_exist?
        make("clean")
      end
    end
  end

  desc "Clean generated files (include Makefile)"
  task "extconf:distclean" do |t|
    each_extconf_directory do |extconf|
      if makefile_exist?
        make("distclean")
      end
    end
  end
end