1
1
# SPDX-License-Identifier: Apache-2.0
2
2
# Copyright 2013-2018 The Meson development team
3
+ # Copyright © 2024 Intel Corporation
3
4
4
5
# This file contains the detection logic for external dependencies.
5
6
# Custom logic for several other packages are in separate files.
@@ -106,6 +107,9 @@ def _process_include_type_kw(cls, kwargs: T.Dict[str, T.Any]) -> str:
106
107
return kwargs ['include_type' ]
107
108
108
109
def __init__ (self , type_name : DependencyTypeName , kwargs : T .Dict [str , T .Any ]) -> None :
110
+ # This allows two Dependencies to be compared even after being copied.
111
+ # The purpose is to allow the name to be changed, but still have a proper comparison
112
+ self .__id = id (self )
109
113
self .name = f'dep{ id (self )} '
110
114
self .version : T .Optional [str ] = None
111
115
self .language : T .Optional [str ] = None # None means C-like
@@ -124,6 +128,14 @@ def __init__(self, type_name: DependencyTypeName, kwargs: T.Dict[str, T.Any]) ->
124
128
self .featurechecks : T .List ['FeatureCheckBase' ] = []
125
129
self .feature_since : T .Optional [T .Tuple [str , str ]] = None
126
130
131
+ def __eq__ (self , other : object ) -> bool :
132
+ if not isinstance (other , Dependency ):
133
+ return NotImplemented
134
+ return self .__id == other .__id
135
+
136
+ def __hash__ (self ) -> int :
137
+ return self .__id
138
+
127
139
def __repr__ (self ) -> str :
128
140
return f'<{ self .__class__ .__name__ } { self .name } : { self .is_found } >'
129
141
0 commit comments