Class: Rake::Leaves::MakeTask

Inherits:
TaskLib
  • Object
show all
Defined in:
lib/leaves/gnu.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TaskLib

#upaste

Constructor Details

#initialize(name = nil) {|_self| ... } ⇒ MakeTask

Returns a new instance of MakeTask.

Yields:

  • (_self)

Yield Parameters:



19
20
21
22
23
24
# File 'lib/leaves/gnu.rb', line 19

def initialize(name = nil)
  @name = name
  
  yield self if block_given?
  define
end

Instance Attribute Details

#c_flagsObject

Returns the value of attribute c_flags.



16
17
18
# File 'lib/leaves/gnu.rb', line 16

def c_flags
  @c_flags
end

#disable_sharedObject

Returns the value of attribute disable_shared.



15
16
17
# File 'lib/leaves/gnu.rb', line 15

def disable_shared
  @disable_shared
end

#do_not_configureObject

Returns the value of attribute do_not_configure.



17
18
19
# File 'lib/leaves/gnu.rb', line 17

def do_not_configure
  @do_not_configure
end

#makefileObject

Returns the value of attribute makefile.



13
14
15
# File 'lib/leaves/gnu.rb', line 13

def makefile
  @makefile
end

#versionObject

Returns the value of attribute version.



14
15
16
# File 'lib/leaves/gnu.rb', line 14

def version
  @version
end

Instance Method Details

#defineObject



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 'lib/leaves/gnu.rb', line 26

def define
  desc "Build using GNU toolchain."
  task upaste("build", @name) => [upaste("compile", @name)]
  
  task upaste("compile", @name) do
    cmd = "make"
    cmd << " -f #{@makefile}" if @makefile
    
    sh cmd
  end
  task upaste("compile", @name) => [:dot_configure] unless @do_not_configure
  
  # autoreconf is used to generate configuration files.  As a result of its
  # execution, a configure script will be generated.  If the configure
  # script already exists, there is no reason to execute the command.
  unless @do_not_configure
    file_create "configure" do
      sh "autoreconf -i"
    end
    task :autoreconf => ["configure"]
  end
  
  # A configuration script is used during the system detection and makefile
  # generation phases.  As a result of its execution, a makefile will be
  # generated, which can be used to build the program.  If a makefile
  # already exists, there is no reason to execute the configure script.
  #
  # NOTE: The task is named "dot_configure" to avoid a conflict with the
  #       file creation task that must be named "configure"
  unless @do_not_configure
    file_create "Makefile" do
      cmd = ""
      cmd << "CFLAGS=\"#{@c_flags}\" " if @c_flags
      
      cmd << "./configure"
      cmd << " --with-version=\"#{@version}\"" if @version
      cmd << " --disable-shared" if @disable_shared
      
      sh cmd
    end
    task :dot_configure => [:autoreconf, "Makefile"]
  end
  
  task :clean do
    sh "make clean"
  end
  
  task :clobber do
    sh "make distclean"
  end
  
  self
end