Class: Delphi::Compiler

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

Overview

Class to execute Delphi compiler

You should not need to directly interact with this class. It is accessed via the compile methods of the Project, GroupProj and Resource classes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_version, fail_on_hints_and_warnings = true) ⇒ Compiler

You need to pass the Delphi target version to this class. If you use the Project or GroupProj classes, they will figure this out for you from the information in the dproj file.



17
18
19
20
21
# File 'lib/delphi/compiler.rb', line 17

def initialize(project_version, fail_on_hints_and_warnings = true)
  Delphi::Environment.instance.configure(project_version)
  @fail_on_hints_and_warnings = fail_on_hints_and_warnings
  @fail_on_errors = true
end

Instance Attribute Details

#fail_on_errorsObject

Returns the value of attribute fail_on_errors.



12
13
14
# File 'lib/delphi/compiler.rb', line 12

def fail_on_errors
  @fail_on_errors
end

#fail_on_hints_and_warningsObject

Returns the value of attribute fail_on_hints_and_warnings.



12
13
14
# File 'lib/delphi/compiler.rb', line 12

def fail_on_hints_and_warnings
  @fail_on_hints_and_warnings
end

Instance Method Details

#bdsObject



50
51
52
# File 'lib/delphi/compiler.rb', line 50

def bds
  File.join(Delphi::Environment.instance.bin_dir, 'bds.exe')
end

#compile(dproj, target, config, platform) ⇒ Object

Compile a Project (dproj file)



24
25
26
27
28
29
# File 'lib/delphi/compiler.rb', line 24

def compile(dproj, target, config, platform)
  puts "Compiling #{dproj}"
  cmd = format(FMT_COMPILE, target, config, platform, dproj)
  compile_output = `#{cmd}`
  check_for_failure(compile_output)
end

#compile_group(groupproj, target) ⇒ Object

Compile a Project Group (groupproj file)



32
33
34
35
36
37
38
39
# File 'lib/delphi/compiler.rb', line 32

def compile_group(groupproj, target)
  puts "Compiling #{groupproj}"
  Dir.chdir(File.dirname(groupproj)) do
    cmd = format(FMT_COMPILE_GROUP, target, File.basename(groupproj))
    compile_output = `#{cmd}`
    check_for_failure(compile_output)
  end
end

#compile_rc(rcfile) ⇒ Object

Compile a Resource (rc file)



42
43
44
45
46
47
48
# File 'lib/delphi/compiler.rb', line 42

def compile_rc(rcfile)
  puts "Compiling #{rcfile}"
  Dir.chdir(File.dirname(rcfile)) do
    cmd = format(FMT_COMPILE_RC, File.basename(rcfile))
    `#{cmd}`
  end
end