Skip to content

Commit

Permalink
apio time refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Obijuan committed Mar 17, 2024
1 parent 8e3e793 commit 176f44d
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 28 deletions.
2 changes: 2 additions & 0 deletions apio/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from apio.managers.scons import SCons
from apio import util

# R0801: Similar lines in 2 files
# pylint: disable=R0801
# ------------------
# -- CONSTANTS
# ------------------
Expand Down
76 changes: 48 additions & 28 deletions apio/commands/time.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,48 @@
# -*- coding: utf-8 -*-
# -- This file is part of the Apio project
# -- (C) 2016-2019 FPGAwars
# -- Author Jesús Arroyo
# -- (C) 2016-2024 FPGAwars
# -- Authors
# -- * Jesús Arroyo (2016-2019)
# -- * Juan Gonzalez (obijuan) (2019-2024)
# -- Licence GPLv2
"""TODO"""
"""Main implementation of APIO time command"""

import click

from apio.managers.scons import SCons
from apio import util

# ------------------
# -- CONSTANTS
# ------------------
CMD = "time" # -- Comand name
BOARD = "board" # -- Option
FPGA = "fpga" # -- Option
SIZE = "size" # -- Option
PACK = "pack" # -- Option
TYPE = "type" # -- Option
PROJECT_DIR = "project_dir" # -- Option
VERBOSE = "verbose" # -- Option
VERBOSE_YOSYS = "verbose_yosys" # -- Option
VERBOSE_PNR = "verbose_pnr" # -- Option
TOP_MODULE = "top_module" # -- Option


# R0913: Too many arguments (6/5)
# pylint: disable=R0913
# pylint: disable=W0622
@click.command("time", context_settings=util.context_settings())
# R0801: Similar lines in 2 files
# pylint: disable=R0801
@click.command(CMD, context_settings=util.context_settings())
@click.pass_context
@click.option(
"-b", "--board", type=str, metavar="board", help="Set the board."
"-b", f"--{BOARD}", type=str, metavar="str", help="Set the board."
)
@click.option("--fpga", type=str, metavar="fpga", help="Set the FPGA.")
@click.option(f"--{FPGA}", type=str, metavar="str", help="Set the FPGA.")
@click.option(
"--size", type=str, metavar="size", help="Set the FPGA type (1k/8k)."
f"--{SIZE}", type=str, metavar="str", help="Set the FPGA type (1k/8k)."
)
@click.option(
"--type", type=str, metavar="type", help="Set the FPGA type (hx/lp)."
f"--{TYPE}", type=str, metavar="str", help="Set the FPGA type (hx/lp)."
)
@click.option(
"--pack", type=str, metavar="package", help="Set the FPGA package."
f"--{PACK}", type=str, metavar="str", help="Set the FPGA package."
)
@click.option(
"-p",
Expand All @@ -38,7 +53,7 @@
)
@click.option(
"-v",
"--verbose",
f"--{VERBOSE}",
is_flag=True,
help="Show the entire output of the command.",
)
Expand All @@ -50,27 +65,30 @@
@click.option(
"--verbose-pnr", is_flag=True, help="Show the pnr output of the command."
)
def cli(
ctx,
board,
fpga,
pack,
type,
size,
project_dir,
verbose,
verbose_yosys,
verbose_pnr,
):
def cli(ctx, **kwargs):
"""Bitstream timing analysis."""

# -- Extract the arguments
project_dir = kwargs[PROJECT_DIR]
board = kwargs[BOARD]
fpga = kwargs[FPGA]
pack = kwargs[PACK]
_type = kwargs[TYPE]
size = kwargs[SIZE]
verbose = kwargs[VERBOSE]
verbose_yosys = kwargs[VERBOSE_YOSYS]
verbose_pnr = kwargs[VERBOSE_PNR]

# -- Create the scons object
scons = SCons(project_dir)

# Run scons
exit_code = SCons(project_dir).time(
exit_code = scons.time(
{
"board": board,
"fpga": fpga,
"size": size,
"type": type,
"type": _type,
"pack": pack,
"verbose": {
"all": verbose,
Expand All @@ -79,4 +97,6 @@ def cli(
},
}
)

# -- Done!
ctx.exit(exit_code)
2 changes: 2 additions & 0 deletions apio/managers/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

# R0902: Too many instance attributes (12/7) (too-many-instance-attributes)
# pylint: disable=R0902
# R0801: Similar lines in 2 files
# pylint: disable=R0801
class Installer:
"""Installer. Class with methods for installing and managing
apio packages"""
Expand Down

0 comments on commit 176f44d

Please sign in to comment.