ebngen 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/ebngen/adapter/_assert.rb +25 -0
 - data/lib/ebngen/adapter/_base.rb +25 -0
 - data/lib/ebngen/adapter/_path_modifier.rb +29 -0
 - data/lib/ebngen/adapter/_yml_helper.rb +51 -0
 - data/lib/ebngen/adapter/cmake/CMakeList.txt +570 -0
 - data/lib/ebngen/adapter/cmake/txt.rb +75 -0
 - data/lib/ebngen/adapter/cmake.rb +291 -0
 - data/lib/ebngen/adapter/iar/ewd.rb +6 -0
 - data/lib/ebngen/adapter/iar/ewp.rb +250 -0
 - data/lib/ebngen/adapter/iar/eww.rb +62 -0
 - data/lib/ebngen/adapter/iar.rb +390 -0
 - data/lib/ebngen/assembly.rb +22 -0
 - data/lib/ebngen/ebngen.rb +4 -0
 - data/lib/ebngen/generate.rb +42 -0
 - data/lib/ebngen/settings/target_types.rb +2 -0
 - data/lib/ebngen/settings/tool_chains.rb +5 -0
 - data/lib/ebngen/translate.rb +238 -0
 - data/lib/ebngen/unifmt.rb +290 -0
 - metadata +19 -1
 
| 
         @@ -0,0 +1,390 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            require_relative '_base'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require_relative '_yml_helper'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require_relative '_path_modifier'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require_relative 'iar/eww'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require_relative 'iar/ewp'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require_relative 'iar/ewd'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            #replace me when yml_merger becomes gem
         
     | 
| 
      
 10 
     | 
    
         
            +
            require 'yml_merger'
         
     | 
| 
      
 11 
     | 
    
         
            +
            require 'nokogiri'
         
     | 
| 
      
 12 
     | 
    
         
            +
            require 'uri'
         
     | 
| 
      
 13 
     | 
    
         
            +
            require 'open-uri'
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            module IAR
         
     | 
| 
      
 16 
     | 
    
         
            +
            class Project
         
     | 
| 
      
 17 
     | 
    
         
            +
            	TOOLCHAIN='iar'
         
     | 
| 
      
 18 
     | 
    
         
            +
            	include Base
         
     | 
| 
      
 19 
     | 
    
         
            +
            	include EWP
         
     | 
| 
      
 20 
     | 
    
         
            +
            	include EWD
         
     | 
| 
      
 21 
     | 
    
         
            +
            	include UNI_Project
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            	def initialize(project_data, generator_variable)
         
     | 
| 
      
 24 
     | 
    
         
            +
            		set_hash(project_data)
         
     | 
| 
      
 25 
     | 
    
         
            +
            		@project_name = get_project_name()
         
     | 
| 
      
 26 
     | 
    
         
            +
            		@board = get_board()
         
     | 
| 
      
 27 
     | 
    
         
            +
            		@paths = PathModifier.new(generator_variable["paths"])
         
     | 
| 
      
 28 
     | 
    
         
            +
            		@iar_project_files = {".ewp" => nil, ".dni" => nil, ".ewd" => nil, ".yml" => nil}
         
     | 
| 
      
 29 
     | 
    
         
            +
            		return nil if get_template(Project::TOOLCHAIN).nil?
         
     | 
| 
      
 30 
     | 
    
         
            +
            		get_template(Project::TOOLCHAIN).each do |template|
         
     | 
| 
      
 31 
     | 
    
         
            +
            			puts template
         
     | 
| 
      
 32 
     | 
    
         
            +
            			ext = File.extname(template)
         
     | 
| 
      
 33 
     | 
    
         
            +
            			if @iar_project_files.keys.include?(ext)
         
     | 
| 
      
 34 
     | 
    
         
            +
            				path = @paths.fullpath("default_path",template)
         
     | 
| 
      
 35 
     | 
    
         
            +
            			  #begin
         
     | 
| 
      
 36 
     | 
    
         
            +
            				case ext
         
     | 
| 
      
 37 
     | 
    
         
            +
            					when ".ewp"
         
     | 
| 
      
 38 
     | 
    
         
            +
            						doc = Nokogiri::XML(open(path))
         
     | 
| 
      
 39 
     | 
    
         
            +
            						@iar_project_files[ext] = doc
         
     | 
| 
      
 40 
     | 
    
         
            +
            					when ".ewd"
         
     | 
| 
      
 41 
     | 
    
         
            +
            						doc = Nokogiri::XML(open(path))
         
     | 
| 
      
 42 
     | 
    
         
            +
            						@iar_project_files[ext] = doc
         
     | 
| 
      
 43 
     | 
    
         
            +
            					when ".dni"
         
     | 
| 
      
 44 
     | 
    
         
            +
            						doc = Nokogiri::XML(open(path))
         
     | 
| 
      
 45 
     | 
    
         
            +
            						@iar_project_files[ext] = doc
         
     | 
| 
      
 46 
     | 
    
         
            +
            				end
         
     | 
