class Rake::Delphi::XEVersionInfo

Public Instance Methods

deploymentfiles(platform, configuration) click to toggle source
# File lib/rake/delphi/projectinfo.rb, line 206
def deploymentfiles(platform, configuration)
  deployment = @content
  raise 'There is no deployment info! Cannot continue.' unless deployment
  ['ProjectExtensions', 'BorlandProject', 'Deployment'].each do |section|
    deployment = deployment[section]
    break unless deployment
  end
  warn "#{@file} have no deployment info" unless deployment
  files, classes = read_files_and_classes(deployment, platform)
  r = make_deployment(files, classes, configuration)
  return r
end

Private Instance Methods

is_special_class_for_bds_path(class_name) click to toggle source
# File lib/rake/delphi/projectinfo.rb, line 146
def is_special_class_for_bds_path(class_name)
  ['AndroidClassesDexFile', /AndroidLibnative.+/i].each do |templ|
    if templ.kind_of?(Regexp)
      r = templ.match(class_name)
    else
      r = templ == class_name
    end
    return r if r
  end
  return false
end
make_deployment(files, classes, configuration) click to toggle source
# File lib/rake/delphi/projectinfo.rb, line 158
def make_deployment(files, classes, configuration)
  r = []
  configuration = configuration.to_s
  if configuration.empty?
    warn 'WARNING! Platform configuration is not set, \'Debug\' is assumed!'
    configuration = 'Debug'
  end
  Logger.trace(Logger::TRACE, "Gathering deployment files for '#{configuration}'")
  configuration = configuration.downcase.to_sym
  files.each do |file, value|
    value = value[configuration]
    unless value
      Logger.trace(Logger::TRACE, "Skip #{file}: it has no entity for the configuration")
      next
    end
    value_class = value['Class']
    _class = classes[value_class]
    if ['AndroidGDBServer', 'ProjectAndroidManifest'].include?(value_class)
      Logger.trace(Logger::TRACE, "Skip '#{file}' of '#{value_class}'")
      next
    end
    if is_special_class_for_bds_path(value_class)
      # dirty hack for special classes
      # usually .dproj has full path to it
      # but we may have another path
      # so remove 'first' part
      Logger.trace(Logger::TRACE, "'#{file}' of '#{value_class}' is a special case: prepend with $(BDS)")
      file = file.gsub(/^.+(\\lib\\android\\)/, '$(BDS)\1')
    end
    remote_name = value['Platform'] ? value['Platform']['RemoteName'] : file.dos2unix_separator.pathmap('%f')
    remote_dir = nil
    if value_class == 'ProjectOutput'
      file = :project_so
    elsif value_class == 'ProjectFile'
      _class = value
    else
      remote_dir = value['Platform']['RemoteDir'] if value['Platform']
    end
    remote_dir =  _class['Platform']['RemoteDir'].to_s unless remote_dir
    remote_dir = remote_dir.empty? ? '.' : remote_dir
    remote_dir += '\\'
    r << { file => [remote_dir, '1', remote_name] }
  end
  warn "WARNING! There are no files for the platform configuration '#{configuration}'!" if r.empty?
  return r
end
read_file_class(platform, node, hash, key) click to toggle source
# File lib/rake/delphi/projectinfo.rb, line 100
def read_file_class(platform, node, hash, key)
  platforms = node['Platform']
  return unless platforms
  unless platforms.kind_of?(Array)
    platforms = [platforms]
  end
  platforms.each do |plat|
    if plat['Name'].casecmp(platform) == 0
      # take filename from hash by key
      value = node.delete(key)
      # delete Name (it is a filtered platform)
      plat.delete('Name')
      # update Platform
      node['Platform'] = plat
      node.delete('Platform') if plat.empty?
      configuration = node['Configuration']
      # for DeployFile's
      if configuration
        configuration = configuration.to_s.downcase.to_sym
        node.delete('Configuration')
        hash_node = hash[value]
        node = { configuration => node }
        node = hash_node.merge(node) if hash_node
      end
      hash.merge!({ value => node })
    end
  end
end
read_files_and_classes(deployment_content, platform) click to toggle source
# File lib/rake/delphi/projectinfo.rb, line 129
def read_files_and_classes(deployment_content, platform)
  files = {}
  classes = {}
  deployment_content.each do |k, v|
    if k == 'DeployFile'
      v.each do |file|
        read_file_class(platform, file, files, 'LocalName')
      end
    elsif k == 'DeployClass'
      v.each do |_class|
        read_file_class(platform, _class, classes, 'Name')
      end
    end
  end
  return files, classes
end