Coverage for apio/commands/apio_report.py: 100%
21 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-06 10:20 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-06 10:20 +0000
1# -*- coding: utf-8 -*-
2# -- This file is part of the Apio project
3# -- (C) 2016-2024 FPGAwars
4# -- Authors
5# -- * Jesús Arroyo (2016-2019)
6# -- * Juan Gonzalez (obijuan) (2019-2024)
7# -- License GPLv2
8"""Implementation of 'apio' report' command"""
10import sys
11from typing import Optional
12from pathlib import Path
13import click
14from apio.managers.scons_manager import SConsManager
15from apio.commands import options
16from apio.apio_context import (
17 ApioContext,
18 PackagesPolicy,
19 ProjectPolicy,
20 RemoteConfigPolicy,
21)
22from apio.common.proto.apio_pb2 import Verbosity
23from apio.utils import cmd_util
26# ---------- apio report
28# -- Text in the rich-text format of the python rich library.
29APIO_REPORT_HELP = """
30The command 'apio report' provides information on the utilization and timing \
31of the design. It is useful for analyzing utilization bottlenecks and \
32verifying that the design can operate at the desired clock speed.
34Examples:[code]
35 apio report # Print report.
36 apio report --verbose # Print extra information.[/code]
37"""
40@click.command(
41 name="report",
42 cls=cmd_util.ApioCommand,
43 short_help="Report design utilization and timing.",
44 help=APIO_REPORT_HELP,
45)
46@click.pass_context
47@options.env_option_gen()
48@options.project_dir_option
49@options.verbose_option
50def cli(
51 _: click.Context,
52 # Options
53 env: Optional[str],
54 project_dir: Optional[Path],
55 verbose: bool,
56):
57 """Analyze the design and report timing."""
59 # -- Create the apio context.
60 apio_ctx = ApioContext(
61 project_policy=ProjectPolicy.PROJECT_REQUIRED,
62 remote_config_policy=RemoteConfigPolicy.CACHED_OK,
63 packages_policy=PackagesPolicy.ENSURE_PACKAGES,
64 project_dir_arg=project_dir,
65 env_arg=env,
66 )
68 # -- Create the scons manager.
69 scons = SConsManager(apio_ctx)
71 # -- Create the verbosity params.
72 verbosity = Verbosity(pnr=verbose)
74 # Run scons
75 exit_code = scons.report(verbosity)
77 # -- Done!
78 sys.exit(exit_code)