def test_normalize_path_from_list(self): paths = ['C:\\ezored\\Test1', 'C:\\ezored\\Test2'] normalized = FileUtil.normalize_path_from_list(paths) expected1 = 'C:/ezored/Test1' expected2 = 'C:/ezored/Test2' self.assertEqual(normalized[0], expected1) self.assertEqual(normalized[1], expected2)
def parse(self, process_data): if process_data: Logger.d('Parsing target data...') self.project_name = process_data.parse_text(self.project_name) self.header_search_paths = process_data.parse_text_list(self.header_search_paths) self.header_search_paths = FileUtil.normalize_path_from_list(self.header_search_paths) self.library_search_paths = process_data.parse_text_list(self.library_search_paths) self.library_search_paths = FileUtil.normalize_path_from_list(self.library_search_paths) self.source_groups = process_data.parse_sourge_group_list(self.source_groups) self.library_links = process_data.parse_text_list(self.library_links) self.framework_links = process_data.parse_text_list(self.framework_links) self.c_flags = process_data.parse_text_list(self.c_flags) self.cxx_flags = process_data.parse_text_list(self.cxx_flags) self.compiler_options = process_data.parse_text_list(self.compiler_options) self.tasks = process_data.parse_task_list(self.tasks) else: Logger.d('Cannot parse target data with invalid source')
def get_target_data_by_target_name_and_parse(self, target_name, process_data): Logger.d('Getting target data from dependency: {0}...'.format( self.get_name())) target_file_data = self.repository.load_target_data_file() if target_file_data: if 'targets' in target_file_data: targets_data = target_file_data['targets'] for target_data_item in targets_data: current_target_name = target_data_item['name'] if self.match_name(pattern=current_target_name, name=target_name): # get target data target_data = TargetData() if 'data' in target_data_item: target_data_dict = target_data_item['data'] if 'header_search_paths' in target_data_dict: if target_data_dict['header_search_paths']: target_data.header_search_paths.extend( FileUtil.normalize_path_from_list( target_data_dict[ 'header_search_paths'])) if 'library_search_paths' in target_data_dict: if target_data_dict['library_search_paths']: target_data.library_search_paths.extend( FileUtil.normalize_path_from_list( target_data_dict[ 'library_search_paths'])) if 'c_flags' in target_data_dict: if target_data_dict['c_flags']: target_data.c_flags.extend( target_data_dict['c_flags']) if 'cxx_flags' in target_data_dict: if target_data_dict['cxx_flags']: target_data.cxx_flags.extend( target_data_dict['cxx_flags']) if 'library_links' in target_data_dict: if target_data_dict['library_links']: target_data.library_links.extend( target_data_dict['library_links']) if 'framework_links' in target_data_dict: if target_data_dict['framework_links']: target_data.framework_links.extend( target_data_dict['framework_links']) if 'tasks' in target_data_dict: if target_data_dict['tasks']: for target_data_task in target_data_dict[ 'tasks']: task = Task.from_dict(target_data_task) target_data.tasks.append(task) # create source group if have files for it target_data_header_files = [] target_data_source_files = [] if 'header_files' in target_data_dict: if target_data_dict['header_files']: for file_data in target_data_dict[ 'header_files']: # find all files source_file_to_find = SourceFile.from_dict( file_data) if source_file_to_find: # process file pattern before file_pattern = source_file_to_find.file file_pattern = process_data.parse_text( file_pattern) found_files = FileUtil.find_files( file_pattern) found_files = FileUtil.normalize_path_from_list( found_files) # create new source file for each found file for f in found_files: target_data_header_files.append( SourceFile( source_file=f, compile_flags= source_file_to_find. compile_flags)) if 'source_files' in target_data_dict: if target_data_dict['source_files']: for file_data in target_data_dict[ 'source_files']: # find all files source_file_to_find = SourceFile.from_dict( file_data) if source_file_to_find: # process file pattern before file_pattern = source_file_to_find.file file_pattern = process_data.parse_text( file_pattern) found_files = FileUtil.find_files( file_pattern) found_files = FileUtil.normalize_path_from_list( found_files) # create new source file for each found file for f in found_files: target_data_source_files.append( SourceFile( source_file=FileUtil. normalize_path(f), compile_flags= source_file_to_find. compile_flags)) if len(target_data_header_files) > 0 or len( target_data_source_files) > 0: target_data_source_group = SourceGroup() target_data_source_group.name = self.get_name() target_data_source_group.header_files = target_data_header_files target_data_source_group.source_files = target_data_source_files target_data.source_groups.append( target_data_source_group) # parse all things target_data.parse(process_data) return target_data