class Rake::Delphi::Dcc32Task
Attributes
_source[RW]
bin[RW]
dccTool[R]
exeoutput[RW]
mainicon[RW]
systempath[RW]
Public Class Methods
new(name, application)
click to toggle source
Calls superclass method
Rake::Task::new
# 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
Public Instance Methods
createVersionInfo()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 63 def createVersionInfo versionInfoClass.new(self) end
dcu=(value)
click to toggle source
# 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.expand_path(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()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 256 def dpr @_source end
execute(opts=nil)
click to toggle source
Calls superclass method
Rake::Task#execute
# File lib/rake/delphi/dcc32.rb, line 298 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| lpaths = paths Logger.trace(Logger::TRACE, 'Implicit and included paths:') Logger.trace(Logger::TRACE, lpaths) lpaths.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)
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 260 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)
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 287 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)
click to toggle source
# 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)
click to toggle source
# 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()
click to toggle source
used in tests
Calls superclass method
# File lib/rake/delphi/dcc32.rb, line 53 def reenable # recreate Dcc32Tool to reinitialize paths to tool recreate_dcc_tool(true) super end
versionInfoClass()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 59 def versionInfoClass @dccTool.versionInfoClass end
Private Instance Methods
_aliases()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 168 def _aliases return @aliases ? Rake.quotepath('-A', @aliases) : '' end
_alldebuginfo()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 193 def _alldebuginfo return @debuginfo.nil? ? '' : (@debuginfo ? '-$D+ -$L+ -$YD' : '-$D- -$L- -$Y-') end
_complete_booleans()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 217 def _complete_booleans return @boolean.nil? ? '' : ('-$B' + (@boolean == :full ? '+' : '-')) end
_dcuoutput()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 176 def _dcuoutput return @dcuoutput || @dcu || @_source.pathmap('%d%sdcu') end
_defines()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 209 def _defines '-D' + @defines if @defines end
_map()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 184 def _map # segments -> -GS # publics -> -GP # detailed -> -GD return unless @map segments = @map.to_s[0..0].upcase return '-G' + segments end
_namespaces()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 172 def _namespaces return @namespaces ? Rake.quotepath('-NS', @namespaces) : '' end
_paths(ppaths)
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 122 def _paths(ppaths) ppaths = ppaths.dup ppaths.map! do |p| a = [] ['U', 'I', 'R', 'O'].each do |s| a << Rake.quotepath("-#{s}", p) end a end # unique paths only ppaths.flatten!.uniq! ppaths end
_writeableconst()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 213 def _writeableconst return '-$J' + (@writeableconst ? '+' : '-') end
add_resources(src, properties)
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 231 def add_resources(src, properties) 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) input, output = res.split(':', 2) rc_task_add.input = src.pathmap('%d%s') + input if output # if extension is present set it to output rc_task_add.output = rc_task_add.output.pathmap('%d%s') + output end end enhance([rc_task_add]) end end
build?()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 152 def build? return @build ? '-B' : '-M' end
build_args()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 221 def build_args args = [] args << @dccTool.options << dcc_options << build? << console? args << warnings? << hints? << quiet? << debug? << _alldebuginfo << _map args << _defines << _writeableconst << _complete_booleans args << _aliases << _namespaces args << _source << outputs << implicitpaths args.flatten end
console?()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 180 def console? return @console.nil? ? '' : (@console ? '-CC' : '-CG') end
debug?()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 148 def debug? return @debug ? '-$D+ -$L+ -$YD -$C+ -$Q+ -$R+ -$O- -GD' : '' end
delphilibs()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 118 def delphilibs return [@dccTool.delphilib] | @dccTool.readLibraryPaths(@platform, @platform_stripped) end
hints?()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 160 def hints? return @hints ? '-H-' : '-H+' end
implicitpaths()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 136 def implicitpaths ipaths = ['.', '..'] Logger.trace(Logger::TRACE, 'Using library paths? %s' % (@uselibrarypath ? 'YES' : 'NO')) ipaths |= delphilibs if @uselibrarypath _paths(ipaths) end
initvars()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 111 def initvars @exeoutput = nil @@symbols.map do |sym| instance_variable_set("@#{sym.to_s}", nil) end end
outputs()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 197 def outputs os = [] os << Rake.quotepath('-E', exeoutput) os << Rake.quotepath('-N', _dcuoutput) os << Rake.quotepath('-LE', @bploutput) return os end
paths()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 143 def paths @includepaths ||= [] _paths(@includepaths) end
quiet?()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 164 def quiet? return @quiet ? '-Q' : '' end
warnings?()
click to toggle source
# File lib/rake/delphi/dcc32.rb, line 156 def warnings? return @warnings ? '-W-' : '-W+' end