Class: Delphi::GroupProj

Inherits:
Object
  • Object
show all
Defined in:
lib/delphi/groupproj.rb

Overview

Class to load and compile dproj files

The RW properties of this class can be changed to modify the compilation behaviour of a project, but they will not be saved back to the dproj file - it is read only.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ GroupProj

Returns a new instance of GroupProj.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/delphi/groupproj.rb', line 15

def initialize(filename)
  @filename = filename
  fail "#{filename} not found" unless File.exist?(filename)

  load
  fail "#{filename} is empty" if projects == []

  # Load one project to initialize the environment

  dproj0 = File.join(File.dirname(filename), projects[0])
  @p = Delphi::Project.new(dproj0)
  @fail_on_hints_and_warnings = true
end

Instance Attribute Details

#fail_on_hints_and_warningsObject

Reader for the compiler setting



45
46
47
# File 'lib/delphi/groupproj.rb', line 45

def fail_on_hints_and_warnings
  @fail_on_hints_and_warnings
end

Instance Method Details

#compileObject

Compile all projects in this group.



29
30
31
32
# File 'lib/delphi/groupproj.rb', line 29

def compile
  puts 'Compiling groupproj'
  compiler.compile_group(@filename, target) if compiler
end

#fail_on_errorsObject

Reader for the compiler setting



35
36
37
# File 'lib/delphi/groupproj.rb', line 35

def fail_on_errors
  compiler.fail_on_errors
end

#fail_on_errors=(value) ⇒ Object

Setter for the compiler setting



40
41
42
# File 'lib/delphi/groupproj.rb', line 40

def fail_on_errors=(value)
  compiler.fail_on_errors = value
end

#projectsObject

Returns an array of dproj filenames in this group.



55
56
57
58
59
60
# File 'lib/delphi/groupproj.rb', line 55

def projects
  path = '/Project/ItemGroup/Projects'
  result = []
  @doc.elements.each(path) { |element| result << element.attributes['Include'] }
  result
end

#targetObject

Read the current compilation target for this group



63
64
65
# File 'lib/delphi/groupproj.rb', line 63

def target
  @p.target
end

#target=(value) ⇒ Object

Set the compilation target for this group



68
69
70
# File 'lib/delphi/groupproj.rb', line 68

def target=(value)
  @p.target = value
end

#targetsObject

Returns an array of valid compile targets (Clean, Compile, Build)



73
74
75
# File 'lib/delphi/groupproj.rb', line 73

def targets
  @p.targets
end