Class: Delphi::Project
- Inherits:
-
Object
- Object
- Delphi::Project
- Defined in:
- lib/delphi/project.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
-
#config ⇒ Object
The configuration to build - e.g.
-
#dproj ⇒ Object
readonly
Returns the value of attribute dproj.
-
#platform ⇒ Object
The platform to build for - e.g.
-
#target ⇒ Object
The msbuild target - e.g.
Instance Method Summary collapse
- #compile ⇒ Object
-
#configs ⇒ Object
Returns the set of valid configurations as read from the dproj file.
- #fail_on_hints_and_warnings ⇒ Object
- #fail_on_hints_and_warnings=(value) ⇒ Object
-
#initialize(dproj) ⇒ Project
constructor
A new instance of Project.
-
#out_file ⇒ Object
The output file without the path.
- #output ⇒ Object
-
#platforms ⇒ Object
Returns the set of valid platforms as read from the dproj file.
- #project_version ⇒ Object
-
#targets ⇒ Object
Returns the set of valid targets.
Constructor Details
#initialize(dproj) ⇒ Project
Returns a new instance of Project.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/delphi/project.rb', line 22 def initialize(dproj) @dproj = dproj fail "#{dproj} not found" unless File.exist?(dproj) load @compiler = Delphi::Compiler.new(project_version) @config = default_config @target = targets[0] @platform = platforms[0] @outputpath = get('//DCC_ExeOutput').text end |
Instance Attribute Details
#config ⇒ Object
The configuration to build - e.g. Debug, Release.
14 15 16 |
# File 'lib/delphi/project.rb', line 14 def config @config end |
#dproj ⇒ Object (readonly)
Returns the value of attribute dproj.
20 21 22 |
# File 'lib/delphi/project.rb', line 20 def dproj @dproj end |
#platform ⇒ Object
The platform to build for - e.g. Win32, Win64.
16 17 18 |
# File 'lib/delphi/project.rb', line 16 def platform @platform end |
#target ⇒ Object
The msbuild target - e.g. Build, Compile, Clean.
18 19 20 |
# File 'lib/delphi/project.rb', line 18 def target @target end |
Instance Method Details
#compile ⇒ Object
34 35 36 |
# File 'lib/delphi/project.rb', line 34 def compile @compiler.compile(@dproj, @target, @config, @platform) end |
#configs ⇒ Object
Returns the set of valid configurations as read from the dproj file
53 54 55 56 57 58 59 60 |
# File 'lib/delphi/project.rb', line 53 def configs result = [] @doc.elements.each('/Project/ItemGroup/BuildConfiguration') do |element| config = element.attributes['Include'] result << config unless config == 'Base' end result end |
#fail_on_hints_and_warnings ⇒ Object
44 45 46 |
# File 'lib/delphi/project.rb', line 44 def fail_on_hints_and_warnings @compiler.fail_on_hints_and_warnings end |
#fail_on_hints_and_warnings=(value) ⇒ Object
48 49 50 |
# File 'lib/delphi/project.rb', line 48 def fail_on_hints_and_warnings=(value) @compiler.fail_on_hints_and_warnings = value end |
#out_file ⇒ Object
The output file without the path.
63 64 65 |
# File 'lib/delphi/project.rb', line 63 def out_file File.basename(@output) end |
#output ⇒ Object
67 68 69 |
# File 'lib/delphi/project.rb', line 67 def output File.(File.join(subst_path(@outputpath), File.basename(@dproj, '.dproj') + '.exe')) end |
#platforms ⇒ Object
Returns the set of valid platforms as read from the dproj file
78 79 80 81 82 83 |
# File 'lib/delphi/project.rb', line 78 def platforms path = '/Project/PropertyGroup/Platform' result = [] @doc.elements.each(path) { |element| result << element.text } result end |
#project_version ⇒ Object
85 86 87 88 89 |
# File 'lib/delphi/project.rb', line 85 def project_version path = 'Project/PropertyGroup/ProjectVersion' @project_version = get(path).text.to_f unless @project_version @project_version end |
#targets ⇒ Object
Returns the set of valid targets
98 99 100 |
# File 'lib/delphi/project.rb', line 98 def targets %w(Build Compile Clean) end |