fix: scope --target the same way in every tool

slots and cross_reference go through model.targets.target_scope, so a
mistyped target ends with ERROR and exit 1 as in verify, where they
exited 2. The platforms --all skips are noted on stderr, which kept
slots --json from printing them ahead of its document. slots reads the
mode through platform_mode and builds the ZIP index and data-directory
registry once per run instead of twice per platform.
This commit is contained in:
Abdessamad Derraz committed 2026-11-21 06:04:31 +01:00
1 parent 3467b80b38
commit ee66aa4e66
4 files changed
+50 -34

No files matched your search

+8 -15
View File
@@ -206,22 +206,15 @@ class _PlatformScope:
run_anywhere: set[str]
def _platform_scope(
args: argparse.Namespace, parser: argparse.ArgumentParser, profiles: dict[str, dict],
) -> _PlatformScope:
from model.targets import load_target_config
def _platform_scope(args: argparse.Namespace, profiles: dict[str, dict]) -> _PlatformScope:
from model.targets import target_scope
from resolve.cores import resolve_platform_cores
try:
target_cores = (
load_target_config(args.platform, args.target, args.platforms_dir)
if args.target
else None
)
except (FileNotFoundError, ValueError) as exc:
# A typo ended in a traceback where verify and slots name the
# closest target.
parser.error(str(exc))
# A typo ended in a traceback where verify and slots name the closest
# target, and is refused the way they refuse it.
target_cores = target_scope(
[args.platform], args.target, args.platforms_dir
)[0].get(args.platform)
config = load_platform_config(args.platform, args.platforms_dir)
relevant = resolve_platform_cores(config, profiles, target_cores=target_cores)
run_anywhere = (
@@ -321,7 +314,7 @@ def main() -> None:
platform_scope: _PlatformScope | None = None
standalone_cores: set[str] = set()
if args.platform:
platform_scope = _platform_scope(args, parser, profiles)
platform_scope = _platform_scope(args, profiles)
profiles = platform_scope.profiles
standalone_cores = platform_scope.standalone_cores
else: