Class: Unifmt
- Inherits:
-
UfBaseClass
- Object
- UfBaseClass
- Unifmt
- Extended by:
- Validate
- Defined in:
- lib/ebngen/unifmt.rb
Constant Summary collapse
- @@UNIFY_KEYS =
the keys that used in the uniformat
["meta_components", "targets", "path", "rootdir", "type", "templates", "outdir", "source", "virtual_dir", "document", "board", "identifier", "linker_file", "sectiontype", "binaryfile", "release_dir"]
- @@CONFIG_SETTINGS =
[ :cp_defines , :as_predefines, :as_defines, :as_flags, :as_preincludes , :as_include, :cc_predefines, :cc_defines, :cc_flags, :cc_preincludes, :cc_include, :cxx_predefines, :cxx_defines, :cxx_flags, :cxx_preincludes, :cxx_include, :ld_flags, :linker_file, :outdir, :binary_file, :tool_chain_set_spec, :tool_chain_add_spec ]
Instance Attribute Summary collapse
-
#as_defines ⇒ Object
the asm defintions.
-
#as_flags ⇒ Object
the asm defintions.
-
#as_include ⇒ Object
the asm defintions.
-
#as_predefines ⇒ Object
the asm defintions.
-
#as_preincludes ⇒ Object
the asm defintions.
-
#binary_file ⇒ Object
binary_file.
-
#cc_defines ⇒ Object
the c code definitons.
-
#cc_flags ⇒ Object
the c code definitons.
-
#cc_include ⇒ Object
the c code definitons.
-
#cc_predefines ⇒ Object
the c code definitons.
-
#cc_preincludes ⇒ Object
the c code definitons.
-
#cp_defines ⇒ Object
the soc definitons.
-
#cxx_defines ⇒ Object
the Cxx code difintios.
-
#cxx_flags ⇒ Object
the Cxx code difintios.
-
#cxx_include ⇒ Object
the Cxx code difintios.
-
#cxx_predefines ⇒ Object
the Cxx code difintios.
-
#cxx_preincludes ⇒ Object
the Cxx code difintios.
-
#ld_flags ⇒ Object
link flags.
-
#libraries ⇒ Object
dependant libraries information.
-
#linker_file ⇒ Object
link files.
-
#meta_components ⇒ Object
meta_components dependency.
-
#outdir ⇒ Object
project_name.
-
#project_name ⇒ Object
project_name.
-
#sources ⇒ Object
source.
-
#templates ⇒ Object
template.
-
#tool_chain_add_spec ⇒ Object
tool_chain_add_apec.
-
#tool_chain_set_spec ⇒ Object
tool_chain_set_spec.
Instance Method Summary collapse
- #<<(other) ⇒ Object
- #as_include_unit ⇒ Object
- #as_preincludes_unit ⇒ Object
- #cc_include_unit ⇒ Object
- #cc_preincludes_unit ⇒ Object
- #cxx_include_unit ⇒ Object
- #cxx_preincludes_unit ⇒ Object
- #help ⇒ Object
-
#initialize(options) ⇒ Unifmt
constructor
A new instance of Unifmt.
- #linker_file_unit ⇒ Object
- #load(project_data) ⇒ Object
- #merge_target(project_data) ⇒ Object
- #output_info ⇒ Object
- #sources_unit ⇒ Object
- #update ⇒ Object
Methods included from Validate
get_validate, validate, validate_array, validate_hash, validate_string
Methods inherited from UfBaseClass
attr_accessor, attributes, #attributes
Constructor Details
#initialize(options) ⇒ Unifmt
Returns a new instance of Unifmt.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/ebngen/unifmt.rb', line 169 def initialize() @options_default = { :config => "debug", :tool_chain => "iar", :type => "application", :board => "dummy_board", :project_name => "dummy_project", :project_root_dir => nil, } if .class.to_s != "Hash" and not .nil? puts "#{} shall be in hash format like { :targets => [\"release\", \"debug\"]}" return end .each do |key, value| @options_default[key] = value end @projects_hash = Hash.new @projects_hash[@options_default[:project_name]] = Hash.new if not $TARGET_TYPES.include?(@options_default[:type]) puts "Error type #{@options_default[:type]} is not in allowable list, should be #{$TARGET_TYPES}" return end if not $TOOL_CHAINS.include?(@options_default[:tool_chain]) puts "Error tool_chain #{@options_default[:tool_chain]} is not supported" return end self.attributes.each do |item| if @@CONFIG_SETTINGS.include?(item) instance_variable_set("@#{item}",Unifmt.get_validate(item).new) #@projects_hash[tc]["targets"][config][item.to_s] = instance_variable_get("@#{item}") end end end |
Instance Attribute Details
#as_defines ⇒ Object
the asm defintions
58 59 60 |
# File 'lib/ebngen/unifmt.rb', line 58 def as_defines @as_defines end |
#as_flags ⇒ Object
the asm defintions
58 59 60 |
# File 'lib/ebngen/unifmt.rb', line 58 def as_flags @as_flags end |
#as_include ⇒ Object
the asm defintions
58 59 60 |
# File 'lib/ebngen/unifmt.rb', line 58 def as_include @as_include end |
#as_predefines ⇒ Object
the asm defintions
58 59 60 |
# File 'lib/ebngen/unifmt.rb', line 58 def as_predefines @as_predefines end |
#as_preincludes ⇒ Object
the asm defintions
58 59 60 |
# File 'lib/ebngen/unifmt.rb', line 58 def as_preincludes @as_preincludes end |
#binary_file ⇒ Object
binary_file
84 85 86 |
# File 'lib/ebngen/unifmt.rb', line 84 def binary_file @binary_file end |
#cc_defines ⇒ Object
the c code definitons
60 61 62 |
# File 'lib/ebngen/unifmt.rb', line 60 def cc_defines @cc_defines end |
#cc_flags ⇒ Object
the c code definitons
60 61 62 |
# File 'lib/ebngen/unifmt.rb', line 60 def cc_flags @cc_flags end |
#cc_include ⇒ Object
the c code definitons
60 61 62 |
# File 'lib/ebngen/unifmt.rb', line 60 def cc_include @cc_include end |
#cc_predefines ⇒ Object
the c code definitons
60 61 62 |
# File 'lib/ebngen/unifmt.rb', line 60 def cc_predefines @cc_predefines end |
#cc_preincludes ⇒ Object
the c code definitons
60 61 62 |
# File 'lib/ebngen/unifmt.rb', line 60 def cc_preincludes @cc_preincludes end |
#cp_defines ⇒ Object
the soc definitons
56 57 58 |
# File 'lib/ebngen/unifmt.rb', line 56 def cp_defines @cp_defines end |
#cxx_defines ⇒ Object
the Cxx code difintios
62 63 64 |
# File 'lib/ebngen/unifmt.rb', line 62 def cxx_defines @cxx_defines end |
#cxx_flags ⇒ Object
the Cxx code difintios
62 63 64 |
# File 'lib/ebngen/unifmt.rb', line 62 def cxx_flags @cxx_flags end |
#cxx_include ⇒ Object
the Cxx code difintios
62 63 64 |
# File 'lib/ebngen/unifmt.rb', line 62 def cxx_include @cxx_include end |
#cxx_predefines ⇒ Object
the Cxx code difintios
62 63 64 |
# File 'lib/ebngen/unifmt.rb', line 62 def cxx_predefines @cxx_predefines end |
#cxx_preincludes ⇒ Object
the Cxx code difintios
62 63 64 |
# File 'lib/ebngen/unifmt.rb', line 62 def cxx_preincludes @cxx_preincludes end |
#ld_flags ⇒ Object
link flags
64 65 66 |
# File 'lib/ebngen/unifmt.rb', line 64 def ld_flags @ld_flags end |
#libraries ⇒ Object
dependant libraries information
66 67 68 |
# File 'lib/ebngen/unifmt.rb', line 66 def libraries @libraries end |
#linker_file ⇒ Object
link files
68 69 70 |
# File 'lib/ebngen/unifmt.rb', line 68 def linker_file @linker_file end |
#meta_components ⇒ Object
meta_components dependency
70 71 72 |
# File 'lib/ebngen/unifmt.rb', line 70 def @meta_components end |
#outdir ⇒ Object
project_name
78 79 80 |
# File 'lib/ebngen/unifmt.rb', line 78 def outdir @outdir end |
#project_name ⇒ Object
project_name
76 77 78 |
# File 'lib/ebngen/unifmt.rb', line 76 def project_name @project_name end |
#sources ⇒ Object
source
72 73 74 |
# File 'lib/ebngen/unifmt.rb', line 72 def sources @sources end |
#templates ⇒ Object
template
74 75 76 |
# File 'lib/ebngen/unifmt.rb', line 74 def templates @templates end |
#tool_chain_add_spec ⇒ Object
tool_chain_add_apec
82 83 84 |
# File 'lib/ebngen/unifmt.rb', line 82 def tool_chain_add_spec @tool_chain_add_spec end |
#tool_chain_set_spec ⇒ Object
tool_chain_set_spec
80 81 82 |
# File 'lib/ebngen/unifmt.rb', line 80 def tool_chain_set_spec @tool_chain_set_spec end |
Instance Method Details
#<<(other) ⇒ Object
246 247 248 |
# File 'lib/ebngen/unifmt.rb', line 246 def <<(other) @projects_hash.deep_merge(other.output_info) end |
#as_include_unit ⇒ Object
263 264 265 |
# File 'lib/ebngen/unifmt.rb', line 263 def as_include_unit return {"path" => "", "rootdir" => ""} end |
#as_preincludes_unit ⇒ Object
259 260 261 |
# File 'lib/ebngen/unifmt.rb', line 259 def as_preincludes_unit return {"path" => "", "rootdir" => ""} end |
#cc_include_unit ⇒ Object
271 272 273 |
# File 'lib/ebngen/unifmt.rb', line 271 def cc_include_unit return {"path" => "", "rootdir" => ""} end |
#cc_preincludes_unit ⇒ Object
267 268 269 |
# File 'lib/ebngen/unifmt.rb', line 267 def cc_preincludes_unit return {"path" => "", "rootdir" => ""} end |
#cxx_include_unit ⇒ Object
279 280 281 |
# File 'lib/ebngen/unifmt.rb', line 279 def cxx_include_unit return {"path" => "", "rootdir" => ""} end |
#cxx_preincludes_unit ⇒ Object
275 276 277 |
# File 'lib/ebngen/unifmt.rb', line 275 def cxx_preincludes_unit return {"path" => "", "rootdir" => ""} end |
#help ⇒ Object
254 255 256 |
# File 'lib/ebngen/unifmt.rb', line 254 def help puts @@UNIFY_KEYS end |
#linker_file_unit ⇒ Object
283 284 285 |
# File 'lib/ebngen/unifmt.rb', line 283 def linker_file_unit return {"path" => "", "rootdir" => ""} end |
#load(project_data) ⇒ Object
250 251 252 |
# File 'lib/ebngen/unifmt.rb', line 250 def load(project_data) @projects_hash = project_data end |
#merge_target(project_data) ⇒ Object
242 243 244 |
# File 'lib/ebngen/unifmt.rb', line 242 def merge_target(project_data) @projects_hash.deep_merge(project_data) end |
#output_info ⇒ Object
238 239 240 |
# File 'lib/ebngen/unifmt.rb', line 238 def output_info @projects_hash end |
#sources_unit ⇒ Object
287 288 289 |
# File 'lib/ebngen/unifmt.rb', line 287 def sources_unit return {"source" => "", "virtual_dir" => "" ,"rootdir" => "", "release_dir" => ""} end |
#update ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/ebngen/unifmt.rb', line 209 def update #some mandatory sections @subhash = @projects_hash[@options_default[:project_name]] @subhash["document"] = Hash.new @subhash["document"]["board"] = @options_default[:board] @subhash["document"]["project_name"] = @options_default[:project_name] @subhash["document"]["project_root_dir"] = @options_default[:project_root_dir] tc = @options_default[:tool_chain] @subhash[tc] = Hash.new @subhash[tc]["targets"] = Hash.new @subhash[tc]["templates"] = instance_variable_get("@templates") @subhash[tc]["type"] = @options_default[:type] config = @options_default[:config] if not $CONFIG_TYPES.include?(config) puts "the config type #{config} is not supported" return end @subhash[tc]["targets"][config] = Hash.new self.attributes.each do |item| if @@CONFIG_SETTINGS.include?(item) @subhash[tc]["targets"][config][item.to_s] = instance_variable_get("@#{item}") end end #other need special process features @subhash[tc]["source"] = instance_variable_get("@sources") @subhash[tc]["outdir"] = instance_variable_get("@outdir") @subhash[tc]["libraries"] = instance_variable_get("@libraries") end |