Class: IAR::Project_set

Inherits:
Object
  • Object
show all
Includes:
EWW, UNI_Project
Defined in:
lib/ebngen/adapter/iar.rb

Constant Summary collapse

TOOLCHAIN =
'iar'

Instance Method Summary collapse

Methods included from UNI_Project

#get_board, #get_libraries, #get_output_dir, #get_project_name, #get_src_list, #get_target_list, #get_targets, #get_template, #get_type, #is_toolchain_support, #set_hash

Methods included from EWW

#add_batch_project_target, #add_project, #save

Constructor Details

#initialize(project_data, generator_variable, logger = nil) ⇒ Project_set

PARAMS:

  • project_data: specific project data format for a application/library

  • generator_variable: all dependency in hash



323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/ebngen/adapter/iar.rb', line 323

def initialize(project_data, generator_variable, logger = nil)
	@logger = logger 
   	unless (logger)
       	@logger = Logger.new(STDOUT)
       	@logger.level = Logger::WARN
   	end
	set_hash(project_data)
	@project_name = get_project_name()
	@board = get_board()
	@paths = PathModifier.new(generator_variable["paths"])
	@all_projects_hash = generator_variable["all"]
	@iar_project_files = {".eww" => nil}
	return nil if get_template(Project_set::TOOLCHAIN).nil?
	get_template(Project_set::TOOLCHAIN).each do |template|
		ext = File.extname(template)
		if @iar_project_files.keys.include?(ext)
			path = @paths.fullpath("default_path",template)
			doc = Nokogiri::XML(open(path))
			case ext
				when ".eww"
					@iar_project_files[ext] = doc
				else
					@logger.info "#{ext} not processed"
			end
		end
	end
	#clean the wrkspace in template
 	@iar_project_files[".eww"].css("workspace/project").each do |node|
       	node.remove
   	end
 	@iar_project_files[".eww"].css("workspace/batchBuild/batchDefinition").each do |node|
       	node.remove
   	end  	
end

Instance Method Details

#add_project_to_setObject



365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
# File 'lib/ebngen/adapter/iar.rb', line 365

def add_project_to_set()
	return if @iar_project_files.nil?
	return if @iar_project_files['.eww'].nil?
	ext = ".eww"

	#batch build mode is add
	get_target_list(Project_set::TOOLCHAIN).each do |target|	
		add_batch_project_target(@iar_project_files[ext], "all", @project_name, target)
		add_batch_project_target(@iar_project_files[ext], target, @project_name, target)
		next if get_libraries(Project_set::TOOLCHAIN).nil?
		get_libraries(Project_set::TOOLCHAIN).each do |lib|
			add_batch_project_target(@iar_project_files[ext], "all", lib, target)
			add_batch_project_target(@iar_project_files[ext], target, lib, target)				
		end
	end
	#add projects
	file = "#{@project_name}_#{@board}.ewp"
	path = File.join('$WS_DIR$',file)
	add_project(@iar_project_files[ext], path)
	#add library projects here
	#get from dependency['libraries'][library_name]
	ustruct = @all_projects_hash
	return if get_libraries(Project_set::TOOLCHAIN).nil?
	get_libraries(Project_set::TOOLCHAIN).each do |lib|
		if ustruct[lib].nil?
			@logger.info "#{lib} information is missing in all hash"
			next
		end
		libname = "#{@project_name}.ewp"
           root = @paths.rootdir_table[@ustruct[library][tool_key]['outdir']['root-dir']]
           lib_path = File.join(root, @ustruct[library][tool_key]['outdir']['path'], libname)
           if @ustruct[ project_name ][ tool_key ].has_key?('outdir')
               ewwpath = File.join(@output_rootdir, @ustruct[ project_name ][ tool_key ][ 'outdir' ] )
           else
               ewwpath = @output_rootdir
           end
           path = Pathname.new(lib_path).relative_path_from(Pathname.new(ewwpath))
		#more to come
	end

end

#generatorObject



358
359
360
361
362
# File 'lib/ebngen/adapter/iar.rb', line 358

def generator()
	return if not is_toolchain_support(Project::TOOLCHAIN)
	add_project_to_set()
	save_set()
end

#save_setObject



407
408
409
410
411
412
413
414
415
416
417
# File 'lib/ebngen/adapter/iar.rb', line 407

def save_set()
	path = get_output_dir(Project_set::TOOLCHAIN, @paths.rootdir_table)
	@logger.info  @paths.rootdir_table['output_root']
	@logger.info path
	@logger.info "#{@project_name}_#{@board}.eww"
	if path.class == Hash 
		save(@iar_project_files['.eww'], File.join(@paths.rootdir_table[path['rootdir']], path['path'], "#{@project_name}_#{@board}.eww"))
	else
	  save(@iar_project_files['.eww'], File.join(@paths.rootdir_table['output_root'], path, "#{@project_name}_#{@board}.eww"))
	end
end