ebngen 1.0.1 → 1.0.2
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/_yml_helper.rb +5 -7
 - data/lib/ebngen/adapter/cmake.rb +24 -10
 - data/lib/ebngen/adapter/iar/ewp.rb +5 -1
 - data/lib/ebngen/adapter/iar.rb +45 -14
 - data/lib/ebngen/generate.rb +15 -9
 - data/lib/ebngen/translate.rb +29 -20
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 289fba682eff193bbcdba2b0d625bb8bcf1d924d
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a8f9b56f7039a6dceae9451ff50f5b381ee634a8
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 2adc6498855aeed317dfef63d4c93471eca978624a217c1e8e5622beddccb6c5f885e5868af6103711acd3654e39a9a0b688007299730e8647645680617b3fdf
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: e1f54f7610740300010192657afc15be7be2045c1e7a3def44fb0e37e2f9a680f0bd74dcc03c6e25362fe31a43be70ef97ba053b8319bdc685e5d2e60ccc0b96
         
     | 
| 
         @@ -3,18 +3,16 @@ require "yaml" 
     | 
|
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            module UNI_Project
         
     | 
| 
      
 6 
     | 
    
         
            +
              def is_toolchain_support(tool_chain)
         
     | 
| 
      
 7 
     | 
    
         
            +
                return @projects_hash.has_key?(tool_chain)
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
       6 
9 
     | 
    
         | 
| 
       7 
10 
     | 
    
         
             
              def set_hash(options)
         
     | 
| 
       8 
11 
     | 
    
         
             
                 @projects_hash = options
         
     | 
| 
       9 
12 
     | 
    
         
             
              end
         
     | 
| 
       10 
