Skip to content

Commit a632849

Browse files
Merge pull request #3344 from verilog-to-routing/feature-fix-cpp-format
[CI] Fix CPP Format Issue
2 parents aec8907 + 9c0579b commit a632849

File tree

19 files changed

+147
-95
lines changed

19 files changed

+147
-95
lines changed

.github/workflows/test.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,27 @@ jobs:
128128
fail-fast: false
129129
matrix:
130130
include:
131-
- { name: 'C/C++', script: 'check-format.sh' , with_python: 'no', pkgs: 'clang-format-18' }
132-
- { name: 'Python', script: 'check-format-py.sh', with_python: 'yes', pkgs: '' }
133-
- { name: 'Python Lint', script: 'pylint_check.py' , with_python: 'yes', pkgs: '' }
131+
- { name: 'C/C++', script: 'check-format.sh' , with_python: 'yes', with_submodules: 'true', all_vtr_pkgs: 'yes', pkgs: 'clang-format-18' }
132+
- { name: 'Python', script: 'check-format-py.sh', with_python: 'yes', with_submodules: 'true', all_vtr_pkgs: 'yes', pkgs: '' }
133+
- { name: 'Python Lint', script: 'pylint_check.py' , with_python: 'yes', with_submodules: 'false', all_vtr_pkgs: 'no', pkgs: '' }
134134
name: 'F: ${{ matrix.name }}'
135135
steps:
136136

137137
- uses: actions/checkout@v4
138-
# NOTE: We do not need sub-modules. We do not check sub-modules for formatting.
138+
with:
139+
submodules: ${{ matrix.with_submodules }}
140+
# NOTE: We usually do not need sub-modules. We do not check sub-modules
141+
# for formatting. However we may need to build make-format which
142+
# requires building VTR which will not build without submodules.
143+
# TODO: We should relax this requirement.
144+
145+
# In order to perform a cpp format of VTR, make format is used which requires
146+
# all of the vpr dependencies to be installed.
147+
# TODO: This should be fixed so this test is not as heavy. We do not need
148+
# these dependencies to perform a simple format.
149+
- name: Install dependencies
150+
if: ${{ matrix.all_vtr_pkgs == 'yes' }}
151+
run: ./install_apt_packages.sh
139152

140153
# TODO: This should be on the same version of Python as would be found on
141154
# Ubuntu 24.04 (3.12.3); however that version has some linting errors.

dev/check-format.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ if [ $clean -ne 0 ]; then
88
else
99
echo "Code Formatting Check"
1010
echo "====================="
11-
make format"$1" > /dev/null 2>&1
11+
make format"$1" > /dev/null
12+
if [ $? -ne 0 ]; then
13+
echo "make format failed!"
14+
exit 1
15+
fi
1216

1317
valid_format=$(git diff | wc -l)
1418

libs/librtlnumber/src/include/internal_bits.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ constexpr short integer_t_size = (sizeof(integer_t) * 8);
2727
}
2828

2929
#define unroll_1d(lut) \
30-
{lut[_0], lut[_1], lut[_x], lut[_z]}
30+
{ lut[_0], lut[_1], lut[_x], lut[_z] }
3131
#define unroll_2d(lut) \
32-
{unroll_1d(lut[_0]), unroll_1d(lut[_1]), unroll_1d(lut[_x]), unroll_1d(lut[_z])}
32+
{ unroll_1d(lut[_0]), unroll_1d(lut[_1]), unroll_1d(lut[_x]), unroll_1d(lut[_z]) }
3333

3434
#define unroll_1d_invert(lut) \
35-
{l_not[lut[_0]], l_not[lut[_1]], l_not[lut[_x]], l_not[lut[_z]]}
35+
{ l_not[lut[_0]], l_not[lut[_1]], l_not[lut[_x]], l_not[lut[_z]] }
3636
#define unroll_2d_invert(lut) \
37-
{unroll_1d_invert(lut[_0]), unroll_1d_invert(lut[_1]), unroll_1d_invert(lut[_x]), unroll_1d_invert(lut[_z])}
37+
{ unroll_1d_invert(lut[_0]), unroll_1d_invert(lut[_1]), unroll_1d_invert(lut[_x]), unroll_1d_invert(lut[_z]) }
3838

3939
namespace BitSpace {
4040
typedef uint8_t bit_value_t;

odin_ii/regression_test/tools/ODIN_CONFIG.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,7 @@ def buildChildren(self, child_, nodeName_):
15421542

15431543

15441544
def usage():
1545-
print USAGE_TEXT
1545+
print(USAGE_TEXT)
15461546
sys.exit(1)
15471547

15481548

odin_ii/regression_test/tools/odin_config_maker.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ def main(argv=None):
2828

2929
# Check our options for input errors
3030
if not options.arch:
31-
print "\tDid not get an architecture file; use odin_config_maker.py -h for help."
31+
print("\tDid not get an architecture file; use odin_config_maker.py -h for help.")
3232
return -1
3333
if options.individual is None and options.directory is None and options.files is None:
34-
print "\tDid not get any input options; use odin_config_maker.py -h for help."
34+
print("\tDid not get any input options; use odin_config_maker.py -h for help.")
3535
return -1
3636
if options.individual is not None and options.directory is not None:
37-
print "\tThe -i and -d options are mutually exclusive; use odin_config_maker.py -h for help."
37+
print(
38+
"\tThe -i and -d options are mutually exclusive; use odin_config_maker.py -h for help."
39+
)
3840
return -1
3941

4042
# Create our Config Files
@@ -54,7 +56,7 @@ def main(argv=None):
5456
)
5557

