Skip to content

Commit b31d7d3

Browse files
authored
Merge pull request #847 from zapta/main
Apio lint can now lint only specified files.
2 parents 441b79b + 41c40d1 commit b31d7d3

File tree

12 files changed

+105
-44
lines changed

12 files changed

+105
-44
lines changed

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"cwarning",
6969
"cwidth",
7070
"cwrite",
71+
"DAPIO",
7172
"dblite",
7273
"debugpy",
7374
"Deconflicting",
@@ -78,6 +79,7 @@
7879
"distpath",
7980
"dpkg",
8081
"drprasad",
82+
"DSYNTHESIZE",
8183
"dumpfile",
8284
"elif",
8385
"EMPH",
@@ -137,11 +139,14 @@
137139
"mengbo",
138140
"mkdirs",
139141
"mkdocs",
142+
"MODMISSING",
140143
"modpath",
141144
"msys",
145+
"MULTITOP",
142146
"nextpnr",
143147
"nofailsafe",
144148
"nostyle",
149+
"novlt",
145150
"nowarn",
146151
"obijuan",
147152
"olddata",
@@ -195,10 +200,12 @@
195200
"testbenches",
196201
"testpypi",
197202
"timedates",
203+
"TIMESCALEMOD",
198204
"tinyprog",
199205
"truecolor",
200206
"udevadm",
201207
"unstyling",
208+
"unsup",
202209
"USBFTDI",
203210
"userimage",
204211
"usermod",
@@ -210,6 +217,7 @@
210217
"verilog",
211218
"wireshape",
212219
"workpath",
220+
"Wwarn",
213221
"yosys",
214222
"Zadig"
215223
]

COMMANDS.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ Usage: apio api echo [OPTIONS]
106106
consistent with that Apio theme that is currently selected in the user
107107
preferences.
108108

109-
The required '--style' option should have one of these values: OK,
110-
INFO, WARNING, or ERROR.
109+
The required option '--style' should have one of these values: OK,
110+
INFO, WARNING, ERROR, TITLE, EMPH1, EMPH2, or EMPH3. The style colors
111+
can be viewed with the command 'apio info themes'.
111112

112113
Examples:
113114
apio api echo -t "Hello world", -s "INFO"
@@ -943,15 +944,19 @@ Options:
943944

944945
apio lint
945946

946-
Usage: apio lint [OPTIONS]
947+
Usage: apio lint [OPTIONS] [FILES]...
947948

948949
The command 'apio lint' scans the project's source files and reports
949950
errors, inconsistencies, and style violations. The command uses the
950951
Verilator tool, which is included with the standard Apio installation.
951952

953+
If specified files are not specified, the top module of the project
954+
and its dependencies are linted.
955+
952956
Examples:
953957
apio lint
954958
apio lint -t my_module
959+
apio lint file1.v file2.v
955960
apio lint --all
956961
apio lint --nosynth
957962
apio lint --novlt

