5
5
import sys
6
6
7
7
8
- def run_cargo_tree (path ):
9
- cmd = 'cargo tree --all-features -d'
8
+ def run_cargo_tree (path , flags = None ):
9
+ cmd = 'cargo tree'
10
+ if flags is not None :
11
+ cmd += ' ' + flags
10
12
prev_dir = os .getcwd ()
11
13
os .chdir (os .path .join (path ))
12
14
return subprocess .check_output (cmd , shell = True ).decode ()
@@ -43,14 +45,46 @@ def main(argv=[], prog_name=''):
43
45
parser = argparse .ArgumentParser (prog = 'DependencyCrossmatcher' ,
44
46
description = 'Checks the version mismatches for dependencies '
45
47
'in Cargo based repositories' )
48
+ parser .add_argument ("-c" , "--compare" , action = 'store_true' ,
49
+ help = 'Check for mismatches between 2 repositories' )
46
50
parser .add_argument ('--deps_dir' ,
47
51
required = True ,
48
- help = 'Existing directory that contains the Cargo.toml for analyzing'
52
+ nargs = '+' ,
53
+ help = 'Existing directories that contain Cargo.toml for analyzing '
49
54
'dependencies' )
50
55
args = parser .parse_args ()
51
56
52
- mismatches = run_deps_mismatcher (run_cargo_tree (args .deps_dir ))
53
- print_deps (mismatches )
57
+ mismatches = dict ()
58
+ parsec_tool_flags = '--all-features -d'
59
+
60
+ if args .compare :
61
+ exceptions = {
62
+ 'bindgen' : ['v0.66.1' , 'v0.57.0' ],
63
+ }
64
+ parsec_repo , parsec_tool_repo = args .deps_dir
65
+ parsec_flags = '--all-features' + ' '
66
+ parsec_flags = '--features tss-esapi/generate-bindings,cryptoki/generate-bindings -d'
67
+ mismatches_parsec = run_deps_mismatcher (run_cargo_tree (parsec_repo , parsec_flags ))
68
+ mismatches_parsec_tool = run_deps_mismatcher (run_cargo_tree (parsec_tool_repo ,
69
+ parsec_tool_flags )
70
+ )
71
+
72
+ # Dependencies that are common to both parsec_repo and parsec_tool_repo repos
73
+ common_deps = list (set (mismatches_parsec .keys ()) & set (mismatches_parsec_tool .keys ()))
74
+ for dep in common_deps :
75
+ # Symmetric difference of repos parsec_repo and parsec_tool_repo
76
+ mistmatch = list (set (mismatches_parsec [dep ]) ^ set (mismatches_parsec_tool [dep ]))
77
+ if len (mistmatch ) > 0 :
78
+ mismatches [dep ] = mistmatch
79
+ else :
80
+ exceptions = {
81
+ 'base64' : ['v0.13.1' , 'v0.21.4' ],
82
+ 'bitflags' : ['v1.3.2' , 'v2.4.1' ],
83
+ 'nom' : ['v5.1.3' , 'v7.1.3' ],
84
+ 'syn' : ['v1.0.109' , 'v2.0.38' ],
85
+ 'yasna' : ['v0.4.0' , 'v0.5.2' ],
86
+ }
87
+ mismatches = run_deps_mismatcher (run_cargo_tree (args .deps_dir [0 ], parsec_tool_flags ))
54
88
55
89
mismatches = get_deps_with_more_than_1v (mismatches )
56
90
@@ -60,15 +94,12 @@ def main(argv=[], prog_name=''):
60
94
print ('---------------------mistmatches----------------------\n \n ' )
61
95
print_deps (mismatches )
62
96
63
- exceptions = {
64
- 'base64' : ['v0.13.1' , 'v0.21.4' ],
65
- 'bitflags' : ['v1.3.2' , 'v2.4.1' ],
66
- 'nom' : ['v5.1.3' , 'v7.1.3' ],
67
- 'syn' : ['v1.0.109' , 'v2.0.38' ],
68
- 'yasna' : ['v0.4.0' , 'v0.5.2' ],
69
- }
97
+ if not args .compare :
98
+ errormsg = "Found dependencies version mismatches in parsec-tool"
99
+ else :
100
+ errormsg = "Found dependencies version mismatches between parsec and parsec-tool"
70
101
71
- assert exceptions == mismatches , "Found dependencies version mismatches in parsec-tool"
102
+ assert exceptions == mismatches , errormsg
72
103
73
104
return 0
74
105
0 commit comments