Ejemplo n.º 1
0
 def set_vendor(self, current_vendor):
     other_vendors = self._find_all_vendors(current_vendor)
     self._comment_other_vendors(other_vendors)
     drivers_path = HdfToolSettings().get_drivers_path()
     new_line = \
         'include $(LITEOSTOPDIR)/../../vendor/%s/%s/hdf_vendor.mk\n' % \
         (current_vendor, drivers_path)
     if self.target_line_index != -1:
         self.lines[self.target_line_index] = new_line
     elif self.end_line_index != -1:
         self.lines.insert(self.end_line_index, new_line)
     else:
         self.lines.append(new_line)
     self._save()
Ejemplo n.º 2
0
 def _create_module(self, module, need_content=True):
     begin, end = self._begin_end(module)
     if not need_content:
         return hdf_utils.SectionContent(begin, '', end)
     vendor_converter = hdf_utils.WordsConverter(self.vendor)
     module_converter = hdf_utils.WordsConverter(module)
     data_model = {
         'module_upper_case': module_converter.upper_case(),
         'module_lower_case': module_converter.lower_case(),
         'vendor_lower_case': vendor_converter.lower_case(),
         'drivers_path': HdfToolSettings().get_drivers_path()
     }
     template_str = hdf_utils.get_template('hdf_vendor_mk_module.template')
     module_item = Template(template_str).safe_substitute(data_model)
     return hdf_utils.SectionContent(begin, module_item, end)
Ejemplo n.º 3
0
 def set_vendor(self, current_vendor):
     other_vendors = self._find_all_vendors(current_vendor)
     self._comment_other_vendors(other_vendors)
     drivers_path = HdfToolSettings().get_drivers_path()
     new_line = 'source "../../vendor/%s/%s/Kconfig"\n' % \
                (current_vendor, drivers_path)
     if self.target_index != -1:
         self.lines[self.target_index] = new_line
     else:
         pos = len(self.lines) - 1
         while pos > 0 and len(self.lines[pos].strip()) == 0:
             pos -= 1
         pos += 1
         self.lines.insert(pos, new_line)
     self._save()
 def __init__(self, root_dir, vendor_name):
     self.root = root_dir
     self.vendor = vendor_name
     self.kconfig_path = \
         hdf_utils.get_vendor_kconfig_path(root_dir, vendor_name)
     if os.path.exists(self.kconfig_path):
         self.lines = hdf_utils.read_file_lines(self.kconfig_path)
     else:
         self.lines = []
     drivers_path = HdfToolSettings().get_drivers_path()
     line_pattern = \
         r'^\s*source\s+"../../(vendor/%s/%s/([a-zA-Z0-9_\-]+)/.*)"' % \
         (vendor_name, drivers_path)
     self.line_re = re.compile(line_pattern)
     self.line_prefix = 'source "../../vendor/%s/%s' % \
                        (vendor_name, drivers_path)
Ejemplo n.º 5
0
 def _add_vendor_handler(self):
     self.check_arg_raise_if_not_exist("vendor_name")
     root, vendor, _, _, board = self.get_args()
     target_dir = hdf_utils.get_vendor_hdf_dir(root, vendor)
     if os.path.exists(target_dir):
         raise HdfToolException("%s already exists" % target_dir,
                                CommandErrorCode.TARGET_ALREADY_EXIST)
     os.makedirs(target_dir)
     self._file_gen_lite('hdf_vendor_kconfig.template', target_dir,
                         'Kconfig', {})
     board_parent_path = HdfToolSettings().get_board_parent_path(board)
     if not board_parent_path:
         board_parent_path = 'vendor/hisi/hi35xx'
     data_model = {"board_parent_path": board_parent_path}
     self._file_gen_lite('hdf_vendor_mk.template', target_dir,
                         'hdf_vendor.mk', data_model)
 def __init__(self, root, board, module, driver, only_path=False):
     self.root = root
     self.board = board
     self.module = module
     self.driver = driver
     bpp = HdfToolSettings().get_board_parent_path(self.board)
     board_path = os.path.join(self.root, bpp, self.board)
     if not os.path.exists(board_path):
         raise HdfToolException('board: %s not exist' % board_path,
                                CommandErrorCode.TARGET_NOT_EXIST)
     self.config_dir = os.path.join(board_path, 'config')
     self.drv_dir = os.path.join(self.config_dir, self.module)
     self.drv_config_path = os.path.join(self.drv_dir,
                                         '%s_config.hcs' % self.driver)
     if only_path:
         return
     manager_hcs_path = os.path.join(self.config_dir, 'device_info',
                                     'device_info.hcs')
     self.manager_hcs = HdfManagerConfigFile(manager_hcs_path)
     hdf_hcs_path = os.path.join(self.config_dir, 'hdf.hcs')
     self.hdf_hcs = HdfHcsFile(hdf_hcs_path)
Ejemplo n.º 7
0
    def _set_drivers_state_handler(self):
        self.check_arg_raise_if_not_exist("all_drivers")
        self.check_arg_raise_if_not_exist("board_name")
        drivers = json.loads(self.args.all_drivers)
        board_name = self.args.board_name.lower()
        root = self.args.root_dir
        dot_config_path = hdf_utils.get_liteos_a_dot_config_path(root)
        dot_config = HdfDotConfigFile(dot_config_path)
        orig_dot_configs = HdfToolSettings().get_dot_configs(board_name)
        orig_dot_configs = \
            [os.path.join(root, config) for config in orig_dot_configs]
        orig_dot_configs = \
            [HdfDotConfigFile(config) for config in orig_dot_configs]

        def config_set(config):
            if not config:
                return
            enabled = config.get('enabled', False)
            config_item = config.get('config_item', '')
            depends_on_item = config.get('depends_on_item', '')
            if enabled:
                dot_config.enable(config_item, depends_on_item)
                for orig_dot_config in orig_dot_configs:
                    orig_dot_config.enable(config_item, depends_on_item)
            else:
                dot_config.disable(config_item)
                for orig_dot_config in orig_dot_configs:
                    orig_dot_config.disable(config_item)

        for module, module_state in drivers.items():
            config_set(module_state.get('self', ''))
            for drv_config in module_state.get('children', []):
                config_set(drv_config)
        dot_config.save()
        for orig_dot_config_ in orig_dot_configs:
            orig_dot_config_.save()
Ejemplo n.º 8
0
def get_vendor_hdf_dir(root, vendor):
    relative_path = HdfToolSettings().get_drivers_path()
    return os.path.join(get_vendor_dir(root, vendor), relative_path)
 def _get_board_list_handler():
     settings = HdfToolSettings()
     return settings.get_supported_boards()