Class: Rake::Delphi::RCTask

Inherits:
Task
  • Object
show all
Defined in:
lib/rake/delphi/resources.rb

Instance Attribute Summary collapse

Attributes inherited from Task

#logger

Instance Method Summary collapse

Methods inherited from Task

#execute_base, #initialize_base, #needed=, #needed?, #out, #reenable_chain, #shortname, #trace?

Constructor Details

#initialize(name, app) ⇒ RCTask

Returns a new instance of RCTask.



100
101
102
103
104
105
# File 'lib/rake/delphi/resources.rb', line 100

def initialize(name, app)
    super
    @output = nil
    @is_rc = false
    @main_icon_path = nil
end

Instance Attribute Details

#inputObject

Returns the value of attribute input.



99
100
101
# File 'lib/rake/delphi/resources.rb', line 99

def input
  @input
end

#mainicon_pathObject

Returns the value of attribute mainicon_path.



99
100
101
# File 'lib/rake/delphi/resources.rb', line 99

def mainicon_path
  @mainicon_path
end

#outputObject

Returns the value of attribute output.



99
100
101
# File 'lib/rake/delphi/resources.rb', line 99

def output
  @output
end

Instance Method Details

#execute(args = nil) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/rake/delphi/resources.rb', line 125

def execute(args=nil)
    super
    v, path, tool = RCResourceCompiler.find(true)
    a = []
    a << '/dRC' if @is_rc
    a << '/dMAIN_ICON' if is_main_icon
    a |= ['/fo', Rake.quotepath('', output), '/r', Rake.quotepath('', input) ]
    opts = { :args => a }
    opts.merge!(args)
    cmd = ([Rake.quotepath('', tool)] | opts[:args]).join(' ')
    RakeFileUtils.verbose(Logger.debug?) do
        sh cmd
    end
end

#is_main_iconObject



116
117
118
119
120
121
122
123
# File 'lib/rake/delphi/resources.rb', line 116

def is_main_icon
    mainicon_path_unquoted = File.expand_path2(Rake.unquotepath(@mainicon_path), '-ml')
    is_main_icon = File.exists?(mainicon_path_unquoted)
    unless is_main_icon
        warn "WARNING! Icon file '#{mainicon_path_unquoted}' does not exists. Application icon is disabled."
    end
    return is_main_icon
end

#is_rc=(value) ⇒ Object



112
113
114
# File 'lib/rake/delphi/resources.rb', line 112

def is_rc=(value)
    @is_rc = ! value.to_s.empty?
end