| 
      
 47 
     | 
    
         
            +
            			  #rescue
         
     | 
| 
      
 48 
     | 
    
         
            +
            			  #	puts "failed to open #{template}"
         
     | 
| 
      
 49 
     | 
    
         
            +
            			  #end
         
     | 
| 
      
 50 
     | 
    
         
            +
            			end
         
     | 
| 
      
 51 
     | 
    
         
            +
            		end
         
     | 
| 
      
 52 
     | 
    
         
            +
            	end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              	def generator(filter, project_data)
         
     | 
| 
      
 55 
     | 
    
         
            +
                	create_method( Project::TOOLCHAIN)
         
     | 
| 
      
 56 
     | 
    
         
            +
                	send(Project::TOOLCHAIN.to_sym, project_data)
         
     | 
| 
      
 57 
     | 
    
         
            +
                	save_project()
         
     | 
| 
      
 58 
     | 
    
         
            +
              	end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
              	def source()
         
     | 
| 
      
 61 
     | 
    
         
            +
              		#add sources to target
         
     | 
| 
      
 62 
     | 
    
         
            +
              		return if @iar_project_files['.ewp'].nil?
         
     | 
| 
      
 63 
     | 
    
         
            +
              		remove_sources(@iar_project_files['.ewp'])
         
     | 
| 
      
 64 
     | 
    
         
            +
              		sources = get_src_list(Project::TOOLCHAIN)
         
     | 
| 
      
 65 
     | 
    
         
            +
              		o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
         
     | 
| 
      
 66 
     | 
    
         
            +
              		proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
         
     | 
| 
      
 67 
     | 
    
         
            +
              		add_sources(@iar_project_files['.ewp'], sources, @paths, proj_path)
         
     | 
| 
      
 68 
     | 
    
         
            +
              	end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
              	def templates()
         
     | 
| 
      
 71 
     | 
    
         
            +
              		#load tempaltes
         
     | 
| 
      
 72 
     | 
    
         
            +
              	end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
              	def type()
         
     | 
| 
      
 75 
     | 
    
         
            +
              		#set project type
         
     | 
| 
      
 76 
     | 
    
         
            +
              	end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
              	def outdir()
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
              	end
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
            	def targets()
         
     | 
| 
      
 83 
     | 
    
         
            +
            		get_targets(Project::TOOLCHAIN).each do |key, value|
         
     | 
| 
      
 84 
     | 
    
         
            +
            			next if value.nil?
         
     | 
| 
      
 85 
     | 
    
         
            +
            			#add target for ewp
         
     | 
| 
      
 86 
     | 
    
         
            +
            			t = new_target(key, @iar_project_files['.ewp'])
         
     | 
| 
      
 87 
     | 
    
         
            +
            			if t.nil?
         
     | 
| 
      
 88 
     | 
    
         
            +
            			  puts "missing default debug configuration in template"
         
     | 
| 
      
 89 
     | 
    
         
            +
             			  return
         
     | 
| 
      
 90 
     | 
    
         
            +
            			end
         
     | 
| 
      
 91 
     | 
    
         
            +
            			#do the target settings
         
     | 
| 
      
 92 
     | 
    
         
            +
            			value.each_key do |subkey|
         
     | 
| 
      
 93 
     | 
    
         
            +
            				methods = self.class.instance_methods(false)
         
     | 
| 
      
 94 
     | 
    
         
            +
                      		if methods.include?("target_#{subkey}".to_sym)
         
     | 
| 
      
 95 
     | 
    
         
            +
                        		send("target_#{subkey}".to_sym, t, value[subkey])
         
     | 
| 
      
 96 
     | 
    
         
            +
                      		else
         
     | 
| 
      
 97 
     | 
    
         
            +
                        		puts "#{subkey} is not processed"
         
     | 
| 
      
 98 
     | 
    
         
            +
                      		end
         
     | 
| 
      
 99 
     | 
    
         
            +
            			end
         
     | 
| 
      
 100 
     | 
    
         
            +
            		end
         
     | 
| 
      
 101 
     | 
    
         
            +
            		remove_targets(@iar_project_files['.ewp'], get_target_list(Project::TOOLCHAIN))
         
     | 
| 
      
 102 
     | 
    
         
            +
            	end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                # tool_chain_specific attribute for each target
         
     | 
| 
      
 105 
     | 
    
         
            +
                # Params:
         
     | 
| 
      
 106 
     | 
    
         
            +
                # - target_node: the xml node of given target
         
     | 
| 
      
 107 
     | 
    
         
            +
                # - doc: the hash that holds the data
         
     | 
| 
      
 108 
     | 
    
         
            +
            	def target_tool_chain_set_spec(target_node, doc)
         
     | 
| 
      
 109 
     | 
    
         
            +
            		set_specific(target_node, doc)
         
     | 
| 
      
 110 
     | 
    
         
            +
            	end
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
            	def target_tool_chain_add_spec(target_node, doc)
         
     | 
| 
      
 113 
     | 
    
         
            +
            		add_specific(target_node, doc)
         
     | 
