Class: Rake::Delphi::Dcc32Task

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

Instance Attribute Summary collapse

Attributes inherited from Task

#logger

Instance Method Summary collapse

Methods inherited from Task

#execute_base, #initialize_base, #out, #shortname, #trace?

Constructor Details

#initialize(name, application) ⇒ Dcc32Task

Returns a new instance of Dcc32Task.



46
47
48
49
50
51
52
53
54
# File 'lib/rake/delphi/dcc32.rb', line 46

def initialize(name, application)
    super
    initvars
    @arg_names = [:verbose]
    @rc_template_task = application.define_task(RCTemplateTask, shortname + ':rc:template')
    @rc_task = application.define_task(RCTask, shortname + ':rc')
    enhance([@rc_template_task, @rc_task])
    @dcc32Tool = Dcc32Tool.new
end

Instance Attribute Details

#_source=(value) ⇒ Object

Sets the attribute _source

Parameters:

  • value

    the value to set the attribute _source to.



33
34
35
# File 'lib/rake/delphi/dcc32.rb', line 33

def _source=(value)
  @_source = value
end

#binObject

Returns the value of attribute bin.



33
34
35
# File 'lib/rake/delphi/dcc32.rb', line 33

def bin
  @bin
end

#exeoutput=(value) ⇒ Object

Sets the attribute exeoutput

Parameters:

  • value

    the value to set the attribute exeoutput to.



33
34
35
# File 'lib/rake/delphi/dcc32.rb', line 33

def exeoutput=(value)
  @exeoutput = value
end

#mainiconObject

Returns the value of attribute mainicon.



33
34
35
# File 'lib/rake/delphi/dcc32.rb', line 33

def mainicon
  @mainicon
end

#systempathObject

Returns the value of attribute systempath.



33
34
35
# File 'lib/rake/delphi/dcc32.rb', line 33

def systempath
  @systempath
end

Instance Method Details

#execute(opts = nil) ⇒ Object



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/rake/delphi/dcc32.rb', line 214

def execute(opts=nil)
    @dcc32Tool.class.checkToolFailure(@dcc32Tool.toolpath)
    fail "Could not find #{_source} to compile" unless @_source && File.exists?(@_source)
    init_libs
    args = build_args
    # on cygwin $D is assumed as shell var
    # so escape $
    args.map! { |a| a.gsub('$', '\$') if a.kind_of?(String) } unless application.windows?
    args.compact!
    cmd = Rake.quotepath('', @dcc32Tool.toolpath)
    cmd << ([''] | args).join(' ')
    ChDir.new(self, File.dirname(@_source)) do |dir|
        RakeFileUtils.verbose(trace?) do
            begin
                unless @usecfg
                    cfg = @systempath.pathmap('%X.cfg')
                    bak_cfg = @systempath.pathmap('%X.rake.cfg')
                    mv cfg, bak_cfg
                    if @altercfg
                        cp @altercfg, cfg
                    end
                    # on Windows there is some limit on command line parameters length
                    # so we just append path parameters to config file
                    File.open(cfg, 'a+') do |f|
                        paths.each do |p|
                            f.write(p + "\n")
                        end
                        f.close
                    end
                end
                sh cmd
            ensure
                unless @usecfg
                    begin
                        cp cfg, cfg + '.1' if trace?
                    ensure
                        mv bak_cfg, cfg
                    end
                end
            end
        end
    end
    puts '' # make one empty string to separate from further lines
end

#init(properties) ⇒ Object



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/rake/delphi/dcc32.rb', line 166

def init(properties)
    pp properties if trace?
    properties.map do |key, value|
        instance_variable_set("@#{key}", value)
    end
    @_source = properties[:projectfile].pathmap('%X.dpr')
    src = @_source.gsub('\\', '/')
    dcu = src.pathmap('%d%sdcu')
    # make sure to create dir for output dcu
    # for now default is <PROJECTDIR>/dcu
    directory dcu
    enhance([dcu])
    # mainicon is usually requested by RCTemplate
    @mainicon ||= Rake.quotepath('', src.pathmap('%X.ico'))
    @rc_template_task.output = src
    @rc_template_task[:version] = properties[:version]
    @rc_template_task[:releaseCandidate] = properties[:releaseCandidate]
    @rc_task.input = src
    @rc_task.is_rc = properties[:releaseCandidate]
    return unless properties[:resources_additional]
    res_add = properties[:resources_additional]
    if res_add.kind_of?(String)
        res_add = res_add.split(';')
    end
    c = 0
    res_add.each do |res|
        if res.kind_of?(Symbol)
            rc_task_add = res
        else
            c = c.next
            rc_task_add = application.define_task(RCTask, shortname + ':rc:add' + c.to_s)
            rc_task_add.input = src.pathmap('%d%s') + res
        end
        enhance([rc_task_add])
    end
end

#init_libs(libs = nil) ⇒ Object



203
204
205
206
207
208
209
210
211
212
# File 'lib/rake/delphi/dcc32.rb', line 203

def init_libs(libs = nil)
    unless libs
        # call parent to find libs
        application[name.gsub(/:dcc32$/, '')].init_libs
    else
        # called from parent
        # set libs
        @includepaths = libs
    end
end

#versionInfoClassObject



56
57
58
# File 'lib/rake/delphi/dcc32.rb', line 56

def versionInfoClass
    @dcc32Tool.versionInfoClass
end