def handle_modules(self): # get all enabled west projects west_proj = west_projects() modules_meta = parse_modules(ZEPHYR_BASE, [p.posixpath for p in west_proj['projects']] if west_proj else None, None) self.modules = [module.meta.get('name') for module in modules_meta]
def kconfig_load(app: Sphinx) -> Tuple[kconfiglib.Kconfig, Dict[str, str]]: """Load Kconfig""" with TemporaryDirectory() as td: projects = zephyr_module.west_projects() projects = [p.posixpath for p in projects["projects"]] if projects else None modules = zephyr_module.parse_modules(ZEPHYR_BASE, projects) # generate Kconfig.modules file kconfig = "" for module in modules: kconfig += zephyr_module.process_kconfig(module.project, module.meta) with open(Path(td) / "Kconfig.modules", "w") as f: f.write(kconfig) # generate dummy Kconfig.dts file kconfig = "" with open(Path(td) / "Kconfig.dts", "w") as f: f.write(kconfig) # base environment os.environ["ZEPHYR_BASE"] = str(ZEPHYR_BASE) os.environ["srctree"] = str(ZEPHYR_BASE) os.environ["KCONFIG_DOC_MODE"] = "1" os.environ["KCONFIG_BINARY_DIR"] = td # include all archs and boards os.environ["ARCH_DIR"] = "arch" os.environ["ARCH"] = "*" os.environ["BOARD_DIR"] = "boards/*/*" # insert external Kconfigs to the environment module_paths = dict() for module in modules: name = module.meta["name"] name_var = module.meta["name-sanitized"].upper() module_paths[name] = module.project build_conf = module.meta.get("build") if not build_conf: continue if build_conf.get("kconfig"): kconfig = Path(module.project) / build_conf["kconfig"] os.environ[f"ZEPHYR_{name_var}_KCONFIG"] = str(kconfig) elif build_conf.get("kconfig-ext"): for path in app.config.kconfig_ext_paths: kconfig = Path(path) / "modules" / name / "Kconfig" if kconfig.exists(): os.environ[f"ZEPHYR_{name_var}_KCONFIG"] = str(kconfig) return kconfiglib.Kconfig(ZEPHYR_BASE / "Kconfig"), module_paths
def do_run(self, args, _): if args.name_re is not None: name_re = re.compile(args.name_re) else: name_re = None modules_board_roots = [] for module in zephyr_module.parse_modules(ZEPHYR_BASE): board_root = module.meta.get('build', {}).get('settings', {}).get('board_root') if board_root is not None: modules_board_roots.append(Path(module.project) / board_root) args.board_roots += modules_board_roots for board in list_boards.find_boards(args): if name_re is not None and not name_re.search(board.name): continue log.inf( args.format.format(name=board.name, arch=board.arch, dir=board.dir))