| 
      
 114 
     | 
    
         
            +
            	end
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
            	def save_project()
         
     | 
| 
      
 117 
     | 
    
         
            +
            		path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
         
     | 
| 
      
 118 
     | 
    
         
            +
            		save(@iar_project_files['.ewp'], File.join(@paths.rootdir_table['output_root'], path, "#{@project_name}_#{@board}.ewp"))
         
     | 
| 
      
 119 
     | 
    
         
            +
            	end
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
            	def target_cp_defines(target_node, doc)
         
     | 
| 
      
 122 
     | 
    
         
            +
            		value = doc.values.join(" ")
         
     | 
| 
      
 123 
     | 
    
         
            +
            		settings = {'OGChipSelectEditMenu' => {
         
     | 
| 
      
 124 
     | 
    
         
            +
                				'state' => doc.keys.join("") + "\t" + value
         
     | 
| 
      
 125 
     | 
    
         
            +
              					}
         
     | 
| 
      
 126 
     | 
    
         
            +
              				}
         
     | 
| 
      
 127 
     | 
    
         
            +
            		set_specific(target_node, settings)
         
     | 
| 
      
 128 
     | 
    
         
            +
            		settings = {'GEndianModeBE' => {
         
     | 
| 
      
 129 
     | 
    
         
            +
            					'state' => 1
         
     | 
| 
      
 130 
     | 
    
         
            +
            					}
         
     | 
| 
      
 131 
     | 
    
         
            +
            		}
         
     | 
| 
      
 132 
     | 
    
         
            +
            		set_specific(target_node, settings)
         
     | 
| 
      
 133 
     | 
    
         
            +
            	end
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
            	def target_as_predefines(target_node, doc)
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
            	end
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
            	def target_as_defines(target_node, doc)
         
     | 
| 
      
 140 
     | 
    
         
            +
            		settings = {'ADefines' => {
         
     | 
| 
      
 141 
     | 
    
         
            +
                				'state' => doc
         
     | 
| 
      
 142 
     | 
    
         
            +
              					}
         
     | 
| 
      
 143 
     | 
    
         
            +
              				}
         
     | 
| 
      
 144 
     | 
    
         
            +
              		add_specific(target_node, settings)
         
     | 
| 
      
 145 
     | 
    
         
            +
            	end
         
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
      
 147 
     | 
    
         
            +
            	def target_as_include(target_node, doc)
         
     | 
| 
      
 148 
     | 
    
         
            +
            		o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
         
     | 
| 
      
 149 
     | 
    
         
            +
              		proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
         
     | 
| 
      
 150 
     | 
    
         
            +
              		settings = {'AUserIncludes' => {} }
         
     | 
| 
      
 151 
     | 
    
         
            +
              		inc_array = Array.new
         
     | 
| 
      
 152 
     | 
    
         
            +
              		doc.each do |item|
         
     | 
| 
      
 153 
     | 
    
         
            +
            	      if item['rootdir']
         
     | 
| 
      
 154 
     | 
    
         
            +
            	        full_path = @paths.fullpath(item['rootdir'],item['path'])
         
     | 
| 
      
 155 
     | 
    
         
            +
            	      else
         
     | 
| 
      
 156 
     | 
    
         
            +
            	        full_path = @paths.fullpath('default_path',item['path'])
         
     | 
| 
      
 157 
     | 
    
         
            +
            	      end
         
     | 
| 
      
 158 
     | 
    
         
            +
            	      inc_array.insert(-1, File.join("$PROJ_DIR$", @paths.relpath(proj_path, full_path)))
         
     | 
| 
      
 159 
     | 
    
         
            +
              		end
         
     | 
| 
      
 160 
     | 
    
         
            +
              		settings['AUserIncludes']['state'] = inc_array
         
     | 
| 
      
 161 
     | 
    
         
            +
              		add_specific(target_node, settings)
         
     | 
| 
      
 162 
     | 
    
         
            +
            	end
         
     | 
| 
      
 163 
     | 
    
         
            +
             
     | 
| 
      
 164 
     | 
    
         
            +
            	def target_as_flags(target_node, doc)
         
     | 
| 
      
 165 
     | 
    
         
            +
            		settings = {'AExtraOptionsV2' => {
         
     | 
| 
      
 166 
     | 
    
         
            +
                				'state' => doc
         
     | 
| 
      
 167 
     | 
    
         
            +
              					}
         
     | 
| 
      
 168 
     | 
    
         
            +
              				}
         
     | 
| 
      
 169 
     | 
    
         
            +
              		add_specific(target_node, settings)
         
     | 
| 
      
 170 
     | 
    
         
            +
            	end
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
            	def target_cc_predefines(target_node, doc)
         
     | 
| 
      
 173 
     | 
    
         
            +
             
     | 
| 
      
 174 
     | 
    
         
            +
            	end
         
     | 
| 
      
 175 
     | 
    
         
            +
             
     | 
| 
      
 176 
     | 
    
         
            +
            	def target_cc_preincludes(target_node, doc)
         
     | 
| 
      
 177 
     | 
    
         
            +
            		o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
         
     | 
