@@ -199,9 +199,9 @@ def verilog_src_scanner_func(
199199
200200 # Sanity check. Should be called only to scan verilog files. If
201201 # this fails, this is a programming error rather than a user error.
202- assert is_source_file (
203- file_node .name
204- ), f"Not a src file: { file_node . name } "
202+ if not is_source_file (file_node . name ):
203+ cerror ( f"' { file_node .name } ' is not a source file." )
204+ sys . exit ( 1 )
205205
206206 # Get the directory of the file, relative to the project root which is
207207 # the current working directory. This value is equals to "." if the
@@ -301,30 +301,42 @@ def verilator_lint_action(
301301 params = apio_env .params
302302 lint_params = params .target .lint
303303
304- # -- Determine top module.
305- top_module = (
306- lint_params .top_module
307- if lint_params .top_module
308- else params .apio_env_params .top_module
309- )
304+ # -- Determine if linting the entire project or just a few files,
305+ lint_whole_project = not lint_params .file_names
306+
307+ # -- Determine if using a vlt file. We use it only when linting a whole
308+ # -- project and --novlt was not specified.
309+ using_vlt = lint_whole_project and (not lint_params .novlt )
310+
311+ # -- Determine the top module.
312+ if lint_params .top_module :
313+ # -- Case 1: Top module was specified in the command line.
314+ top_module = lint_params .top_module
315+ elif lint_whole_project :
316+ # -- Case 2: Linting the entire project, use top module from apio.ini,
317+ top_module = params .apio_env_params .top_module
318+ else :
319+ # -- Linting only a few files and top module was not specified.
320+ top_module = None
310321
311322 # -- Construct the action
312323 action = (
313324 "verilator_bin --lint-only --quiet --bbox-unsup --timing "
314- "-Wno-TIMESCALEMOD -Wno-MULTITOP {0} -DAPIO_SIM=0 "
315- "{1} { 2} {3} {4} {5} {6} {7} {8} {9} {10} $SOURCES"
325+ "-Wno-TIMESCALEMOD -Wno-MULTITOP {0} {1} -DAPIO_SIM=0 "
326+ "{2} {3} {4} {5} {6} {7} {8} {9} {10} {11 } $SOURCES"
316327 ).format (
317328 "" if lint_params .nosynth else "-DSYNTHESIZE" ,
329+ "" if lint_whole_project else "-Wno-MODMISSING" ,
318330 "-Wall" if lint_params .verilator_all else "" ,
319331 "-Wno-style" if lint_params .verilator_no_style else "" ,
320332 map_params (lint_params .verilator_no_warns , "-Wno-{}" ),
321333 map_params (lint_params .verilator_warns , "-Wwarn-{}" ),
322- f"--top-module { top_module } " ,
334+ f"--top-module { top_module } " if top_module else "" ,
323335 get_define_flags (apio_env ),
324336 map_params (extra_params , "{}" ),
325- map_params (lib_dirs , '-I"{}"' ),
326- "" if lint_params . novlt else apio_env .target + ".vlt" ,
327- map_params (lib_files , '"{}"' ),
337+ map_params (lib_dirs , '-I"{}"' ) if lint_whole_project else "" ,
338+ apio_env .target + ".vlt" if using_vlt else " " ,
339+ map_params (lib_files , '"{}"' ) if lint_whole_project else "" ,
328340 )
329341
330342 return [source_files_issue_scanner_action (), action ]
0 commit comments