@ -1,5 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Apache-2.0
# Copyright 2013-2018 The Meson development team
# Copyright 2013-2018 The Meson development team
# Copyright © 2024 Intel Corporation
# This file contains the detection logic for external dependencies.
# This file contains the detection logic for external dependencies.
# Custom logic for several other packages are in separate files.
# Custom logic for several other packages are in separate files.
@ -10,6 +11,7 @@ import os
import collections
import collections
import itertools
import itertools
import typing as T
import typing as T
import uuid
from enum import Enum
from enum import Enum
from . . import mlog , mesonlib
from . . import mlog , mesonlib
@ -106,6 +108,9 @@ class Dependency(HoldableObject):
return kwargs [ ' include_type ' ]
return kwargs [ ' include_type ' ]
def __init__ ( self , type_name : DependencyTypeName , kwargs : T . Dict [ str , T . Any ] ) - > None :
def __init__ ( self , type_name : DependencyTypeName , kwargs : T . Dict [ str , T . Any ] ) - > None :
# This allows two Dependencies to be compared even after being copied.
# The purpose is to allow the name to be changed, but still have a proper comparison
self . _id = uuid . uuid4 ( ) . int
self . name = f ' dep { id ( self ) } '
self . name = f ' dep { id ( self ) } '
self . version : T . Optional [ str ] = None
self . version : T . Optional [ str ] = None
self . language : T . Optional [ str ] = None # None means C-like
self . language : T . Optional [ str ] = None # None means C-like
@ -124,6 +129,14 @@ class Dependency(HoldableObject):
self . featurechecks : T . List [ ' FeatureCheckBase ' ] = [ ]
self . featurechecks : T . List [ ' FeatureCheckBase ' ] = [ ]
self . feature_since : T . Optional [ T . Tuple [ str , str ] ] = None
self . feature_since : T . Optional [ T . Tuple [ str , str ] ] = None
def __eq__ ( self , other : object ) - > bool :
if not isinstance ( other , Dependency ) :
return NotImplemented
return self . _id == other . _id
def __hash__ ( self ) - > int :
return self . _id
def __repr__ ( self ) - > str :
def __repr__ ( self ) - > str :
return f ' < { self . __class__ . __name__ } { self . name } : { self . is_found } > '
return f ' < { self . __class__ . __name__ } { self . name } : { self . is_found } > '
@ -402,6 +415,7 @@ class ExternalDependency(Dependency, HasNativeKwarg):
link_args : bool = False , links : bool = False ,
link_args : bool = False , links : bool = False ,
includes : bool = False , sources : bool = False ) - > Dependency :
includes : bool = False , sources : bool = False ) - > Dependency :
new = copy . copy ( self )
new = copy . copy ( self )
new . _id = uuid . uuid4 ( ) . int
if not compile_args :
if not compile_args :
new . compile_args = [ ]
new . compile_args = [ ]
if not link_args :
if not link_args :
@ -472,7 +486,9 @@ class NotFoundDependency(Dependency):
def get_partial_dependency ( self , * , compile_args : bool = False ,
def get_partial_dependency ( self , * , compile_args : bool = False ,
link_args : bool = False , links : bool = False ,
link_args : bool = False , links : bool = False ,
includes : bool = False , sources : bool = False ) - > ' NotFoundDependency ' :
includes : bool = False , sources : bool = False ) - > ' NotFoundDependency ' :
return copy . copy ( self )
new = copy . copy ( self )
new . _id = uuid . uuid4 ( ) . int
return new
class ExternalLibrary ( ExternalDependency ) :
class ExternalLibrary ( ExternalDependency ) :
@ -512,6 +528,7 @@ class ExternalLibrary(ExternalDependency):
# External library only has link_args, so ignore the rest of the
# External library only has link_args, so ignore the rest of the
# interface.
# interface.
new = copy . copy ( self )
new = copy . copy ( self )
new . _id = uuid . uuid4 ( ) . int
if not link_args :
if not link_args :
new . link_args = [ ]
new . link_args = [ ]
return new
return new