Ejemplo n.º 1
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)
 def _create_host(self, module):
     template_str = \
         hdf_utils.get_template('hdf_driver_manager_config_host.template')
     mod_converter = hdf_utils.WordsConverter(module)
     data_model = {'module_lower_case': mod_converter.lower_case()}
     host_content = Template(template_str).safe_substitute(data_model)
     begin, end = self._begin_end(module, module)
     return hdf_utils.SectionContent(begin, host_content, end)
 def get_args(self):
     args = ['vendor_name', 'module_name', 'driver_name', 'board_name']
     ret = [self._get_arg('root_dir')]
     for arg in args:
         value = self._get_arg(arg)
         if value:
             value = hdf_utils.WordsConverter(value).lower_case()
         ret.append(value)
     return tuple(ret)
 def _create_driver_item(self, driver):
     drv_converter = hdf_utils.WordsConverter(driver)
     data_model = {
         'driver_upper_case': drv_converter.upper_case(),
         'driver_lower_case': drv_converter.lower_case()
     }
     template_str = hdf_utils.get_template('hdf_module_mk_driver.template')
     content = Template(template_str).safe_substitute(data_model)
     begin_flag, end_flag = self._begin_end(driver)
     return hdf_utils.SectionContent(begin_flag, content, end_flag)
 def _create_device(self, module, driver):
     drv_converter = hdf_utils.WordsConverter(driver)
     data_model = {
         'driver_lower_case': drv_converter.lower_case(),
         'driver_lower_camel_case': drv_converter.lower_camel_case()
     }
     template_str = \
         hdf_utils.get_template('hdf_driver_manager_config_device.template')
     contents = Template(template_str).safe_substitute(data_model)
     begin, end = self._begin_end(module, driver)
     return hdf_utils.SectionContent(begin, contents, end)
 def _get_driver_kconfig_item(self, driver):
     templates_dir = hdf_utils.get_templates_lite_dir()
     template = os.path.join(templates_dir, 'hdf_driver_kconfig.template')
     template_str = hdf_utils.read_file(template)
     mod_converter = hdf_utils.WordsConverter(self.module)
     drv_converter = hdf_utils.WordsConverter(driver)
     data_model = {
         'driver_upper_case': drv_converter.upper_case(),
         'driver_lower_case': drv_converter.lower_case(),
         'module_upper_case': mod_converter.upper_case()
     }
     config_item = 'DRIVERS_HDF_%s' % drv_converter.upper_case()
     depends_on_item = 'DRIVERS_HDF_%s' % mod_converter.upper_case()
     config_option = {
         'name': drv_converter.lower_case(),
         'config_item': config_item,
         'depends_on_item': depends_on_item,
         'enabled': False
     }
     config = Template(template_str).safe_substitute(data_model)
     return config_option, config
Ejemplo n.º 7
0
 def _add_driver_handler(self):
     self.check_arg_raise_if_not_exist("vendor_name")
     self.check_arg_raise_if_not_exist("module_name")
     self.check_arg_raise_if_not_exist("driver_name")
     self.check_arg_raise_if_not_exist("board_name")
     root, vendor, module, driver, board = self.get_args()
     drv_converter = hdf_utils.WordsConverter(self.args.driver_name)
     drv_config = HdfDriverConfigFile(root, board, module, driver)
     module_k = \
         hdf_utils.get_module_kconfig_path(root, vendor, module)
     if not os.path.exists(module_k):
         raise HdfToolException('module "%s Kconfig" not exist' % module,
                                CommandErrorCode.TARGET_NOT_EXIST)
     module_mk = \
         hdf_utils.get_module_mk_path(root, vendor, module)
     if not os.path.exists(module_mk):
         raise HdfToolException('module "%s Makefile" not exist' % module,
                                CommandErrorCode.TARGET_NOT_EXIST)
     drv_src_dir = hdf_utils.get_drv_src_dir(root, vendor, module, driver)
     if os.path.exists(drv_src_dir):
         raise HdfToolException('driver "%s" already exist' % driver,
                                CommandErrorCode.TARGET_ALREADY_EXIST)
     os.makedirs(drv_src_dir)
     drv_include_dir = \
         hdf_utils.get_drv_include_dir(root, vendor, module, driver)
     if not os.path.exists(drv_include_dir):
         os.makedirs(drv_include_dir)
     data_model = {
         'driver_lower_case': drv_converter.lower_case(),
         'driver_upper_camel_case': drv_converter.upper_camel_case(),
         'driver_lower_camel_case': drv_converter.lower_camel_case(),
         'driver_upper_case': drv_converter.upper_case()
     }
     self._file_gen_lite('hdf_driver.c.template', drv_src_dir,
                         '%s_driver.c' % driver, data_model)
     self._file_gen_lite('hdf_driver.h.template', drv_include_dir,
                         '%s_driver.h' % driver, data_model)
     k_path = hdf_utils.get_module_kconfig_path(root, vendor, module)
     module_config = HdfModuleKconfigFile(root, module, k_path)
     config = module_config.add_driver(driver)
     module_mk = HdfModuleMkFile(root, vendor, module)
     module_mk.add_driver(driver)
     drv_config.create_driver()
     return json.dumps(config)
Ejemplo n.º 8
0
 def _add_module_handler(self):
     self.check_arg_raise_if_not_exist("vendor_name")
     self.check_arg_raise_if_not_exist("module_name")
     root, vendor, module, _, _ = self.get_args()
     converter = hdf_utils.WordsConverter(self.args.module_name)
     hdf = hdf_utils.get_vendor_hdf_dir(root, vendor)
     if not os.path.exists(hdf):
         raise HdfToolException('vendor "%s" not exist' % vendor,
                                CommandErrorCode.TARGET_NOT_EXIST)
     drv_root_dir = hdf_utils.get_drv_root_dir(root, vendor, module)
     if os.path.exists(drv_root_dir):
         raise HdfToolException('module "%s" already exist' % module,
                                CommandErrorCode.TARGET_ALREADY_EXIST)
     os.makedirs(drv_root_dir)
     hdi_dir = os.path.join(hdf, module, 'hdi')
     if not os.path.exists(hdi_dir):
         os.makedirs(hdi_dir)
     data_model = {
         "module_upper_case": converter.upper_case(),
         "module_lower_case": converter.lower_case()
     }
     self._file_gen_lite('hdf_module_kconfig.template', drv_root_dir,
                         'Kconfig', data_model)
     self._file_gen_lite('hdf_module_mk.template', drv_root_dir, 'Makefile',
                         data_model)
     vendor_k = HdfVendorKconfigFile(root, vendor)
     vendor_k.add_module([module, 'driver', 'Kconfig'])
     vendor_mk = HdfVendorMkFile(root, vendor)
     vendor_mk.add_module(module)
     config_item = {
         'name': module,
         'config_item': 'DRIVERS_HDF_%s' % converter.upper_case(),
         'depends_on_item': 'DRIVERS_HDF',
         'enabled': False
     }
     return json.dumps(config_item)