13 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
              def get_output_dir(toolchain,  path_hash 
     | 
| 
       12 
     | 
    
         
            -
                 
     | 
| 
       13 
     | 
    
         
            -
                  return File.join(@projects_hash[toolchain]["outdir"], toolchain)
         
     | 
| 
       14 
     | 
    
         
            -
                elsif ! args[:dir].nil?
         
     | 
| 
       15 
     | 
    
         
            -
                  return Pathname.new(File.join(
         
     | 
| 
       16 
     | 
    
         
            -
                  @projects_hash[toolchain]["outdir"], toolchain)).relative_path_from(Pathname.new(args[:dir])).to_s
         
     | 
| 
       17 
     | 
    
         
            -
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
              def get_output_dir(toolchain,  path_hash)
         
     | 
| 
      
 15 
     | 
    
         
            +
                @projects_hash[toolchain]["outdir"]
         
     | 
| 
       18 
16 
     | 
    
         
             
              end
         
     | 
| 
       19 
17 
     | 
    
         | 
| 
       20 
18 
     | 
    
         
             
              def get_src_list(toolchain)
         
     | 
    
        data/lib/ebngen/adapter/cmake.rb
    CHANGED
    
    | 
         @@ -18,7 +18,12 @@ module CMAKE 
     | 
|
| 
       18 
18 
     | 
    
         
             
            	include TXT
         
     | 
| 
       19 
19 
     | 
    
         
             
            	include UNI_Project
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
            	def initialize(project_data, generator_variable)
         
     | 
| 
      
 21 
     | 
    
         
            +
            	def initialize(project_data, generator_variable, logger = nil)
         
     | 
| 
      
 22 
     | 
    
         
            +
            		@logger = logger 
         
     | 
| 
      
 23 
     | 
    
         
            +
                	unless (logger)
         
     | 
| 
      
 24 
     | 
    
         
            +
                    	@logger = Logger.new(STDOUT)
         
     | 
| 
      
 25 
     | 
    
         
            +
                    	@logger.level = Logger::WARN
         
     | 
| 
      
 26 
     | 
    
         
            +
                	end
         
     | 
| 
       22 
27 
     | 
    
         
             
            		set_hash(project_data)
         
     | 
| 
       23 
28 
     | 
    
         
             
            		@project_name = get_project_name()
         
     | 
| 
       24 
29 
     | 
    
         
             
            		@board = get_board()
         
     | 
| 
         @@ -29,6 +34,7 @@ module CMAKE 
     | 
|
| 
       29 
34 
     | 
    
         
             
            	end
         
     | 
| 
       30 
35 
     | 
    
         | 
| 
       31 
36 
     | 
    
         
             
              	def generator(filter, project_data)
         
     | 
| 
      
 37 
     | 
    
         
            +
              		return if not is_toolchain_support(Project::TOOLCHAIN)
         
     | 
| 
       32 
38 
     | 
    
         
             
                	create_method(Project::TOOLCHAIN)
         
     | 
| 
       33 
39 
     | 
    
         
             
                	send(Project::TOOLCHAIN.to_sym, project_data)
         
     | 
| 
       34 
40 
     | 
    
         
             
                	save_project()
         
     | 
| 
         @@ -41,13 +47,21 @@ module CMAKE 
     | 
|
| 
       41 
47 
     | 
    
         
             
              		proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
         
     | 
| 
       42 
48 
     | 
    
         
             
              		@project['sources'] = Array.new
         
     | 
| 
       43 
49 
     | 
    
         
             
              		sources.each do |src|
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
      
 50 
     | 
    
         
            +
            			if file['rootdir']
         
     | 
| 
      
 51 
     | 
    
         
            +
            			  if file.has_key? 'path'
         
     | 
| 
      
 52 
     | 
    
         
            +
            			    full_path = path_mod.fullpath(file['rootdir'],file['path'])
         
     | 
| 
      
 53 
     | 
    
         
            +
            			  else
         
     | 
| 
      
 54 
     | 
    
         
            +
            			    full_path = path_mod.fullpath(file['rootdir'],file['source'])
         
     | 
| 
      
 55 
     | 
    
         
            +
            			  end
         
     | 
| 
      
 56 
     | 
    
         
            +
            			else
         
     | 
| 
      
 57 
     | 
    
         
            +
            			  if file.has_key? 'path'
         
     | 
| 
      
 58 
     | 
    
         
            +
            			    full_path = path_mod.fullpath('default_path',file['path'])
         
     | 
| 
      
 59 
     | 
    
         
            +
            			  else
         
     | 
| 
      
 60 
     | 
    
         
            +
            			    full_path = path_mod.fullpath('default_path',file['source'])
         
     | 
| 
      
 61 
     | 
    
         
            +
            			  end
         
     | 
| 
      
 62 
     | 
    
         
            +
            			end
         
     | 
| 
      
 63 
     | 
    
         
            +
                      	ipath = File.join("$ProjDirPath$", @paths.relpath(proj_path, full_path))
         
     | 
| 
      
 64 
     | 
    
         
            +
            		  	@project['sources'].insert(-1, ipath)
         
     | 
| 
       51 
65 
     | 
    
         
             
            		end
         
     | 
| 
       52 
66 
     | 
    
         | 
| 
       53 
67 
     | 
    
         
             
              	end
         
     | 
| 
         @@ -61,7 +75,7 @@ module CMAKE 
     | 
|
| 
       61 
75 
     | 
    
         
             
              	end
         
     | 
| 
       62 
76 
     | 
    
         | 
| 
       63 
77 
     | 
    
         
             
              	def outdir()
         
     | 
| 
       64 
     | 
    
         
            -
              		 
     | 
| 
      
 78 
     | 
    
         
            +
              		@logger.info "#{get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)}"
         
     | 
| 
       65 
79 
     | 
    
         
             
              	end
         
     | 
| 
       66 
80 
     | 
    
         | 
| 
       67 
81 
     | 
    
         
             
            	def targets()
         
     | 
| 
         @@ -76,7 +90,7 @@ module CMAKE 
     | 
|
| 
       76 
90 
     | 
    
         
             
                      		if methods.include?("target_#{subkey}".to_sym)
         
     | 
| 
       77 
91 
     | 
    
         
             
                        		send("target_#{subkey}".to_sym, key, value[subkey])
         
     | 
| 
       78 
92 
     | 
    
         
             
                      		else
         
     | 
| 
       79 
     | 
    
         
            -
                        		 
     | 
| 
      
 93 
     | 
    
         
            +
                        		@logger.info "#{key} is not processed"
         
     | 
| 
       80 
94 
     | 
    
         
             
                      		end
         
     | 
| 
       81 
95 
     | 
    
         
             
            			end
         
     | 
| 
       82 
96 
     | 
    
         
             
            		end
         
     | 
| 
         @@ -204,7 +204,11 @@ module EWP 
     | 
|
| 
       204 
204 
     | 
    
         
             
                source_hash.each do |src|
         
     | 
| 
       205 
205 
     | 
    
         
             
                  rootdir = src['rootdir']
         
     | 
| 
       206 
206 
     | 
    
         
             
                  virtual_dir = src['virtual_dir']
         
     | 
| 
       207 
     | 
    
         
            -
                   
     | 
| 
      
 207 
     | 
    
         
            +
                  if src.has_key?('path')
         
     | 
| 
      
 208 
     | 
    
         
            +
                    path = src['path']
         
     | 
| 
      
 209 
     | 
    
         
            +
                  else
         
     | 
| 
      
 210 
     | 
    
         
            +
                    path = src['source']
         
     | 
| 
      
 211 
     | 
    
         
            +
                  end
         
     | 
| 
       208 
212 
     | 
    
         
             
                  if virtual_dir
         
     | 
| 
       209 
213 
     | 
    
         
             
                    if ! groups_existing.include?(virtual_dir)
         
     | 
| 
       210 
214 
     | 
    
         
             
                      groups_existing.insert(-1, virtual_dir)
         
     | 
    
        data/lib/ebngen/adapter/iar.rb
    CHANGED
    
    | 
         @@ -20,7 +20,12 @@ class Project 
     | 
|
| 
       20 
20 
     | 
    
         
             
            	include EWD
         
     | 
| 
       21 
21 
     | 
    
         
             
            	include UNI_Project
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
            	def initialize(project_data, generator_variable)
         
     | 
| 
      
 23 
     | 
    
         
            +
            	def initialize(project_data, generator_variable, logger = nil)
         
     | 
| 
      
 24 
     | 
    
         
            +
            		@logger = logger 
         
     | 
| 
      
 25 
     | 
    
         
            +
                	unless (logger)
         
     | 
| 
      
 26 
     | 
    
         
            +
                    	@logger = Logger.new(STDOUT)
         
     | 
| 
      
 27 
     | 
    
         
            +
                    	@logger.level = Logger::WARN
         
     | 
| 
      
 28 
     | 
    
         
            +
                	end
         
     | 
| 
       24 
29 
     | 
    
         
             
            		set_hash(project_data)
         
     | 
| 
       25 
30 
     | 
    
         
             
            		@project_name = get_project_name()
         
     | 
| 
       26 
31 
     | 
    
         
             
            		@board = get_board()
         
     | 
| 
         @@ -28,7 +33,7 @@ class Project 
     | 
|
| 
       28 
33 
     | 
    
         
             
            		@iar_project_files = {".ewp" => nil, ".dni" => nil, ".ewd" => nil, ".yml" => nil}
         
     | 
| 
       29 
34 
     | 
    
         
             
            		return nil if get_template(Project::TOOLCHAIN).nil?
         
     | 
| 
       30 
35 
     | 
    
         
             
            		get_template(Project::TOOLCHAIN).each do |template|
         
     | 
| 
       31 
     | 
    
         
            -
            			 
     | 
| 
      
 36 
     | 
    
         
            +
            			@logger.info template
         
     | 
| 
       32 
37 
     | 
    
         
             
            			ext = File.extname(template)
         
     | 
| 
       33 
38 
     | 
    
         
             
            			if @iar_project_files.keys.include?(ext)
         
     | 
| 
       34 
39 
     | 
    
         
             
            				path = @paths.fullpath("default_path",template)
         
     | 
| 
         @@ -45,13 +50,14 @@ class Project 
     | 
|
| 
       45 
50 
     | 
    
         
             
            						@iar_project_files[ext] = doc
         
     | 
| 
       46 
51 
     | 
    
         
             
            				end
         
     | 
| 
       47 
52 
     | 
    
         
             
            			  #rescue
         
     | 
| 
       48 
     | 
    
         
            -
            			  #	 
     | 
| 
      
 53 
     | 
    
         
            +
            			  #	@logger.info "failed to open #{template}"
         
     | 
| 
       49 
54 
     | 
    
         
             
            			  #end
         
     | 
| 
       50 
55 
     | 
    
         
             
            			end
         
     | 
| 
       51 
56 
     | 
    
         
             
            		end
         
     | 
| 
       52 
57 
     | 
    
         
             
            	end
         
     | 
| 
       53 
58 
     | 
    
         | 
| 
       54 
59 
     | 
    
         
             
              	def generator(filter, project_data)
         
     | 
| 
      
 60 
     | 
    
         
            +
              		return if not is_toolchain_support(Project::TOOLCHAIN)
         
     | 
| 
       55 
61 
     | 
    
         
             
                	create_method( Project::TOOLCHAIN)
         
     | 
| 
       56 
62 
     | 
    
         
             
                	send(Project::TOOLCHAIN.to_sym, project_data)
         
     | 
| 
       57 
63 
     | 
    
         
             
                	save_project()
         
     | 
| 
         @@ -80,21 +86,36 @@ class Project 
     | 
|
| 
       80 
86 
     | 
    
         
             
              	end
         
     | 
| 
       81 
87 
     | 
    
         | 
| 
       82 
88 
     | 
    
         
             
            	def targets()
         
     | 
| 
      
 89 
     | 
    
         
            +
            		convert_lut = {
         
     | 
| 
      
 90 
     | 
    
         
            +
            			'cx_flags' => 'cxx_flags',
         
     | 
| 
      
 91 
     | 
    
         
            +
            			'cc_define' => 'cc_defines',
         
     | 
| 
      
 92 
     | 
    
         
            +
            			'cx_define' => 'cxx_defines',
         
     | 
| 
      
 93 
     | 
    
         
            +
            			'as_define' => 'as_defines', 
         
     | 
| 
      
 94 
     | 
    
         
            +
            			'cp_define' => 'cp_defines',
         
     | 
| 
      
 95 
     | 
    
         
            +
            			'ar_flags' => 'ar_flags' 
         
     | 
| 
      
 96 
     | 
    
         
            +
            		}
         
     | 
| 
       83 
97 
     | 
    
         
             
            		get_targets(Project::TOOLCHAIN).each do |key, value|
         
     | 
| 
       84 
98 
     | 
    
         
             
            			next if value.nil?
         
     | 
| 
       85 
99 
     | 
    
         
             
            			#add target for ewp
         
     | 
| 
       86 
100 
     | 
    
         
             
            			t = new_target(key, @iar_project_files['.ewp'])
         
     | 
| 
       87 
101 
     | 
    
         
             
            			if t.nil?
         
     | 
| 
       88 
     | 
    
         
            -
            			   
     | 
| 
      
 102 
     | 
    
         
            +
            			  @logger.info "missing default debug configuration in template"
         
     | 
| 
       89 
103 
     | 
    
         
             
             			  return
         
     | 
| 
       90 
104 
     | 
    
         
             
            			end
         
     | 
| 
       91 
105 
     | 
    
         
             
            			#do the target settings
         
     | 
| 
       92 
106 
     | 
    
         
             
            			value.each_key do |subkey|
         
     | 
| 
      
 107 
     | 
    
         
            +
            				#for backward compatible
         
     | 
| 
      
 108 
     | 
    
         
            +
            				temp_op = subkey.gsub('-', '_')
         
     | 
| 
      
 109 
     | 
    
         
            +
            				if convert_lut.has_key? temp_op
         
     | 
| 
      
 110 
     | 
    
         
            +
            					target_op = convert_lut[temp_op]
         
     | 
| 
      
 111 
     | 
    
         
            +
            				else
         
     | 
| 
      
 112 
     | 
    
         
            +
            					target_op = temp_op
         
     | 
| 
      
 113 
     | 
    
         
            +
            				end
         
     | 
| 
       93 
114 
     | 
    
         
             
            				methods = self.class.instance_methods(false)
         
     | 
| 
       94 
     | 
    
         
            -
                      		if methods.include?("target_#{ 
     | 
| 
       95 
     | 
    
         
            -
                        		send("target_#{ 
     | 
| 
      
 115 
     | 
    
         
            +
                      		if methods.include?("target_#{target_op}".to_sym)
         
     | 
| 
      
 116 
     | 
    
         
            +
                        		send("target_#{target_op}".to_sym, t, value[subkey])
         
     | 
| 
       96 
117 
     | 
    
         
             
                      		else
         
     | 
| 
       97 
     | 
    
         
            -
                        		 
     | 
| 
      
 118 
     | 
    
         
            +
                        		@logger.info "#{subkey} is not processed try to use the tool-chain specific"
         
     | 
| 
       98 
119 
     | 
    
         
             
                      		end
         
     | 
| 
       99 
120 
     | 
    
         
             
            			end
         
     | 
| 
       100 
121 
     | 
    
         
             
            		end
         
     | 
| 
         @@ -299,7 +320,12 @@ class Project_set 
     | 
|
| 
       299 
320 
     | 
    
         
             
                # PARAMS:
         
     | 
| 
       300 
321 
     | 
    
         
             
                # - project_data: specific project data format for a application/library
         
     | 
| 
       301 
322 
     | 
    
         
             
                # - generator_variable: all dependency in hash
         
     | 
| 
       302 
     | 
    
         
            -
            	def initialize(project_data, generator_variable)
         
     | 
| 
      
 323 
     | 
    
         
            +
            	def initialize(project_data, generator_variable, logger = nil)
         
     | 
| 
      
 324 
     | 
    
         
            +
            		@logger = logger 
         
     | 
| 
      
 325 
     | 
    
         
            +
                	unless (logger)
         
     | 
| 
      
 326 
     | 
    
         
            +
                    	@logger = Logger.new(STDOUT)
         
     | 
| 
      
 327 
     | 
    
         
            +
                    	@logger.level = Logger::WARN
         
     | 
| 
      
 328 
     | 
    
         
            +
                	end
         
     | 
| 
       303 
329 
     | 
    
         
             
            		set_hash(project_data)
         
     | 
| 
       304 
330 
     | 
    
         
             
            		@project_name = get_project_name()
         
     | 
| 
       305 
331 
     | 
    
         
             
            		@board = get_board()
         
     | 
| 
         @@ -316,7 +342,7 @@ class Project_set 
     | 
|
| 
       316 
342 
     | 
    
         
             
            					when ".eww"
         
     | 
| 
       317 
343 
     | 
    
         
             
            						@iar_project_files[ext] = doc
         
     | 
| 
       318 
344 
     | 
    
         
             
            					else
         
     | 
| 
       319 
     | 
    
         
            -
            						 
     | 
| 
      
 345 
     | 
    
         
            +
            						@logger.info "#{ext} not processed"
         
     | 
| 
       320 
346 
     | 
    
         
             
            				end
         
     | 
| 
       321 
347 
     | 
    
         
             
            			end
         
     | 
| 
       322 
348 
     | 
    
         
             
            		end
         
     | 
| 
         @@ -330,6 +356,7 @@ class Project_set 
     | 
|
| 
       330 
356 
     | 
    
         
             
            	end
         
     | 
| 
       331 
357 
     | 
    
         | 
| 
       332 
358 
     | 
    
         
             
            	def generator()
         
     | 
| 
      
 359 
     | 
    
         
            +
            		return if not is_toolchain_support(Project::TOOLCHAIN)
         
     | 
| 
       333 
360 
     | 
    
         
             
            		add_project_to_set()
         
     | 
| 
       334 
361 
     | 
    
         
             
            		save_set()
         
     | 
| 
       335 
362 
     | 
    
         
             
            	end
         
     | 
| 
         @@ -360,7 +387,7 @@ class Project_set 
     | 
|
| 
       360 
387 
     | 
    
         
             
            		return if get_libraries(Project_set::TOOLCHAIN).nil?
         
     | 
| 
       361 
388 
     | 
    
         
             
            		get_libraries(Project_set::TOOLCHAIN).each do |lib|
         
     | 
| 
       362 
389 
     | 
    
         
             
            			if ustruct[lib].nil?
         
     | 
| 
       363 
     | 
    
         
            -
            				 
     | 
| 
      
 390 
     | 
    
         
            +
            				@logger.info "#{lib} information is missing in all hash"
         
     | 
| 
       364 
391 
     | 
    
         
             
            				next
         
     | 
| 
       365 
392 
     | 
    
         
             
            			end
         
     | 
| 
       366 
393 
     | 
    
         
             
            			libname = "#{@project_name}.ewp"
         
     | 
| 
         @@ -379,10 +406,14 @@ class Project_set 
     | 
|
| 
       379 
406 
     | 
    
         | 
| 
       380 
407 
     | 
    
         
             
            	def save_set()
         
     | 
| 
       381 
408 
     | 
    
         
             
            		path = get_output_dir(Project_set::TOOLCHAIN, @paths.rootdir_table)
         
     | 
| 
       382 
     | 
    
         
            -
            		 
     | 
| 
       383 
     | 
    
         
            -
            		 
     | 
| 
       384 
     | 
    
         
            -
            		 
     | 
| 
       385 
     | 
    
         
            -
            		 
     | 
| 
      
 409 
     | 
    
         
            +
            		@logger.info  @paths.rootdir_table['output_root']
         
     | 
| 
      
 410 
     | 
    
         
            +
            		@logger.info path
         
     | 
| 
      
 411 
     | 
    
         
            +
            		@logger.info "#{@project_name}_#{@board}.eww"
         
     | 
| 
      
 412 
     | 
    
         
            +
            		if path.class == Hash 
         
     | 
| 
      
 413 
     | 
    
         
            +
            			save(@iar_project_files['.eww'], File.join(@paths.rootdir_table[path['rootdir']], path['path'], "#{@project_name}_#{@board}.eww"))
         
     | 
| 
      
 414 
     | 
    
         
            +
            		else
         
     | 
| 
      
 415 
     | 
    
         
            +
            		  save(@iar_project_files['.eww'], File.join(@paths.rootdir_table['output_root'], path, "#{@project_name}_#{@board}.eww"))
         
     | 
| 
      
 416 
     | 
    
         
            +
            		end
         
     | 
| 
       386 
417 
     | 
    
         
             
            	end
         
     | 
| 
       387 
418 
     | 
    
         | 
| 
       388 
419 
     | 
    
         
             
            end
         
     | 
    
        data/lib/ebngen/generate.rb
    CHANGED
    
    | 
         @@ -1,41 +1,47 @@ 
     | 
|
| 
       1 
1 
     | 
    
         | 
| 
       2 
2 
     | 
    
         
             
            require_relative 'adapter/iar'
         
     | 
| 
       3 
3 
     | 
    
         
             
            require_relative 'adapter/cmake'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'logger'
         
     | 
| 
       4 
5 
     | 
    
         | 
| 
       5 
6 
     | 
    
         
             
            class Generator
         
     | 
| 
       6 
7 
     | 
    
         
             
              attr_accessor :generator_variable
         
     | 
| 
       7 
     | 
    
         
            -
              def initialize(options)
         
     | 
| 
      
 8 
     | 
    
         
            +
              def initialize(options, logger = nil)
         
     | 
| 
      
 9 
     | 
    
         
            +
                @logger = logger 
         
     | 
| 
      
 10 
     | 
    
         
            +
                unless (logger)
         
     | 
| 
      
 11 
     | 
    
         
            +
                    @logger = Logger.new(STDOUT)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    @logger.level = Logger::INFO
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
       8 
14 
     | 
    
         
             
                @generator_variable = options
         
     | 
| 
       9 
15 
     | 
    
         
             
                if @generator_variable.class != Hash
         
     | 
| 
       10 
16 
     | 
    
         
             
                  puts "failure options shall be a hash"
         
     | 
| 
       11 
17 
     | 
    
         
             
                  return
         
     | 
| 
       12 
18 
     | 
    
         
             
                end
         
     | 
| 
       13 
19 
     | 
    
         
             
                if @generator_variable.has_key?('all') and @generator_variable.has_key?('paths')
         
     | 
| 
       14 
     | 
    
         
            -
                   
     | 
| 
      
 20 
     | 
    
         
            +
                  @logger.info "input setting is ok"
         
     | 
| 
       15 
21 
     | 
    
         
             
                else
         
     | 
| 
       16 
     | 
    
         
            -
                   
     | 
| 
      
 22 
     | 
    
         
            +
                  @logger.info "input settings is wrong"
         
     | 
| 
       17 
23 
     | 
    
         
             
                end
         
     | 
| 
       18 
24 
     | 
    
         
             
              end
         
     | 
| 
       19 
25 
     | 
    
         | 
| 
       20 
26 
     | 
    
         
             
              def generate_projects(tool_chain, filter, project_data)
         
     | 
| 
       21 
27 
     | 
    
         
             
                case tool_chain.downcase
         
     | 
| 
       22 
28 
     | 
    
         
             
                when 'iar'
         
     | 
| 
       23 
     | 
    
         
            -
                	IAR::Project.new(project_data, @generator_variable).generator(filter, project_data)
         
     | 
| 
      
 29 
     | 
    
         
            +
                	IAR::Project.new(project_data, @generator_variable, @logger).generator(filter, project_data)
         
     | 
| 
       24 
30 
     | 
    
         
             
                when 'mdk'
         
     | 
| 
       25 
     | 
    
         
            -
                	 
     | 
| 
      
 31 
     | 
    
         
            +
                	@logger.info "mdk TBD"
         
     | 
| 
       26 
32 
     | 
    
         
             
                when 'cmake'
         
     | 
| 
       27 
     | 
    
         
            -
                	CMAKE::Project.new(project_data, @generator_variable).generator(filter, project_data)
         
     | 
| 
      
 33 
     | 
    
         
            +
                	CMAKE::Project.new(project_data, @generator_variable, @logger).generator(filter, project_data)
         
     | 
| 
       28 
34 
     | 
    
         
             
            	end
         
     | 
| 
       29 
35 
     | 
    
         
             
              end
         
     | 
| 
       30 
36 
     | 
    
         | 
| 
       31 
37 
     | 
    
         
             
              def generate_project_set(tool_chain, project_data)
         
     | 
| 
       32 
38 
     | 
    
         
             
                case tool_chain.downcase
         
     | 
| 
       33 
39 
     | 
    
         
             
                when 'iar'
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 40 
     | 
    
         
            +
                	 IAR::Project_set.new(project_data, @generator_variable, @logger).generator()
         
     | 
| 
       35 
41 
     | 
    
         
             
                when 'mdk'
         
     | 
| 
       36 
     | 
    
         
            -
                	 
     | 
| 
      
 42 
     | 
    
         
            +
                	@logger.info "mdk TBD"
         
     | 
| 
       37 
43 
     | 
    
         
             
                when 'armgcc'
         
     | 
| 
       38 
     | 
    
         
            -
                	 
     | 
| 
      
 44 
     | 
    
         
            +
                	@logger.info "armgcc TBD"
         
     | 
| 
       39 
45 
     | 
    
         
             
            	end  
         
     | 
| 
       40 
46 
     | 
    
         
             
              end
         
     | 
| 
       41 
47 
     | 
    
         | 
    
        data/lib/ebngen/translate.rb
    CHANGED
    
    | 
         @@ -2,6 +2,7 @@ require 'deep_merge' 
     | 
|
| 
       2 
2 
     | 
    
         
             
            require 'rubygems'
         
     | 
| 
       3 
3 
     | 
    
         
             
            require 'pathname'
         
     | 
| 
       4 
4 
     | 
    
         
             
            require 'fileutils'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'logger'
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            module Utils_set
         
     | 
| 
       7 
8 
     | 
    
         
             
              def nodes_exist?(node, subnodes)
         
     | 
| 
         @@ -18,7 +19,12 @@ class Translator 
     | 
|
| 
       18 
19 
     | 
    
         | 
| 
       19 
20 
     | 
    
         
             
              include Utils_set
         
     | 
| 
       20 
21 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
              def initialize(node, logger 
     | 
| 
      
 22 
     | 
    
         
            +
              def initialize(node, logger = nil)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  @logger = logger 
         
     | 
| 
      
 24 
     | 
    
         
            +
                  unless (logger)
         
     | 
| 
      
 25 
     | 
    
         
            +
                    @logger = Logger.new(STDOUT)
         
     | 
| 
      
 26 
     | 
    
         
            +
                    @logger.level = Logger::INFO
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
       22 
28 
     | 
    
         
             
                  @data_in = deep_copy(node)
         
     | 
| 
       23 
29 
     | 
    
         
             
                  @data_in_component = deep_copy(node)
         
     | 
| 
       24 
30 
     | 
    
         
             
                  @data_out = Hash.new
         
     | 
| 
         @@ -61,10 +67,10 @@ class Translator 
     | 
|
| 
       61 
67 
     | 
    
         
             
                      begin
         
     | 
| 
       62 
68 
     | 
    
         
             
                        next if struct[subnode]['configuration']['section-type'] != "application"
         
     | 
| 
       63 
69 
     | 
    
         
             
                        if struct[addon]['configuration']['section-type'] != "component"
         
     | 
| 
       64 
     | 
    
         
            -
                           
     | 
| 
      
 70 
     | 
    
         
            +
                          @logger.warn "WARNING #{addon} is required as component but has not a component attribute"
         
     | 
| 
       65 
71 
     | 
    
         
             
                        end
         
     | 
| 
       66 
72 
     | 
    
         
             
                      rescue
         
     | 
| 
       67 
     | 
    
         
            -
                         
     | 
| 
      
 73 
     | 
    
         
            +
                        @logger.error "error with the merge_by_add with #{subnode} add #{addon}"
         
     | 
| 
       68 
74 
     | 
    
         
             
                      end
         
     | 
| 
       69 
75 
     | 
    
         
             
                        deep_add_merge(struct, subnode, addon)
         
     | 
| 
       70 
76 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -79,6 +85,25 @@ class Translator 
     | 
|
| 
       79 
85 
     | 
    
         
             
                 #puts @data_out.to_yaml
         
     | 
| 
       80 
86 
     | 
    
         
             
              end
         
     | 
| 
       81 
87 
     | 
    
         | 
| 
      
 88 
     | 
    
         
            +
              def output_path(proj, comp)
         
     | 
| 
      
 89 
     | 
    
         
            +
                if @data_in[proj].has_key?('outdir')
         
     | 
| 
      
 90 
     | 
    
         
            +
                  board = @data_in[proj]['configuration']['board']
         
     | 
| 
      
 91 
     | 
    
         
            +
                  if @data_out[proj][comp]['type'] == "library"
         
     | 
| 
      
 92 
     | 
    
         
            +
                    if comp == 'uv4'
         
     | 
| 
      
 93 
     | 
    
         
            +
                      @data_out[proj][comp]['outdir'] = File.join(@data_in[proj]['outdir'], proj, "mdk")
         
     | 
| 
      
 94 
     | 
    
         
            +
                    else
         
     | 
| 
      
 95 
     | 
    
         
            +
                      @data_out[proj][comp]['outdir'] = File.join(@data_in[proj]['outdir'], proj, comp)
         
     | 
| 
      
 96 
     | 
    
         
            +
                    end
         
     | 
| 
      
 97 
     | 
    
         
            +
                  else
         
     | 
| 
      
 98 
     | 
    
         
            +
                    if comp == "uv4"
         
     | 
| 
      
 99 
     | 
    
         
            +
                      @data_out[proj][comp]['outdir'] = File.join(board, @data_in[proj]['outdir'], "mdk")
         
     | 
| 
      
 100 
     | 
    
         
            +
                    else
         
     | 
| 
      
 101 
     | 
    
         
            +
                      @data_out[proj][comp]['outdir'] = File.join(board, @data_in[proj]['outdir'], comp)
         
     | 
| 
      
 102 
     | 
    
         
            +
                    end
         
     | 
| 
      
 103 
     | 
    
         
            +
                  end
         
     | 
| 
      
 104 
     | 
    
         
            +
                end
         
     | 
| 
      
 105 
     | 
    
         
            +
              end
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
       82 
107 
     | 
    
         
             
              private
         
     | 
| 
       83 
108 
     | 
    
         | 
| 
       84 
109 
     | 
    
         
             
              def convert_rules(proj, comp = 'iar')
         
     | 
| 
         @@ -111,23 +136,7 @@ class Translator 
     | 
|
| 
       111 
136 
     | 
    
         
             
                  if compiler.has_key?("group")
         
     | 
| 
       112 
137 
     | 
    
         
             
                     @data_out[proj][comp]['group'] =  compiler['group']
         
     | 
| 
       113 
138 
     | 
    
         
             
                  end
         
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
                  if @data_in[proj].has_key?('outdir')
         
     | 
| 
       116 
     | 
    
         
            -
                    board = @data_in[proj]['configuration']['board']
         
     | 
| 
       117 
     | 
    
         
            -
                    if @data_out[proj][comp]['type'] == "library"
         
     | 
| 
       118 
     | 
    
         
            -
                      if comp == 'uv4'
         
     | 
| 
       119 
     | 
    
         
            -
                        @data_out[proj][comp]['outdir'] = File.join(@data_in[proj]['outdir'], proj, "mdk")
         
     | 
| 
       120 
     | 
    
         
            -
                      else
         
     | 
| 
       121 
     | 
    
         
            -
                        @data_out[proj][comp]['outdir'] = File.join(@data_in[proj]['outdir'], proj, comp)
         
     | 
| 
       122 
     | 
    
         
            -
                      end
         
     | 
| 
       123 
     | 
    
         
            -
                    else
         
     | 
| 
       124 
     | 
    
         
            -
                      if comp == "uv4"
         
     | 
| 
       125 
     | 
    
         
            -
                        @data_out[proj][comp]['outdir'] = File.join(@data_in[proj]['outdir'], "mdk", board)
         
     | 
| 
       126 
     | 
    
         
            -
                      else
         
     | 
| 
       127 
     | 
    
         
            -
                        @data_out[proj][comp]['outdir'] = File.join(@data_in[proj]['outdir'], comp, board)
         
     | 
| 
       128 
     | 
    
         
            -
                      end
         
     | 
| 
       129 
     | 
    
         
            -
                    end
         
     | 
| 
       130 
     | 
    
         
            -
                  end
         
     | 
| 
      
 139 
     | 
    
         
            +
                  output_path(proj, comp)
         
     | 
| 
       131 
140 
     | 
    
         
             
              	  compiler['config'].each_key do |target|
         
     | 
| 
       132 
141 
     | 
    
         
             
                      next if compiler['load-to'].nil?
         
     | 
| 
       133 
142 
     | 
    
         
             
                      next if compiler['load-to'][target].nil?
         
     |