| 
      
 178 
     | 
    
         
            +
              		proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
         
     | 
| 
      
 179 
     | 
    
         
            +
              		settings = {'PreInclude' => {} }
         
     | 
| 
      
 180 
     | 
    
         
            +
              		inc_array = Array.new
         
     | 
| 
      
 181 
     | 
    
         
            +
              		doc.each do |item|
         
     | 
| 
      
 182 
     | 
    
         
            +
            	      if item['rootdir']
         
     | 
| 
      
 183 
     | 
    
         
            +
            	        full_path = @paths.fullpath(item['rootdir'],item['path'])
         
     | 
| 
      
 184 
     | 
    
         
            +
            	      else
         
     | 
| 
      
 185 
     | 
    
         
            +
            	        full_path = @paths.fullpath('default_path',item['path'])
         
     | 
| 
      
 186 
     | 
    
         
            +
            	      end
         
     | 
| 
      
 187 
     | 
    
         
            +
            	      inc_array.insert(-1, File.join("$PROJ_DIR$", @paths.relpath(proj_path, full_path)))
         
     | 
| 
      
 188 
     | 
    
         
            +
              		end
         
     | 
| 
      
 189 
     | 
    
         
            +
              		settings['PreInclude']['state'] = inc_array
         
     | 
| 
      
 190 
     | 
    
         
            +
              		add_specific(target_node, settings)
         
     | 
| 
      
 191 
     | 
    
         
            +
            	end
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
            	def target_cc_defines(target_node, doc)
         
     | 
| 
      
 194 
     | 
    
         
            +
            		settings = {'CCDefines' => {
         
     | 
| 
      
 195 
     | 
    
         
            +
                				'state' => doc
         
     | 
| 
      
 196 
     | 
    
         
            +
              					}
         
     | 
| 
      
 197 
     | 
    
         
            +
              				   }
         
     | 
| 
      
 198 
     | 
    
         
            +
              		add_specific(target_node, settings)
         
     | 
| 
      
 199 
     | 
    
         
            +
            	end
         
     | 
| 
      
 200 
     | 
    
         
            +
             
     | 
| 
      
 201 
     | 
    
         
            +
            	def target_cc_include(target_node, doc)
         
     | 
| 
      
 202 
     | 
    
         
            +
            		o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
         
     | 
| 
      
 203 
     | 
    
         
            +
              		proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
         
     | 
| 
      
 204 
     | 
    
         
            +
              		settings = {'CCIncludePath2' => {} }
         
     | 
| 
      
 205 
     | 
    
         
            +
              		inc_array = Array.new
         
     | 
| 
      
 206 
     | 
    
         
            +
              		doc.each do |item|
         
     | 
| 
      
 207 
     | 
    
         
            +
            	      if item['rootdir']
         
     | 
| 
      
 208 
     | 
    
         
            +
            	        full_path = @paths.fullpath(item['rootdir'],item['path'])
         
     | 
| 
      
 209 
     | 
    
         
            +
            	      else
         
     | 
| 
      
 210 
     | 
    
         
            +
            	        full_path = @paths.fullpath('default_path',item['path'])
         
     | 
| 
      
 211 
     | 
    
         
            +
            	      end
         
     | 
| 
      
 212 
     | 
    
         
            +
            	      inc_array.insert(-1, File.join("$PROJ_DIR$", @paths.relpath(proj_path, full_path)))
         
     | 
| 
      
 213 
     | 
    
         
            +
              		end
         
     | 
| 
      
 214 
     | 
    
         
            +
              		settings['CCIncludePath2']['state'] = inc_array
         
     | 
| 
      
 215 
     | 
    
         
            +
              		add_specific(target_node, settings)
         
     | 
| 
      
 216 
     | 
    
         
            +
            	end
         
     | 
| 
      
 217 
     | 
    
         
            +
             
     | 
| 
      
 218 
     | 
    
         
            +
            	def target_cc_flags(target_node, doc)
         
     | 
| 
      
 219 
     | 
    
         
            +
            		settings_check = { 'IExtraOptionsCheck' => {
         
     | 
| 
      
 220 
     | 
    
         
            +
            				'state' => 1
         
     | 
| 
      
 221 
     | 
    
         
            +
            			}
         
     | 
| 
      
 222 
     | 
    
         
            +
            		}
         
     | 
| 
      
 223 
     | 
    
         
            +
            		add_specific(target_node, settings_check)
         
     | 
| 
      
 224 
     | 
    
         
            +
            		settings = {'IExtraOptions' => {
         
     | 
| 
      
 225 
     | 
    
         
            +
                				'state' => doc
         
     | 
| 
      
 226 
     | 
    
         
            +
              					}
         
     | 
| 
      
 227 
     | 
    
         
            +
              				   }
         
     | 
| 
      
 228 
     | 
    
         
            +
              		add_specific(target_node, settings)
         
     | 
| 
      
 229 
     | 
    
         
            +
            	end
         
     | 
| 
      
 230 
     | 
    
         
            +
             
     | 