apio/commands/apio_lint.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,13 @@
7575
inconsistencies, and style violations. The command uses the Verilator tool, \
7676
which is included with the standard Apio installation.
7777
78+
If specified files are not specified, the top module of the project and \
79+
its dependencies are linted.
80+
7881
Examples:[code]
7982
apio lint
8083
apio lint -t my_module
84+
apio lint file1.v file2.v
8185
apio lint --all
8286
apio lint --nosynth
8387
apio lint --novlt[/code]
@@ -95,6 +99,7 @@
9599
help=APIO_LINT_HELP,
96100
)
97101
@click.pass_context
102+
@click.argument("files", nargs=-1, required=False)
98103
@nosynth_option
99104
@novlt_option
100105
@nostyle_option
@@ -110,6 +115,8 @@
110115
@options.project_dir_option
111116
def cli(
112117
_: click.Context,
118+
# Args
119+
files,
113120
# Options
114121
nosynth: bool,
115122
novlt: bool,
@@ -151,6 +158,7 @@ def cli(
151158
verilator_warns=warns_list,
152159
nosynth=nosynth,
153160
novlt=novlt,
161+
file_names=files,
154162
)
155163

156164
assert lint_params.IsInitialized(), lint_params

apio/common/proto/apio.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ message LintParams {
126126
repeated string verilator_warns = 5;
127127
optional bool nosynth = 6 [default = false];
128128
optional bool novlt = 7 [default = false];
129+
repeated string file_names = 8; // Is specified, lint only these files.
129130
}
130131

131132
// Graph target specific params.

apio/common/proto/apio_pb2.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@
2727

2828

2929

30-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\napio.proto\x12\x11\x61pio.common.proto\"+\n\rIce40FpgaInfo\x12\x0c\n\x04type\x18\x01 \x02(\t\x12\x0c\n\x04pack\x18\x02 \x02(\t\"9\n\x0c\x45\x63p5FpgaInfo\x12\x0c\n\x04type\x18\x04 \x02(\t\x12\x0c\n\x04pack\x18\x05 \x02(\t\x12\r\n\x05speed\x18\x06 \x02(\t\"\x1f\n\rGowinFpgaInfo\x12\x0e\n\x06\x66\x61mily\x18\x04 \x02(\t\"\xda\x01\n\x08\x46pgaInfo\x12\x0f\n\x07\x66pga_id\x18\x01 \x02(\t\x12\x10\n\x08part_num\x18\x02 \x02(\t\x12\x0c\n\x04size\x18\x03 \x02(\t\x12\x31\n\x05ice40\x18\n \x01(\x0b\x32 .apio.common.proto.Ice40FpgaInfoH\x00\x12/\n\x04\x65\x63p5\x18\x0b \x01(\x0b\x32\x1f.apio.common.proto.Ecp5FpgaInfoH\x00\x12\x31\n\x05gowin\x18\x0c \x01(\x0b\x32 .apio.common.proto.GowinFpgaInfoH\x00\x42\x06\n\x04\x61rch\"I\n\tVerbosity\x12\x12\n\x03\x61ll\x18\x01 \x01(\x08:\x05\x66\x61lse\x12\x14\n\x05synth\x18\x02 \x01(\x08:\x05\x66\x61lse\x12\x12\n\x03pnr\x18\x03 \x01(\x08:\x05\x66\x61lse\"\xd9\x01\n\x0b\x45nvironment\x12\x13\n\x0bplatform_id\x18\x01 \x02(\t\x12\x12\n\nis_windows\x18\x02 \x02(\x08\x12\x36\n\rterminal_mode\x18\x03 \x02(\x0e\x32\x1f.apio.common.proto.TerminalMode\x12\x12\n\ntheme_name\x18\x04 \x02(\t\x12\x13\n\x0b\x64\x65\x62ug_level\x18\x05 \x02(\x05\x12\x12\n\nyosys_path\x18\x06 \x02(\t\x12\x14\n\x0ctrellis_path\x18\x07 \x02(\t\x12\x16\n\x0escons_shell_id\x18\x08 \x02(\t\"\xd4\x01\n\rApioEnvParams\x12\x10\n\x08\x65nv_name\x18\x01 \x02(\t\x12\x10\n\x08\x62oard_id\x18\x02 \x02(\t\x12\x12\n\ntop_module\x18\x03 \x02(\t\x12\x0f\n\x07\x64\x65\x66ines\x18\x04 \x03(\t\x12!\n\x19yosys_synth_extra_options\x18\x05 \x03(\t\x12\x1d\n\x15nextpnr_extra_options\x18\x06 \x03(\t\x12\x1d\n\x15gtkwave_extra_options\x18\x07 \x03(\t\x12\x19\n\x0f\x63onstraint_file\x18\x08 \x01(\t:\x00\"\xc6\x01\n\nLintParams\x12\x14\n\ntop_module\x18\x01 \x01(\t:\x00\x12\x1c\n\rverilator_all\x18\x02 \x01(\x08:\x05\x66\x61lse\x12!\n\x12verilator_no_style\x18\x03 \x01(\x08:\x05\x66\x61lse\x12\x1a\n\x12verilator_no_warns\x18\x04 \x03(\t\x12\x17\n\x0fverilator_warns\x18\x05 \x03(\t\x12\x16\n\x07nosynth\x18\x06 \x01(\x08:\x05\x66\x61lse\x12\x14\n\x05novlt\x18\x07 \x01(\x08:\x05\x66\x61lse\"o\n\x0bGraphParams\x12\x37\n\x0boutput_type\x18\x01 \x02(\x0e\x32\".apio.common.proto.GraphOutputType\x12\x12\n\ntop_module\x18\x02 \x01(\t\x12\x13\n\x0bopen_viewer\x18\x03 \x02(\x08\"d\n\tSimParams\x12\x18\n\x0etestbench_path\x18\x01 \x01(\t:\x00\x12\x11\n\tforce_sim\x18\x02 \x02(\x08\x12\x12\n\nno_gtkwave\x18\x03 \x02(\x08\x12\x16\n\x0e\x64\x65tach_gtkwave\x18\x04 \x02(\x08\"B\n\x0e\x41pioTestParams\x12\x18\n\x0etestbench_path\x18\x01 \x01(\t:\x00\x12\x16\n\x0e\x64\x65\x66\x61ult_option\x18\x02 \x02(\x08\"&\n\x0cUploadParams\x12\x16\n\x0eprogrammer_cmd\x18\x01 \x01(\t\"\x8b\x02\n\x0cTargetParams\x12-\n\x04lint\x18\n \x01(\x0b\x32\x1d.apio.common.proto.LintParamsH\x00\x12/\n\x05graph\x18\x0b \x01(\x0b\x32\x1e.apio.common.proto.GraphParamsH\x00\x12+\n\x03sim\x18\x0c \x01(\x0b\x32\x1c.apio.common.proto.SimParamsH\x00\x12\x31\n\x04test\x18\r \x01(\x0b\x32!.apio.common.proto.ApioTestParamsH\x00\x12\x31\n\x06upload\x18\x0e \x01(\x0b\x32\x1f.apio.common.proto.UploadParamsH\x00\x42\x08\n\x06target\"\xcd\x02\n\x0bSconsParams\x12\x11\n\ttimestamp\x18\x01 \x02(\t\x12)\n\x04\x61rch\x18\x02 \x02(\x0e\x32\x1b.apio.common.proto.ApioArch\x12.\n\tfpga_info\x18\x03 \x02(\x0b\x32\x1b.apio.common.proto.FpgaInfo\x12/\n\tverbosity\x18\x04 \x01(\x0b\x32\x1c.apio.common.proto.Verbosity\x12\x33\n\x0b\x65nvironment\x18\x05 \x02(\x0b\x32\x1e.apio.common.proto.Environment\x12\x39\n\x0f\x61pio_env_params\x18\x06 \x02(\x0b\x32 .apio.common.proto.ApioEnvParams\x12/\n\x06target\x18\x07 \x01(\x0b\x32\x1f.apio.common.proto.TargetParams*@\n\x08\x41pioArch\x12\x14\n\x10\x41RCH_UNSPECIFIED\x10\x00\x12\t\n\x05ICE40\x10\x01\x12\x08\n\x04\x45\x43P5\x10\x02\x12\t\n\x05GOWIN\x10\x03*_\n\x0cTerminalMode\x12\x18\n\x14TERMINAL_UNSPECIFIED\x10\x00\x12\x11\n\rAUTO_TERMINAL\x10\x01\x12\x12\n\x0e\x46ORCE_TERMINAL\x10\x02\x12\x0e\n\nFORCE_PIPE\x10\x03*B\n\x0fGraphOutputType\x12\x14\n\x10TYPE_UNSPECIFIED\x10\x00\x12\x07\n\x03SVG\x10\x01\x12\x07\n\x03PNG\x10\x02\x12\x07\n\x03PDF\x10\x03')
30+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\napio.proto\x12\x11\x61pio.common.proto\"+\n\rIce40FpgaInfo\x12\x0c\n\x04type\x18\x01 \x02(\t\x12\x0c\n\x04pack\x18\x02 \x02(\t\"9\n\x0c\x45\x63p5FpgaInfo\x12\x0c\n\x04type\x18\x04 \x02(\t\x12\x0c\n\x04pack\x18\x05 \x02(\t\x12\r\n\x05speed\x18\x06 \x02(\t\"\x1f\n\rGowinFpgaInfo\x12\x0e\n\x06\x66\x61mily\x18\x04 \x02(\t\"\xda\x01\n\x08\x46pgaInfo\x12\x0f\n\x07\x66pga_id\x18\x01 \x02(\t\x12\x10\n\x08part_num\x18\x02 \x02(\t\x12\x0c\n\x04size\x18\x03 \x02(\t\x12\x31\n\x05ice40\x18\n \x01(\x0b\x32 .apio.common.proto.Ice40FpgaInfoH\x00\x12/\n\x04\x65\x63p5\x18\x0b \x01(\x0b\x32\x1f.apio.common.proto.Ecp5FpgaInfoH\x00\x12\x31\n\x05gowin\x18\x0c \x01(\x0b\x32 .apio.common.proto.GowinFpgaInfoH\x00\x42\x06\n\x04\x61rch\"I\n\tVerbosity\x12\x12\n\x03\x61ll\x18\x01 \x01(\x08:\x05\x66\x61lse\x12\x14\n\x05synth\x18\x02 \x01(\x08:\x05\x66\x61lse\x12\x12\n\x03pnr\x18\x03 \x01(\x08:\x05\x66\x61lse\"\xd9\x01\n\x0b\x45nvironment\x12\x13\n\x0bplatform_id\x18\x01 \x02(\t\x12\x12\n\nis_windows\x18\x02 \x02(\x08\x12\x36\n\rterminal_mode\x18\x03 \x02(\x0e\x32\x1f.apio.common.proto.TerminalMode\x12\x12\n\ntheme_name\x18\x04 \x02(\t\x12\x13\n\x0b\x64\x65\x62ug_level\x18\x05 \x02(\x05\x12\x12\n\nyosys_path\x18\x06 \x02(\t\x12\x14\n\x0ctrellis_path\x18\x07 \x02(\t\x12\x16\n\x0escons_shell_id\x18\x08 \x02(\t\"\xd4\x01\n\rApioEnvParams\x12\x10\n\x08\x65nv_name\x18\x01 \x02(\t\x12\x10\n\x08\x62oard_id\x18\x02 \x02(\t\x12\x12\n\ntop_module\x18\x03 \x02(\t\x12\x0f\n\x07\x64\x65\x66ines\x18\x04 \x03(\t\x12!\n\x19yosys_synth_extra_options\x18\x05 \x03(\t\x12\x1d\n\x15nextpnr_extra_options\x18\x06 \x03(\t\x12\x1d\n\x15gtkwave_extra_options\x18\x07 \x03(\t\x12\x19\n\x0f\x63onstraint_file\x18\x08 \x01(\t:\x00\"\xda\x01\n\nLintParams\x12\x14\n\ntop_module\x18\x01 \x01(\t:\x00\x12\x1c\n\rverilator_all\x18\x02 \x01(\x08:\x05\x66\x61lse\x12!\n\x12verilator_no_style\x18\x03 \x01(\x08:\x05\x66\x61lse\x12\x1a\n\x12verilator_no_warns\x18\x04 \x03(\t\x12\x17\n\x0fverilator_warns\x18\x05 \x03(\t\x12\x16\n\x07nosynth\x18\x06 \x01(\x08:\x05\x66\x61lse\x12\x14\n\x05novlt\x18\x07 \x01(\x08:\x05\x66\x61lse\x12\x12\n\nfile_names\x18\x08 \x03(\t\"o\n\x0bGraphParams\x12\x37\n\x0boutput_type\x18\x01 \x02(\x0e\x32\".apio.common.proto.GraphOutputType\x12\x12\n\ntop_module\x18\x02 \x01(\t\x12\x13\n\x0bopen_viewer\x18\x03 \x02(\x08\"d\n\tSimParams\x12\x18\n\x0etestbench_path\x18\x01 \x01(\t:\x00\x12\x11\n\tforce_sim\x18\x02 \x02(\x08\x12\x12\n\nno_gtkwave\x18\x03 \x02(\x08\x12\x16\n\x0e\x64\x65tach_gtkwave\x18\x04 \x02(\x08\"B\n\x0e\x41pioTestParams\x12\x18\n\x0etestbench_path\x18\x01 \x01(\t:\x00\x12\x16\n\x0e\x64\x65\x66\x61ult_option\x18\x02 \x02(\x08\"&\n\x0cUploadParams\x12\x16\n\x0eprogrammer_cmd\x18\x01 \x01(\t\"\x8b\x02\n\x0cTargetParams\x12-\n\x04lint\x18\n \x01(\x0b\x32\x1d.apio.common.proto.LintParamsH\x00\x12/\n\x05graph\x18\x0b \x01(\x0b\x32\x1e.apio.common.proto.GraphParamsH\x00\x12+\n\x03sim\x18\x0c \x01(\x0b\x32\x1c.apio.common.proto.SimParamsH\x00\x12\x31\n\x04test\x18\r \x01(\x0b\x32!.apio.common.proto.ApioTestParamsH\x00\x12\x31\n\x06upload\x18\x0e \x01(\x0b\x32\x1f.apio.common.proto.UploadParamsH\x00\x42\x08\n\x06target\"\xcd\x02\n\x0bSconsParams\x12\x11\n\ttimestamp\x18\x01 \x02(\t\x12)\n\x04\x61rch\x18\x02 \x02(\x0e\x32\x1b.apio.common.proto.ApioArch\x12.\n\tfpga_info\x18\x03 \x02(\x0b\x32\x1b.apio.common.proto.FpgaInfo\x12/\n\tverbosity\x18\x04 \x01(\x0b\x32\x1c.apio.common.proto.Verbosity\x12\x33\n\x0b\x65nvironment\x18\x05 \x02(\x0b\x32\x1e.apio.common.proto.Environment\x12\x39\n\x0f\x61pio_env_params\x18\x06 \x02(\x0b\x32 .apio.common.proto.ApioEnvParams\x12/\n\x06target\x18\x07 \x01(\x0b\x32\x1f.apio.common.proto.TargetParams*@\n\x08\x41pioArch\x12\x14\n\x10\x41RCH_UNSPECIFIED\x10\x00\x12\t\n\x05ICE40\x10\x01\x12\x08\n\x04\x45\x43P5\x10\x02\x12\t\n\x05GOWIN\x10\x03*_\n\x0cTerminalMode\x12\x18\n\x14TERMINAL_UNSPECIFIED\x10\x00\x12\x11\n\rAUTO_TERMINAL\x10\x01\x12\x12\n\x0e\x46ORCE_TERMINAL\x10\x02\x12\x0e\n\nFORCE_PIPE\x10\x03*B\n\x0fGraphOutputType\x12\x14\n\x10TYPE_UNSPECIFIED\x10\x00\x12\x07\n\x03SVG\x10\x01\x12\x07\n\x03PNG\x10\x02\x12\x07\n\x03PDF\x10\x03')
3131

3232
_globals = globals()
3333
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
3434
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'apio_pb2', _globals)
3535
if not _descriptor._USE_C_DESCRIPTORS:
3636
DESCRIPTOR._loaded_options = None
37-
_globals['_APIOARCH']._serialized_start=2031
38-
_globals['_APIOARCH']._serialized_end=2095
39-
_globals['_TERMINALMODE']._serialized_start=2097
40-
_globals['_TERMINALMODE']._serialized_end=2192
41-
_globals['_GRAPHOUTPUTTYPE']._serialized_start=2194
42-
_globals['_GRAPHOUTPUTTYPE']._serialized_end=2260
37+
_globals['_APIOARCH']._serialized_start=2051
38+
_globals['_APIOARCH']._serialized_end=2115
39+
_globals['_TERMINALMODE']._serialized_start=2117
40+
_globals['_TERMINALMODE']._serialized_end=2212
41+
_globals['_GRAPHOUTPUTTYPE']._serialized_start=2214
42+
_globals['_GRAPHOUTPUTTYPE']._serialized_end=2280
4343
_globals['_ICE40FPGAINFO']._serialized_start=33
4444
_globals['_ICE40FPGAINFO']._serialized_end=76
4545
_globals['_ECP5FPGAINFO']._serialized_start=78
@@ -55,17 +55,17 @@
5555
_globals['_APIOENVPARAMS']._serialized_start=687
5656
_globals['_APIOENVPARAMS']._serialized_end=899
5757
_globals['_LINTPARAMS']._serialized_start=902
58-
_globals['_LINTPARAMS']._serialized_end=1100
59-
_globals['_GRAPHPARAMS']._serialized_start=1102
60-
_globals['_GRAPHPARAMS']._serialized_end=1213
61-
_globals['_SIMPARAMS']._serialized_start=1215
62-
_globals['_SIMPARAMS']._serialized_end=1315
63-
_globals['_APIOTESTPARAMS']._serialized_start=1317
64-
_globals['_APIOTESTPARAMS']._serialized_end=1383
65-
_globals['_UPLOADPARAMS']._serialized_start=1385
66-
_globals['_UPLOADPARAMS']._serialized_end=1423
67-
_globals['_TARGETPARAMS']._serialized_start=1426
68-
_globals['_TARGETPARAMS']._serialized_end=1693
69-
_globals['_SCONSPARAMS']._serialized_start=1696
70-
_globals['_SCONSPARAMS']._serialized_end=2029
58+
_globals['_LINTPARAMS']._serialized_end=1120
59+
_globals['_GRAPHPARAMS']._serialized_start=1122
60+
_globals['_GRAPHPARAMS']._serialized_end=1233
61+
_globals['_SIMPARAMS']._serialized_start=1235
62+
_globals['_SIMPARAMS']._serialized_end=1335
63+
_globals['_APIOTESTPARAMS']._serialized_start=1337
64+
_globals['_APIOTESTPARAMS']._serialized_end=1403
65+
_globals['_UPLOADPARAMS']._serialized_start=1405
66+
_globals['_UPLOADPARAMS']._serialized_end=1443
67+
_globals['_TARGETPARAMS']._serialized_start=1446
68+
_globals['_TARGETPARAMS']._serialized_end=1713
69+
_globals['_SCONSPARAMS']._serialized_start=1716
70+
_globals['_SCONSPARAMS']._serialized_end=2049
7171
# @@protoc_insertion_point(module_scope)