5658
for file in file_list:
57-
print file[file.rfind("/") + 1 : file.rfind(".v")]
59+
print(file[file.rfind("/") + 1 : file.rfind(".v")])
5860
base = file[file.rfind("/") + 1 : file.rfind(".v")]
5961
create_odin_projects(options, [file], base, path)
6062

@@ -78,7 +80,7 @@ def main(argv=None):
7880

7981
create_odin_projects(options, file_list, base, path)
8082
else:
81-
print "Something Failed!"
83+
print("Something Failed!")
8284
return -1
8385

8486

odin_ii/regression_test/tools/synth_using_odin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
if len(sys.argv) is not 2:
12-
print "usage: " + sys.argv[0] + " <dir>"
12+
print("usage: " + sys.argv[0] + " <dir>")
1313

1414
path = abspath(sys.argv[1]) + "/"
1515
slog = open(path + "ODIN_success.lst", "w")

odin_ii/regression_test/tools/synth_using_quartus.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
# print sys.argv
2121
if len(sys.argv) != 2:
22-
print "Take our Verilog benchmarks and synthesize them using QIS (Quartus)"
23-
print "Usage: GenQuartusBlifs.py <Verilog Source Dir>"
22+
print("Take our Verilog benchmarks and synthesize them using QIS (Quartus)")
23+
print("Usage: GenQuartusBlifs.py <Verilog Source Dir>")
2424
sys.exit(0)
2525

2626
projNames = map(odin.trimDotV, filter(odin.isVerilog, os.listdir(sys.argv[1])))
@@ -68,11 +68,11 @@
6868

6969
process = subprocess.Popen(clean, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
7070
(out, err) = process.communicate()
71-
print out + "\n"
71+
print(out + "\n")
7272

7373
process = subprocess.Popen(create, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
7474
(out, err) = process.communicate()
75-
print out + "\n"
75+
print(out + "\n")
7676

7777
process = subprocess.Popen(move, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
7878
(out, err) = process.communicate()

odin_ii/regression_test/tools/synth_using_vl2mv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
if len(sys.argv) is not 2:
13-
print "usage: " + sys.argv[0] + " <dir>"
13+
print("usage: " + sys.argv[0] + " <dir>")
1414

1515
path = abspath(sys.argv[1]) + "/"
1616
os.system('mkdir -p "' + path + 'VL2MV_Blifs/"')

odin_ii/usefull_tools/restore_blackboxed_latches_from_blif_file.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,24 @@ def main():
4949
# print "DEBUG: RESTORED_BLIF_FILE: {}".format(args.restoredBlifFile)
5050

5151
if args.inplace:
52-
print "Inplace Restortation:"
52+
print("Inplace Restortation:")
5353
elif not args.restoredBlifFile:
54-
print '\n\nERROR: Must Specify Either Inplace Restoration "-i,--inplace" or a file to restore to "-r\--restoredBlifFile"\nExiting...\n'
54+
print(
55+
'\n\nERROR: Must Specify Either Inplace Restoration "-i,--inplace" or a file to restore to "-r\--restoredBlifFile"\nExiting...\n'
56+
)
5557
parser.print_help()
5658
return -1
5759

5860
if not os.path.isfile(args.blifFileToRestore):
59-
print '\n\nERROR: BLIF File to Restore "{}" doesn not exist\nExiting...\n'.format(
60-
args.blifFileToRestore
61+
print(
62+
'\n\nERROR: BLIF File to Restore "{}" doesn not exist\nExiting...\n'.format(
63+
args.blifFileToRestore
64+
)
6165
)
6266
parser.print_help()
6367
return -1
6468

65-
print "Restoring original inputs, ouptuts, types, controls and init_vals:"
69+
print("Restoring original inputs, ouptuts, types, controls and init_vals:")
6670

6771
if args.inplace:
6872
args.restoredBlifFile = "restored.blif.tmp"
@@ -81,15 +85,15 @@ def main():
8185
line = line.replace(src, target)
8286
outfile.write(line)
8387

84-
print "Removing BlackBoxed Latch Model:"
88+
print("Removing BlackBoxed Latch Model:")
8589

8690
ignore = False
8791
for line in fileinput.input(args.restoredBlifFile, inplace=True):
8892
if not ignore:
8993
if line.startswith(".model bb_latch"):
9094
ignore = True
9195
else:
92-
print line,
96+
print(line),
9397
if ignore and line.isspace():
9498
ignore = False
9599

@@ -98,9 +102,9 @@ def main():
98102
dest_filename = os.path.join(args.blifFileToRestore)
99103
shutil.move(src_filename, dest_filename)
100104

101-
print "BLIF File Restored. See: {}".format(args.blifFileToRestore)
105+
print("BLIF File Restored. See: {}".format(args.blifFileToRestore))
102106
else:
103-
print "BLIF File Restored. See: {}".format(args.restoredBlifFile)
107+
print("BLIF File Restored. See: {}".format(args.restoredBlifFile))
104108

105109
return
106110

vpr/src/base/read_netlist.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,11 @@ static void sync_clustered_and_atom_netlists(ClusteredNetlist& clb_nlist,
319319
}
320320

321321
static void process_complex_block(pugi::xml_node clb_block,
322-
const ClusterBlockId index,
323-
int& num_primitives,
324-
const pugiutil::loc_data& loc_data,
325-
const std::unordered_map<std::string, int>& logical_block_type_name_to_index,
326-
ClusteredNetlist& clb_nlist) {
322+
const ClusterBlockId index,
323+
int& num_primitives,
324+
const pugiutil::loc_data& loc_data,
325+
const std::unordered_map<std::string, int>& logical_block_type_name_to_index,
326+
ClusteredNetlist& clb_nlist) {
327327
const auto& logical_block_types = g_vpr_ctx.device().logical_block_types;
328328

329329
//Parse cb attributes

0 commit comments

Comments
 (0)