| 
      
 231 
     | 
    
         
            +
            	def target_cxx_predefines(target_node, doc)
         
     | 
| 
      
 232 
     | 
    
         
            +
            		target_cc_predefines(target_node, doc)
         
     | 
| 
      
 233 
     | 
    
         
            +
            	end
         
     | 
| 
      
 234 
     | 
    
         
            +
             
     | 
| 
      
 235 
     | 
    
         
            +
            	def target_cxx_preincludes(target_node, doc)
         
     | 
| 
      
 236 
     | 
    
         
            +
            		target_cc_preincludes(target_node, doc)
         
     | 
| 
      
 237 
     | 
    
         
            +
            	end
         
     | 
| 
      
 238 
     | 
    
         
            +
             
     | 
| 
      
 239 
     | 
    
         
            +
            	def target_cxx_defines(target_node, doc)
         
     | 
| 
      
 240 
     | 
    
         
            +
            		target_cc_defines(target_node, doc)
         
     | 
| 
      
 241 
     | 
    
         
            +
            	end
         
     | 
| 
      
 242 
     | 
    
         
            +
             
     | 
| 
      
 243 
     | 
    
         
            +
            	def target_cxx_include(target_node, doc)
         
     | 
| 
      
 244 
     | 
    
         
            +
            		target_cc_include(target_node, doc)
         
     | 
| 
      
 245 
     | 
    
         
            +
            	end
         
     | 
| 
      
 246 
     | 
    
         
            +
             
     | 
| 
      
 247 
     | 
    
         
            +
            	def target_cxx_flags(target_node, doc)
         
     | 
| 
      
 248 
     | 
    
         
            +
            		target_cc_flags(target_node, doc)
         
     | 
| 
      
 249 
     | 
    
         
            +
            	end
         
     | 
| 
      
 250 
     | 
    
         
            +
             
     | 
| 
      
 251 
     | 
    
         
            +
            	def target_ld_flags(target_node, doc)
         
     | 
| 
      
 252 
     | 
    
         
            +
            		settings = {'IlinkConfigDefines' => {
         
     | 
| 
      
 253 
     | 
    
         
            +
                				'state' => doc
         
     | 
| 
      
 254 
     | 
    
         
            +
              					}
         
     | 
| 
      
 255 
     | 
    
         
            +
              				   }
         
     | 
| 
      
 256 
     | 
    
         
            +
              		add_specific(target_node, settings)
         
     | 
| 
      
 257 
     | 
    
         
            +
            	end
         
     | 
| 
      
 258 
     | 
    
         
            +
             
     | 
| 
      
 259 
     | 
    
         
            +
            	def target_libraries(target_node, doc)
         
     | 
| 
      
 260 
     | 
    
         
            +
            		settings = {'IlinkAdditionalLibs' => {
         
     | 
| 
      
 261 
     | 
    
         
            +
                				'state' => doc
         
     | 
| 
      
 262 
     | 
    
         
            +
              					}
         
     | 
| 
      
 263 
     | 
    
         
            +
              				   }
         
     | 
| 
      
 264 
     | 
    
         
            +
              		add_specific(target_node, settings)
         
     | 
| 
      
 265 
     | 
    
         
            +
            	end
         
     | 
| 
      
 266 
     | 
    
         
            +
             
     | 
| 
      
 267 
     | 
    
         
            +
            	def target_linker_file(target_node, doc)
         
     | 
| 
      
 268 
     | 
    
         
            +
            		settings_check = { 'IlinkIcfOverride' => {
         
     | 
| 
      
 269 
     | 
    
         
            +
            				'state' => 1
         
     | 
| 
      
 270 
     | 
    
         
            +
            			}
         
     | 
| 
      
 271 
     | 
    
         
            +
            		}
         
     | 
| 
      
 272 
     | 
    
         
            +
            		add_specific(target_node, settings_check)
         
     | 
| 
      
 273 
     | 
    
         
            +
            		o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
         
     | 
| 
      
 274 
     | 
    
         
            +
              		proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
         
     | 
| 
      
 275 
     | 
    
         
            +
              		settings = {'IlinkIcfFile' => {} }
         
     | 
| 
      
 276 
     | 
    
         
            +
              		inc_array = Array.new
         
     | 
| 
      
 277 
     | 
    
         
            +
              		if doc.has_key?("rootdir")
         
     | 
| 
      
 278 
     | 
    
         
            +
            	      full_path = @paths.fullpath(doc['rootdir'],doc['path'])
         
     | 
| 
      
 279 
     | 
    
         
            +
            	    else
         
     | 
| 
      
 280 
     | 
    
         
            +
            	      full_path = @paths.fullpath('default_path',doc['path'])
         
     | 
| 
      
 281 
     | 
    
         
            +
            	    end
         
     | 
| 
      
 282 
     | 
    
         
            +
            	    inc_array.insert(-1, File.join("$PROJ_DIR$", @paths.relpath(proj_path, full_path)))
         
     | 
