Class: Rake::Delphi::Dcc32Task
Instance Attribute Summary collapse
-
#_source ⇒ Object
writeonly
Sets the attribute _source.
-
#bin ⇒ Object
Returns the value of attribute bin.
-
#exeoutput ⇒ Object
writeonly
Sets the attribute exeoutput.
-
#mainicon ⇒ Object
Returns the value of attribute mainicon.
-
#systempath ⇒ Object
Returns the value of attribute systempath.
Attributes inherited from Task
Instance Method Summary collapse
- #dcu=(value) ⇒ Object
- #execute(opts = nil) ⇒ Object
- #init(properties) ⇒ Object
- #init_libs(libs = nil) ⇒ Object
-
#initialize(name, application) ⇒ Dcc32Task
constructor
A new instance of Dcc32Task.
-
#reenable ⇒ Object
used in tests.
- #versionInfoClass ⇒ Object
Methods inherited from Task
#execute_base, #initialize_base, #out, #shortname, #trace?
Constructor Details
#initialize(name, application) ⇒ Dcc32Task
Returns a new instance of Dcc32Task.
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rake/delphi/dcc32.rb', line 61 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]) @platform = nil @dcc32Tool = Dcc32Tool.new end |
Instance Attribute Details
#_source=(value) ⇒ Object
Sets the attribute _source
48 49 50 |
# File 'lib/rake/delphi/dcc32.rb', line 48 def _source=(value) @_source = value end |
#bin ⇒ Object
Returns the value of attribute bin.
48 49 50 |
# File 'lib/rake/delphi/dcc32.rb', line 48 def bin @bin end |
#exeoutput=(value) ⇒ Object
Sets the attribute exeoutput
48 49 50 |
# File 'lib/rake/delphi/dcc32.rb', line 48 def exeoutput=(value) @exeoutput = value end |
#mainicon ⇒ Object
Returns the value of attribute mainicon.
48 49 50 |
# File 'lib/rake/delphi/dcc32.rb', line 48 def mainicon @mainicon end |
#systempath ⇒ Object
Returns the value of attribute systempath.
48 49 50 |
# File 'lib/rake/delphi/dcc32.rb', line 48 def systempath @systempath end |
Instance Method Details
#dcu=(value) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/rake/delphi/dcc32.rb', line 83 def dcu=(value) # delete previously defined @prerequisites.delete_if do |d| if d.kind_of?(Rake::FileCreationTask) d.name.casecmp(@dcu) == 0 end end @dcu = value dcu_task = directory @dcu enhance([dcu_task]) end |
#execute(opts = nil) ⇒ Object
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
# File 'lib/rake/delphi/dcc32.rb', line 276 def execute(opts=nil) super @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(Logger.debug?) do begin unless @usecfg cfg = @systempath.pathmap('%X.cfg') bak_cfg = @systempath.pathmap('%X.rake.cfg') if File.exists?(cfg) mv cfg, bak_cfg else warn "WARNING! Config #{cfg} is absent!" end 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 end end sh cmd ensure unless @usecfg begin cp cfg, cfg + '.1' if trace? ensure mv bak_cfg, cfg if File.exists?(bak_cfg) end end end end end puts '' # make one empty string to separate from further lines end |
#init(properties) ⇒ Object
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 258 259 260 261 262 263 |
# File 'lib/rake/delphi/dcc32.rb', line 225 def init(properties) Logger.trace(Logger::TRACE, properties) properties.map do |key, value| begin send("#{key}=", value) rescue NoMethodError instance_variable_set("@#{key}", value) end end @_source = properties[:projectfile].pathmap('%X.dpr') src = @_source.gsub('\\', '/') # make sure to create dir for output dcu # for now default is <PROJECTDIR>/dcu self.dcu = src.pathmap('%d%sdcu') unless @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] @rc_task.mainicon_path = @mainicon 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
265 266 267 268 269 270 271 272 273 274 |
# File 'lib/rake/delphi/dcc32.rb', line 265 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 |
#reenable ⇒ Object
used in tests
73 74 75 76 77 |
# File 'lib/rake/delphi/dcc32.rb', line 73 def reenable # recreate Dcc32Tool to reinitialize paths to tool @dcc32Tool = Dcc32Tool.new(true) super end |
#versionInfoClass ⇒ Object
79 80 81 |
# File 'lib/rake/delphi/dcc32.rb', line 79 def versionInfoClass @dcc32Tool.versionInfoClass end |