Class: RakeOE::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/rakeoe/config.rb

Overview

Project wide configurations RakeOE::init() takes a RakeOE::Config object. Therefore this class should be used from inside the project Rakefile to change project wide settings before calling RakeOE::init().

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/rakeoe/config.rb', line 14

def initialize

  # Common file suffixes used for C/C++/Assembler files inside the project.
  # This is a hash object with the following key => value mappings (examples):
  # {
  #     :as_sources => %w[.s],                      Assembler source
  #     :c_sources => %w[.c],                       C source
  #     :c_headers => %w[.h],                       C headers
  #     :cplus_sources => %w[.cpp .cc],             C++ sources
  #     :cplus_headers => %w[.h .hpp],              C++ headers
  #     :moc_header => '.h',                        Qt MOC file header
  #     :moc_source => '.cpp'                       Qt MOC file source
  # }
  @suffixes=RakeOE::Default.suffixes
  
  # Directories used for the project
  # This is a hash object with the following key => value mappings (examples):
  # {
  #     :apps => %w[src/app],                       Application top level directories
  #     :libs => %w[src/lib1 src/lib2],             Library top level directories
  #     :build => 'build'                           Build top level directory
  # }
  @directories=RakeOE::Default.dirs

  # Platform configuration used for the project
  # This is the absolute path to the platform definition file
  #
  # This parameter can be overridden via environment variable TOOLCHAIN_ENV
  @platform = ENV['TOOLCHAIN_ENV'].nil? ? '' : ENV['TOOLCHAIN_ENV']

  # Release mode used for the project
  # It can take the values "dbg" or "release" and influences the build behaviour.
  # When "dbg", optimization definitions set via @optimization_dbg are used.
  # When "release", optimization definitions set via @optimization_release are used.
  # CFLAGS/CXXFLAGS will contain the symbol -DRELEASE
  #
  # This parameter can be overridden via environment variable RELEASE. If the latter
  # is defined, this configuration variable has the value "release"
  @release = ENV['RELEASE'].nil? ? RakeOE::Default.release : 'release'

  # Test framework used for linking test case binaries
  # This takes the name of the test framework that has to be integrated into the project
  # library path.
  # RakeOE does not require a specific test framework, but CppUTest and CUnit are proposals
  # that have been tested to work fine.
  @test_fw=RakeOE::Default.test_fw

  # Optimization levels used for compiling binaries (e.g. -O0, -O1, -O2, -O3, -Og).
  # Depending on the release mode, either @optimization_dbg or @optimization_release
  # is used
  @optimization_dbg=RakeOE::Default.optimization_dbg
  @optimization_release=RakeOE::Default.optimization_release

  # Language standard (e.g. -std=gnu99, -std=c++03, -std=c99, etc. )
  @language_std_c=RakeOE::Default.lang_std_c
  @language_std_cpp=RakeOE::Default.lang_std_cpp

  # Software version string
  #
  # This parameter can be overridden via environment variable SW_VERSION_ENV.
  @sw_version = ENV['SW_VERSION_ENV'].nil? ? "#{RakeOE::Default.sw_version}-#{@release}" : ENV['SW_VERSION_ENV']

  # Project settings as specified in prj.rake file
  @prj_settings = RakeOE::Default.prj_settings
end

Instance Attribute Details

#directoriesObject

Returns the value of attribute directories.



11
12
13
# File 'lib/rakeoe/config.rb', line 11

def directories
  @directories
end

#language_std_cObject

Returns the value of attribute language_std_c.



11
12
13
# File 'lib/rakeoe/config.rb', line 11

def language_std_c
  @language_std_c
end

#language_std_cppObject

Returns the value of attribute language_std_cpp.



11
12
13
# File 'lib/rakeoe/config.rb', line 11

def language_std_cpp
  @language_std_cpp
end

#optimization_dbgObject

Returns the value of attribute optimization_dbg.



11
12
13
# File 'lib/rakeoe/config.rb', line 11

def optimization_dbg
  @optimization_dbg
end

#optimization_releaseObject

Returns the value of attribute optimization_release.



11
12
13
# File 'lib/rakeoe/config.rb', line 11

def optimization_release
  @optimization_release
end

#platformObject

Returns the value of attribute platform.



11
12
13
# File 'lib/rakeoe/config.rb', line 11

def platform
  @platform
end

#releaseObject

Returns the value of attribute release.



11
12
13
# File 'lib/rakeoe/config.rb', line 11

def release
  @release
end

#suffixesObject

Returns the value of attribute suffixes.



11
12
13
# File 'lib/rakeoe/config.rb', line 11

def suffixes
  @suffixes
end

#sw_versionObject

Returns the value of attribute sw_version.



11
12
13
# File 'lib/rakeoe/config.rb', line 11

def sw_version
  @sw_version
end

#test_fwObject

Returns the value of attribute test_fw.



11
12
13
# File 'lib/rakeoe/config.rb', line 11

def test_fw
  @test_fw
end

Instance Method Details

#checks_pass?bool

Checks configuration, e.g. if given files do exist or if vital configuration settings are missing

Returns:

  • (bool)

    true if checks pass, false otherwise



85
86
87
88
89
90
91
92
93
# File 'lib/rakeoe/config.rb', line 85

def checks_pass?
  rv = true
  unless File.exist?(@platform)
    puts "No platform or invalid platform configuration given: (#{@platform}) !"
    puts "Use either property 'platform' via RakeOE::Config object in the Rakefile or environment variable TOOLCHAIN_ENV"
    rv = false
  end
  rv
end

#dumpObject

Dumps configuration to stdout



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/rakeoe/config.rb', line 97

def dump
  puts '******************'
  puts '* RakeOE::Config *'
  puts '******************'
  puts "Directories                 : #{@directories}"
  puts "Suffixes                    : #{@suffixes}"
  puts "Platform                    : #{@platform}"
  puts "Release mode                : #{@release}"
  puts "Test framework              : #{@test_fw}"
  puts "Optimization dbg            : #{@optimization_dbg}"
  puts "Optimization release        : #{@optimization_release}"
  puts "Language Standard for C     : #{@language_std_c}"
  puts "Language Standard for C++   : #{@language_std_cpp}"
  puts "Software version string     : #{@sw_version}"
end