Skip to content

Commit c8a8eaa

Browse files
tgonzalezorlandoarmgowthamsk-arm
authored andcommitted
utils/dependency_cross_matcher.py: Add parsec-tool checking
Enable the script to be called with parsec-tool repository, by adding its exception list. Signed-off-by: Tomás González <[email protected]>
1 parent 67223e8 commit c8a8eaa

File tree

1 file changed

+33
-17
lines changed

1 file changed

+33
-17
lines changed

utils/dependency_cross_matcher.py

+33-17
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,17 @@ def main(argv=[], prog_name=''):
5252
description='Checks the version mismatches for dependencies '
5353
'in Cargo based repositories')
5454
parser.add_argument("-c", "--compare", action='store_true',
55-
help='Check for mismatches between 2 repositories')
55+
help='Check for mismatches between parsec and parsec-tool.')
5656
parser.add_argument('--deps_dir',
5757
required=True,
5858
nargs='+',
59-
help='Existing directories that contain Cargo.toml for analyzing '
60-
'dependencies')
59+
help='Existing directories that contain Cargo.toml for analyzing ' \
60+
'dependencies. Note: when using the -c option, parsec should be ' \
61+
'first of the listed directories and parsec-tool the second.')
6162
args = parser.parse_args()
62-
6363
mismatches = dict()
64+
65+
parsec_tool_flags = '--all-features -d'
6466
parsec_flags = '--all-features' + ' '
6567
parsec_flags += '--features tss-esapi/generate-bindings,cryptoki/generate-bindings -d'
6668

@@ -71,7 +73,6 @@ def main(argv=[], prog_name=''):
7173
'cexpr': ['v0.6.0'],
7274
}
7375
parsec_repo, parsec_tool_repo = args.deps_dir
74-
parsec_tool_flags = '--all-features -d'
7576
mismatches_parsec = run_deps_mismatcher(run_cargo_tree(parsec_repo, parsec_flags))
7677
mismatches_parsec_tool = run_deps_mismatcher(run_cargo_tree(parsec_tool_repo,
7778
parsec_tool_flags)
@@ -85,17 +86,31 @@ def main(argv=[], prog_name=''):
8586
if len(mistmatch) > 0:
8687
mismatches[dep] = mistmatch
8788
else:
88-
# Versions should be sorted!
89-
exceptions = {
90-
'base64': ['v0.13.1', 'v0.21.4'],
91-
'bindgen': ['v0.57.0', 'v0.66.1'],
92-
'bitflags': ['v1.3.2', 'v2.4.1'],
93-
'cexpr': ['v0.4.0', 'v0.6.0'],
94-
'nom': ['v5.1.3', 'v7.1.3'],
95-
'shlex': ['v0.1.1', 'v1.2.0'],
96-
'syn': ['v1.0.109', 'v2.0.38'],
97-
}
98-
mismatches = run_deps_mismatcher(run_cargo_tree(args.deps_dir[0], parsec_flags))
89+
repo_dir = args.deps_dir[0]
90+
if os.path.basename(repo_dir) == 'parsec':
91+
# Versions should be sorted!
92+
exceptions = {
93+
'base64': ['v0.13.1', 'v0.21.4'],
94+
'bindgen': ['v0.57.0', 'v0.66.1'],
95+
'bitflags': ['v1.3.2', 'v2.4.1'],
96+
'cexpr': ['v0.4.0', 'v0.6.0'],
97+
'nom': ['v5.1.3', 'v7.1.3'],
98+
'shlex': ['v0.1.1', 'v1.2.0'],
99+
'syn': ['v1.0.109', 'v2.0.38'],
100+
}
101+
tree_flags = parsec_flags
102+
elif os.path.basename(repo_dir) == 'parsec-tool':
103+
# Versions should be sorted!
104+
exceptions = {
105+
'base64': ['v0.13.1', 'v0.21.4'],
106+
'bitflags': ['v1.3.2', 'v2.4.1'],
107+
'nom': ['v5.1.3', 'v7.1.3'],
108+
'syn': ['v1.0.109', 'v2.0.38'],
109+
'yasna': ['v0.4.0', 'v0.5.2'],
110+
}
111+
tree_flags = parsec_tool_flags
112+
113+
mismatches = run_deps_mismatcher(run_cargo_tree(repo_dir, tree_flags))
99114
mismatches = get_deps_with_more_than_1v(mismatches)
100115

101116
print('---------------------exceptions-----------------------\n\n')
@@ -105,7 +120,8 @@ def main(argv=[], prog_name=''):
105120
print_deps(mismatches)
106121

107122
if not args.compare:
108-
errormsg = "Found dependencies version mismatches in parsec"
123+
repo_name = os.path.basename(args.deps_dir[0])
124+
errormsg = "Found dependencies version mismatches in " + repo_name
109125
else:
110126
errormsg = "Found dependencies version mismatches between parsec and parsec-tool"
111127

0 commit comments

Comments
 (0)