| 
      
 283 
     | 
    
         
            +
              		settings['IlinkIcfFile']['state'] = inc_array.join(" ")
         
     | 
| 
      
 284 
     | 
    
         
            +
              		add_specific(target_node, settings)
         
     | 
| 
      
 285 
     | 
    
         
            +
            	end
         
     | 
| 
      
 286 
     | 
    
         
            +
             
     | 
| 
      
 287 
     | 
    
         
            +
            	def target_outdir(target_node, doc)
         
     | 
| 
      
 288 
     | 
    
         
            +
             
     | 
| 
      
 289 
     | 
    
         
            +
            	end
         
     | 
| 
      
 290 
     | 
    
         
            +
             
     | 
| 
      
 291 
     | 
    
         
            +
            end
         
     | 
| 
      
 292 
     | 
    
         
            +
             
     | 
| 
      
 293 
     | 
    
         
            +
            class Project_set
         
     | 
| 
      
 294 
     | 
    
         
            +
            	include EWW
         
     | 
| 
      
 295 
     | 
    
         
            +
            	include UNI_Project
         
     | 
| 
      
 296 
     | 
    
         
            +
            	TOOLCHAIN='iar'
         
     | 
| 
      
 297 
     | 
    
         
            +
             
     | 
| 
      
 298 
     | 
    
         
            +
            	# initialize EWW class
         
     | 
| 
      
 299 
     | 
    
         
            +
                # PARAMS:
         
     | 
| 
      
 300 
     | 
    
         
            +
                # - project_data: specific project data format for a application/library
         
     | 
| 
      
 301 
     | 
    
         
            +
                # - generator_variable: all dependency in hash
         
     | 
| 
      
 302 
     | 
    
         
            +
            	def initialize(project_data, generator_variable)
         
     | 
| 
      
 303 
     | 
    
         
            +
            		set_hash(project_data)
         
     | 
| 
      
 304 
     | 
    
         
            +
            		@project_name = get_project_name()
         
     | 
| 
      
 305 
     | 
    
         
            +
            		@board = get_board()
         
     | 
| 
      
 306 
     | 
    
         
            +
            		@paths = PathModifier.new(generator_variable["paths"])
         
     | 
| 
      
 307 
     | 
    
         
            +
            		@all_projects_hash = generator_variable["all"]
         
     | 
| 
      
 308 
     | 
    
         
            +
            		@iar_project_files = {".eww" => nil}
         
     | 
| 
      
 309 
     | 
    
         
            +
            		return nil if get_template(Project_set::TOOLCHAIN).nil?
         
     | 
| 
      
 310 
     | 
    
         
            +
            		get_template(Project_set::TOOLCHAIN).each do |template|
         
     | 
| 
      
 311 
     | 
    
         
            +
            			ext = File.extname(template)
         
     | 
| 
      
 312 
     | 
    
         
            +
            			if @iar_project_files.keys.include?(ext)
         
     | 
| 
      
 313 
     | 
    
         
            +
            				path = @paths.fullpath("default_path",template)
         
     | 
| 
      
 314 
     | 
    
         
            +
            				doc = Nokogiri::XML(open(path))
         
     | 
| 
      
 315 
     | 
    
         
            +
            				case ext
         
     | 
| 
      
 316 
     | 
    
         
            +
            					when ".eww"
         
     | 
| 
      
 317 
     | 
    
         
            +
            						@iar_project_files[ext] = doc
         
     | 
| 
      
 318 
     | 
    
         
            +
            					else
         
     | 
| 
      
 319 
     | 
    
         
            +
            						puts "#{ext} not processed"
         
     | 
| 
      
 320 
     | 
    
         
            +
            				end
         
     | 
| 
      
 321 
     | 
    
         
            +
            			end
         
     | 
| 
      
 322 
     | 
    
         
            +
            		end
         
     | 
| 
      
 323 
     | 
    
         
            +
            		#clean the wrkspace in template
         
     | 
| 
      
 324 
     | 
    
         
            +
            	 	@iar_project_files[".eww"].css("workspace/project").each do |node|
         
     | 
| 
      
 325 
     | 
    
         
            +
                    	node.remove
         
     | 
| 
      
 326 
     | 
    
         
            +
                	end
         
     | 
| 
      
 327 
     | 
    
         
            +
            	 	@iar_project_files[".eww"].css("workspace/batchBuild/batchDefinition").each do |node|
         
     | 
| 
      
 328 
     | 
    
         
            +
                    	node.remove
         
     | 
| 
      
 329 
     | 
    
         
            +
                	end  	
         
     | 
| 
      
 330 
     | 
    
         
            +
            	end
         
     | 
| 
      
 331 
     | 
    
         
            +
             
     | 
| 
      
 332 
     | 
    
         
            +
            	def generator()
         
     | 
| 
      
 333 
     | 
    
         
            +
            		add_project_to_set()
         
     | 
| 
      
 334 
     | 
    
         
            +
            		save_set()
         
     | 
| 
      
 335 
     | 
    
         
            +
            	end
         
     | 
| 
      
 336 
     | 
    
         
            +
             
     | 
