Coverage for apio / commands / apio_report.py: 100%

21 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-03-25 02:31 +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""" 

9 

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 

24 

25 

26# ---------- apio report 

27 

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. 

33 

34Examples:[code] 

35 apio report # Print report. 

36 apio report --verbose # Print extra information.[/code] 

37""" 

38 

39 

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 *, 

53 # Options 

54 env: Optional[str], 

55 project_dir: Optional[Path], 

56 verbose: bool, 

57): 

58 """Analyze the design and report timing.""" 

59 

60 # -- Create the apio context. 

61 apio_ctx = ApioContext( 

62 project_policy=ProjectPolicy.PROJECT_REQUIRED, 

63 remote_config_policy=RemoteConfigPolicy.CACHED_OK, 

64 packages_policy=PackagesPolicy.ENSURE_PACKAGES, 

65 project_dir_arg=project_dir, 

66 env_arg=env, 

67 ) 

68 

69 # -- Create the scons manager. 

70 scons = SConsManager(apio_ctx) 

71 

72 # -- Create the verbosity params. 

73 verbosity = Verbosity(pnr=verbose) 

74 

75 # Run scons 

76 exit_code = scons.report(verbosity) 

77 

78 # -- Done! 

79 sys.exit(exit_code)