apio/common/proto/apio_pb2.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,22 +134,24 @@ class ApioEnvParams(_message.Message):
134134
def __init__(self, env_name: _Optional[str] = ..., board_id: _Optional[str] = ..., top_module: _Optional[str] = ..., defines: _Optional[_Iterable[str]] = ..., yosys_synth_extra_options: _Optional[_Iterable[str]] = ..., nextpnr_extra_options: _Optional[_Iterable[str]] = ..., gtkwave_extra_options: _Optional[_Iterable[str]] = ..., constraint_file: _Optional[str] = ...) -> None: ...
135135

136136
class LintParams(_message.Message):
137-
__slots__ = ("top_module", "verilator_all", "verilator_no_style", "verilator_no_warns", "verilator_warns", "nosynth", "novlt")
137+
__slots__ = ("top_module", "verilator_all", "verilator_no_style", "verilator_no_warns", "verilator_warns", "nosynth", "novlt", "file_names")
138138
TOP_MODULE_FIELD_NUMBER: _ClassVar[int]
139139
VERILATOR_ALL_FIELD_NUMBER: _ClassVar[int]
140140
VERILATOR_NO_STYLE_FIELD_NUMBER: _ClassVar[int]
141141
VERILATOR_NO_WARNS_FIELD_NUMBER: _ClassVar[int]
142142
VERILATOR_WARNS_FIELD_NUMBER: _ClassVar[int]
143143
NOSYNTH_FIELD_NUMBER: _ClassVar[int]
144144
NOVLT_FIELD_NUMBER: _ClassVar[int]
145+
FILE_NAMES_FIELD_NUMBER: _ClassVar[int]
145146
top_module: str
146147
verilator_all: bool
147148
verilator_no_style: bool
148149
verilator_no_warns: _containers.RepeatedScalarFieldContainer[str]
149150
verilator_warns: _containers.RepeatedScalarFieldContainer[str]
150151
nosynth: bool
151152
novlt: bool
152-
def __init__(self, top_module: _Optional[str] = ..., verilator_all: bool = ..., verilator_no_style: bool = ..., verilator_no_warns: _Optional[_Iterable[str]] = ..., verilator_warns: _Optional[_Iterable[str]] = ..., nosynth: bool = ..., novlt: bool = ...) -> None: ...
153+
file_names: _containers.RepeatedScalarFieldContainer[str]
154+
def __init__(self, top_module: _Optional[str] = ..., verilator_all: bool = ..., verilator_no_style: bool = ..., verilator_no_warns: _Optional[_Iterable[str]] = ..., verilator_warns: _Optional[_Iterable[str]] = ..., nosynth: bool = ..., novlt: bool = ..., file_names: _Optional[_Iterable[str]] = ...) -> None: ...
153155

154156
class GraphParams(_message.Message):
155157
__slots__ = ("output_type", "top_module", "open_viewer")

apio/scons/plugin_util.py

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)