| 
      
 337 
     | 
    
         
            +
             
     | 
| 
      
 338 
     | 
    
         
            +
            	def add_project_to_set()
         
     | 
| 
      
 339 
     | 
    
         
            +
            		return if @iar_project_files.nil?
         
     | 
| 
      
 340 
     | 
    
         
            +
            		return if @iar_project_files['.eww'].nil?
         
     | 
| 
      
 341 
     | 
    
         
            +
            		ext = ".eww"
         
     | 
| 
      
 342 
     | 
    
         
            +
             
     | 
| 
      
 343 
     | 
    
         
            +
            		#batch build mode is add
         
     | 
| 
      
 344 
     | 
    
         
            +
            		get_target_list(Project_set::TOOLCHAIN).each do |target|	
         
     | 
| 
      
 345 
     | 
    
         
            +
            			add_batch_project_target(@iar_project_files[ext], "all", @project_name, target)
         
     | 
| 
      
 346 
     | 
    
         
            +
            			add_batch_project_target(@iar_project_files[ext], target, @project_name, target)
         
     | 
| 
      
 347 
     | 
    
         
            +
            			next if get_libraries(Project_set::TOOLCHAIN).nil?
         
     | 
| 
      
 348 
     | 
    
         
            +
            			get_libraries(Project_set::TOOLCHAIN).each do |lib|
         
     | 
| 
      
 349 
     | 
    
         
            +
            				add_batch_project_target(@iar_project_files[ext], "all", lib, target)
         
     | 
| 
      
 350 
     | 
    
         
            +
            				add_batch_project_target(@iar_project_files[ext], target, lib, target)				
         
     | 
| 
      
 351 
     | 
    
         
            +
            			end
         
     | 
| 
      
 352 
     | 
    
         
            +
            		end
         
     | 
| 
      
 353 
     | 
    
         
            +
            		#add projects
         
     | 
| 
      
 354 
     | 
    
         
            +
            		file = "#{@project_name}_#{@board}.ewp"
         
     | 
| 
      
 355 
     | 
    
         
            +
            		path = File.join('$WS_DIR$',file)
         
     | 
| 
      
 356 
     | 
    
         
            +
            		add_project(@iar_project_files[ext], path)
         
     | 
| 
      
 357 
     | 
    
         
            +
            		#add library projects here
         
     | 
| 
      
 358 
     | 
    
         
            +
            		#get from dependency['libraries'][library_name]
         
     | 
| 
      
 359 
     | 
    
         
            +
            		ustruct = @all_projects_hash
         
     | 
| 
      
 360 
     | 
    
         
            +
            		return if get_libraries(Project_set::TOOLCHAIN).nil?
         
     | 
| 
      
 361 
     | 
    
         
            +
            		get_libraries(Project_set::TOOLCHAIN).each do |lib|
         
     | 
| 
      
 362 
     | 
    
         
            +
            			if ustruct[lib].nil?
         
     | 
| 
      
 363 
     | 
    
         
            +
            				puts "#{lib} information is missing in all hash"
         
     | 
| 
      
 364 
     | 
    
         
            +
            				next
         
     | 
| 
      
 365 
     | 
    
         
            +
            			end
         
     | 
| 
      
 366 
     | 
    
         
            +
            			libname = "#{@project_name}.ewp"
         
     | 
| 
      
 367 
     | 
    
         
            +
                        root = @paths.rootdir_table[@ustruct[library][tool_key]['outdir']['root-dir']]
         
     | 
| 
      
 368 
     | 
    
         
            +
                        lib_path = File.join(root, @ustruct[library][tool_key]['outdir']['path'], libname)
         
     | 
| 
      
 369 
     | 
    
         
            +
                        if @ustruct[ project_name ][ tool_key ].has_key?('outdir')
         
     | 
| 
      
 370 
     | 
    
         
            +
                            ewwpath = File.join(@output_rootdir, @ustruct[ project_name ][ tool_key ][ 'outdir' ] )
         
     | 
| 
      
 371 
     | 
    
         
            +
                        else
         
     | 
| 
      
 372 
     | 
    
         
            +
                            ewwpath = @output_rootdir
         
     | 
| 
      
 373 
     | 
    
         
            +
                        end
         
     | 
| 
      
 374 
     | 
    
         
            +
                        path = Pathname.new(lib_path).relative_path_from(Pathname.new(ewwpath))
         
     | 
| 
      
 375 
     | 
    
         
            +
            			#more to come
         
     | 
| 
      
 376 
     | 
    
         
            +
            		end
         
     | 
| 
      
 377 
     | 
    
         
            +
             
     | 
| 
      
 378 
     | 
    
         
            +
            	end
         
     | 
| 
      
 379 
     | 
    
         
            +
             
     | 
| 
      
 380 
     | 
    
         
            +
            	def save_set()
         
     | 
| 
      
 381 
     | 
    
         
            +
            		path = get_output_dir(Project_set::TOOLCHAIN, @paths.rootdir_table)
         
     | 
