Skip to content

Commit

Permalink
apio lint refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Obijuan committed Mar 17, 2024
1 parent fd9495d commit 7ebc9fe
Showing 1 changed file with 41 additions and 17 deletions.
58 changes: 41 additions & 17 deletions apio/commands/lint.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,48 @@
# -*- coding: utf-8 -*-
# -- This file is part of the Apio project
# -- (C) 2016-2019 FPGAwars
# -- Authors Jesús Arroyo, Miodrag Milanovic
# -- (C) 2016-2024 FPGAwars
# -- Authors
# -- * Jesús Arroyo (2016-2019)
# -- * Juan Gonzalez (obijuan) (2019-2024)
# -- Licence GPLv2
"""TODO"""
"""Main implementation of APIO LINT command"""

import click

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

# ------------------
# -- CONSTANTS
# ------------------
CMD = "lint" # -- Comand name
ALL = "all" # -- Option
TOP_MODULE = "top_module" # -- Option
NOSTYLE = "nostyle" # -- Option
NOWARN = "nowarn" # -- Option
WARN = "warn" # -- Option
PROJECT_DIR = "project_dir" # -- Option


# R0913: Too many arguments (6/5)
# pylint: disable=R0913
# pylint: disable=W0622
@click.command("lint", context_settings=util.context_settings())
@click.command(CMD, context_settings=util.context_settings())
@click.pass_context
@click.option(
"-a",
"--all",
f"--{ALL}",
is_flag=True,
help="Enable all warnings, including code style warnings.",
)
@click.option("-t", "--top", type=str, metavar="top", help="Set top module.")
@click.option("--nostyle", is_flag=True, help="Disable all style warnings.")
@click.option(
"--nowarn",
"-t", "--top-module", type=str, metavar="str", help="Set top module."
)
@click.option(f"--{NOSTYLE}", is_flag=True, help="Disable all style warnings.")
@click.option(
f"--{NOWARN}",
type=str,
metavar="nowarn",
help="Disable specific warning(s).",
)
@click.option(
"--warn", type=str, metavar="warn", help="Enable specific warning(s)."
f"--{WARN}", type=str, metavar="warn", help="Enable specific warning(s)."
)
@click.option(
"-p",
Expand All @@ -40,13 +51,26 @@
metavar="path",
help="Set the target directory for the project.",
)
def cli(ctx, all, top, nostyle, nowarn, warn, project_dir):
def cli(ctx, **kwargs):
# def cli(ctx, all, top, nostyle, nowarn, warn, project_dir):
"""Lint the verilog code."""

exit_code = SCons(project_dir).lint(
# -- Extract the arguments
project_dir = kwargs[PROJECT_DIR]
_all = kwargs[ALL]
top_module = kwargs[TOP_MODULE]
nostyle = kwargs[NOSTYLE]
nowarn = kwargs[NOWARN]
warn = kwargs[WARN]

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

# -- Lint the project with the given parameters
exit_code = scons.lint(
{
"all": all,
"top": top,
"all": _all,
"top": top_module,
"nostyle": nostyle,
"nowarn": nowarn,
"warn": warn,
Expand Down

0 comments on commit 7ebc9fe

Please sign in to comment.