Class: Rake::Delphi::Dcc32Task
Instance Attribute Summary collapse
-
#_source ⇒ Object
writeonly
Sets the attribute _source.
-
#bin ⇒ Object
Returns the value of attribute bin.
-
#dccTool ⇒ Object
readonly
Returns the value of attribute dccTool.
-
#exeoutput ⇒ Object
Returns the value of 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
- #createVersionInfo ⇒ Object
- #dcu=(value) ⇒ Object
- #dpr ⇒ Object
- #execute(opts = nil) ⇒ Object
- #init(properties) ⇒ Object
- #init_libs(libs = nil) ⇒ Object
-
#initialize(name, application) ⇒ Dcc32Task
constructor
A new instance of Dcc32Task.
- #platform=(value) ⇒ Object
- #recreate_dcc_tool(checkExistance = false) ⇒ Object
-
#reenable ⇒ Object
used in tests.
- #versionInfoClass ⇒ Object
Methods inherited from Task
#execute_base, #initialize_base, #needed=, #needed?, #out, #reenable_chain, #shortname, #trace?
Constructor Details
#initialize(name, application) ⇒ Dcc32Task
Returns a new instance of Dcc32Task.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rake/delphi/dcc32.rb', line 32 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 @platform_stripped = nil @dccToolClass = nil recreate_dcc_tool end |
Instance Attribute Details
#_source=(value) ⇒ Object
Sets the attribute _source
17 18 19 |
# File 'lib/rake/delphi/dcc32.rb', line 17 def _source=(value) @_source = value end |
#bin ⇒ Object
Returns the value of attribute bin.
17 18 19 |
# File 'lib/rake/delphi/dcc32.rb', line 17 def bin @bin end |
#dccTool ⇒ Object (readonly)
Returns the value of attribute dccTool.
18 19 20 |
# File 'lib/rake/delphi/dcc32.rb', line 18 def dccTool @dccTool end |
#exeoutput ⇒ Object
Returns the value of attribute exeoutput.
17 18 19 |
# File 'lib/rake/delphi/dcc32.rb', line 17 def exeoutput @exeoutput end |
#mainicon ⇒ Object
Returns the value of attribute mainicon.
17 18 19 |
# File 'lib/rake/delphi/dcc32.rb', line 17 def mainicon @mainicon end |
#systempath ⇒ Object
Returns the value of attribute systempath.
17 18 19 |
# File 'lib/rake/delphi/dcc32.rb', line 17 def systempath @systempath end |
Instance Method Details
#createVersionInfo ⇒ Object
63 64 65 |
# File 'lib/rake/delphi/dcc32.rb', line 63 def createVersionInfo versionInfoClass.new(self) end |
#dcu=(value) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rake/delphi/dcc32.rb', line 67 def dcu=(value) # delete previously defined Logger.trace(Logger::TRACE, "New DCU set: #{value}") @prerequisites.delete_if do |d| if d.kind_of?(Rake::FileCreationTask) && d.name.casecmp(@dcu) == 0 Logger.trace(Logger::TRACE, "Removed previously defined DCU task: #{@dcu}") true end end @dcu = File.(value, dpr) Logger.trace(Logger::TRACE, "DPR path: #{dpr}") Logger.trace(Logger::TRACE, "Define new DCU task: #{@dcu}") dcu_task = directory @dcu enhance([dcu_task]) end |
#dpr ⇒ Object
249 250 251 |
# File 'lib/rake/delphi/dcc32.rb', line 249 def dpr @_source end |
#execute(opts = nil) ⇒ Object
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 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/rake/delphi/dcc32.rb', line 291 def execute(opts=nil) super recreate_dcc_tool @dccTool.class.checkToolFailure(@dccTool.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('', @dccTool.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
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
# File 'lib/rake/delphi/dcc32.rb', line 253 def init(properties) Logger.trace(Logger::TRACE, properties) # set @_source BEFORE properties @_source = properties[:projectfile].pathmap('%X.dpr') properties.map do |key, value| begin send("#{key}=", value) rescue NoMethodError instance_variable_set("@#{key}", value) end end src = @_source.dos2unix_separator # 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 add_resources(src, properties) end |
#init_libs(libs = nil) ⇒ Object
280 281 282 283 284 285 286 287 288 289 |
# File 'lib/rake/delphi/dcc32.rb', line 280 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 |
#platform=(value) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/rake/delphi/dcc32.rb', line 83 def platform=(value) @platform = value Logger.trace(Logger::DEBUG, 'PLATFORM set: ' + value) # strip digits from platform name Android @platform_stripped = @platform @platform_stripped = @platform.gsub(/\d/, '') if @platform.downcase.starts_with?('android') @dccToolClass = nil post_needed = false if @platform_stripped.downcase.to_sym == :android # set dccaarm compiler tool for Android platform @dccToolClass = DccARMTool post_needed = true end # enable appropriate PAClientTask application[name + ':post'].needed = post_needed # for XE and above set default aliases and namespaces if EnvVariables.delphi_version >= DELPHI_VERSION_XE @aliases = 'Generics.Collections=System.Generics.Collections;Generics.Defaults=System.Generics.Defaults;WinTypes=Winapi.Windows;WinProcs=Winapi.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE' @namespaces = 'Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;System;Xml;Data;Datasnap;Web;Soap;Vcl' Logger.trace(Logger::TRACE, 'Aliases and namespaces are set for Delphi XE') end end |
#recreate_dcc_tool(checkExistance = false) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/rake/delphi/dcc32.rb', line 45 def recreate_dcc_tool(checkExistance = false) @dccToolClass ||= Dcc32Tool @dccToolClass.reinit @dccTool = @dccToolClass.new(checkExistance) Logger.trace(Logger::DEBUG, name + ': DCC tool set: ' + @dccToolClass.to_s) end |
#reenable ⇒ Object
used in tests
53 54 55 56 57 |
# File 'lib/rake/delphi/dcc32.rb', line 53 def reenable # recreate Dcc32Tool to reinitialize paths to tool recreate_dcc_tool(true) super end |
#versionInfoClass ⇒ Object
59 60 61 |
# File 'lib/rake/delphi/dcc32.rb', line 59 def versionInfoClass @dccTool.versionInfoClass end |