| 
      
 382 
     | 
    
         
            +
            		puts @paths.rootdir_table['output_root']
         
     | 
| 
      
 383 
     | 
    
         
            +
            		puts path
         
     | 
| 
      
 384 
     | 
    
         
            +
            		puts "#{@project_name}_#{@board}.eww"
         
     | 
| 
      
 385 
     | 
    
         
            +
            		save(@iar_project_files['.eww'], File.join(@paths.rootdir_table['output_root'], path, "#{@project_name}_#{@board}.eww"))
         
     | 
| 
      
 386 
     | 
    
         
            +
            	end
         
     | 
| 
      
 387 
     | 
    
         
            +
             
     | 
| 
      
 388 
     | 
    
         
            +
            end
         
     | 
| 
      
 389 
     | 
    
         
            +
             
     | 
| 
      
 390 
     | 
    
         
            +
            end # end Module IAR
         
     | 
| 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'pathname'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "deep_merge" 
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            class Assembly
         
     | 
| 
      
 5 
     | 
    
         
            +
            	def initialize(options)
         
     | 
| 
      
 6 
     | 
    
         
            +
            		@internal_hash = options
         
     | 
| 
      
 7 
     | 
    
         
            +
            	end
         
     | 
| 
      
 8 
     | 
    
         
            +
            	def assembly(project_name, key = "__add__")
         
     | 
| 
      
 9 
     | 
    
         
            +
            		@internal_hash[project_name][key].each do |submodule|
         
     | 
| 
      
 10 
     | 
    
         
            +
            			@internal_hash[project_name].deep_merge(deep_copy(@internal_hash[submodule]))
         
     | 
| 
      
 11 
     | 
    
         
            +
            		end
         
     | 
| 
      
 12 
     | 
    
         
            +
            		@internal_hash[project_name].delete(key)
         
     | 
| 
      
 13 
     | 
    
         
            +
            		@internal_hash.keys.each do |subkey|
         
     | 
| 
      
 14 
     | 
    
         
            +
            			next if subkey == project_name
         
     | 
| 
      
 15 
     | 
    
         
            +
            			@internal_hash.delete(subkey)
         
     | 
| 
      
 16 
     | 
    
         
            +
            		end
         
     | 
| 
      
 17 
     | 
    
         
            +
            	end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            	def deep_copy(o)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  Marshal.load(Marshal.dump(o))
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,42 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            require_relative 'adapter/iar'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require_relative 'adapter/cmake'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            class Generator
         
     | 
| 
      
 6 
     | 
    
         
            +
              attr_accessor :generator_variable
         
     | 
| 
      
 7 
     | 
    
         
            +
              def initialize(options)
         
     | 
| 
      
 8 
     | 
    
         
            +
                @generator_variable = options
         
     | 
| 
      
 9 
     | 
    
         
            +
                if @generator_variable.class != Hash
         
     | 
| 
      
 10 
     | 
    
         
            +
                  puts "failure options shall be a hash"
         
     | 
| 
      
 11 
     | 
    
         
            +
                  return
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
                if @generator_variable.has_key?('all') and @generator_variable.has_key?('paths')
         
     | 
| 
      
 14 
     | 
    
         
            +
                  puts "input setting is ok"
         
     | 
| 
      
 15 
     | 
    
         
            +
                else
         
     | 
| 
      
 16 
     | 
    
         
            +
                  puts "input settings is wrong"
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              def generate_projects(tool_chain, filter, project_data)
         
     | 
| 
      
 21 
     | 
    
         
            +
                case tool_chain.downcase
         
     | 
| 
      
 22 
     | 
    
         
            +
                when 'iar'
         
     | 
| 
      
 23 
     | 
    
         
            +
                	IAR::Project.new(project_data, @generator_variable).generator(filter, project_data)
         
     | 
| 
      
 24 
     | 
    
         
            +
                when 'mdk'
         
     | 
| 
      
 25 
     | 
    
         
            +
                	puts "mdk"
         
     | 
| 
      
 26 
     | 
    
         
            +
                when 'cmake'
         
     | 
| 
      
 27 
     | 
    
         
            +
                	CMAKE::Project.new(project_data, @generator_variable).generator(filter, project_data)
         
     | 
| 
      
 28 
     | 
    
         
            +
            	end
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              def generate_project_set(tool_chain, project_data)
         
     | 
| 
      
 32 
     | 
    
         
            +
                case tool_chain.downcase
         
     | 
| 
      
 33 
     | 
    
         
            +
                when 'iar'
         
     | 
| 
      
 34 
     | 
    
         
            +
                	IAR::Project_set.new(project_data, @generator_variable).generator()
         
     | 
| 
      
 35 
     | 
    
         
            +
                when 'mdk'
         
     | 
| 
      
 36 
     | 
    
         
            +
                	puts "mdk"
         
     | 
| 
      
 37 
     | 
    
         
            +
                when 'armgcc'
         
     | 
| 
      
 38 
     | 
    
         
            +
                	puts "armgcc"
         
     | 
| 
      
 39 
     | 
    
         
            +
            	end  
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            end
         
     |