Map the Config.in file that defines a symbol to a Buildroot package name. The robust mapping is: take the parent directory of the Config.in file and use its basename. Works for both Buildroot core packages (package/ / Config.in) and OpenIPC external packages (general/package/<
(filename: str | None, *, repo_root: str)
| 57 | |
| 58 | |
| 59 | def package_of(filename: str | None, *, repo_root: str) -> str | None: |
| 60 | """ |
| 61 | Map the Config.in file that defines a symbol to a Buildroot package name. |
| 62 | |
| 63 | The robust mapping is: take the parent directory of the Config.in file and |
| 64 | use its basename. Works for both Buildroot core packages (package/<name>/ |
| 65 | Config.in) and OpenIPC external packages (general/package/<name>/Config.in |
| 66 | or general/package/legacy/<name>/Config.in). |
| 67 | |
| 68 | Returns None when the symbol is defined outside a package/ tree (toolchain, |
| 69 | fs, system, …). |
| 70 | """ |
| 71 | if not filename: |
| 72 | return None |
| 73 | parts = Path(filename).parts |
| 74 | # We look for the last "package" segment and take the next path element. |
| 75 | for i, p in enumerate(parts): |
| 76 | if p == "package" and i + 1 < len(parts): |
| 77 | return parts[i + 1] |
| 78 | return None |
| 79 | |
| 80 | |
| 81 | def setup_kconfig_env(br2_output_dir: str, br_ver: str, repo_root: str) -> str: |