1313from .ast .interpreter import IntrospectionBuildTarget , IntrospectionDependency , _symbol
1414from .interpreterbase import UnknownValue , TV_func
1515from .interpreterbase .helpers import flatten
16- from mesonbuild .mesonlib import MesonException , setup_vsenv , relpath
16+ from mesonbuild .mesonlib import MesonException , pathname_sort_key , relpath , setup_vsenv
1717from . import mlog , environment
1818from functools import wraps
1919from .mparser import Token , ArrayNode , ArgumentNode , ArithmeticNode , AssignmentNode , BaseNode , StringNode , BooleanNode , ElementaryNode , IdNode , FunctionNode , PlusAssignmentNode
@@ -951,15 +951,6 @@ def rel_source(src: str) -> str:
951951
952952 # Sort files
953953 for i in to_sort_nodes :
954- def convert (text : str ) -> T .Union [int , str ]:
955- return int (text ) if text .isdigit () else text .lower ()
956-
957- def alphanum_key (key : str ) -> T .List [T .Union [int , str ]]:
958- return [convert (c ) for c in re .split ('([0-9]+)' , key )]
959-
960- def path_sorter (key : str ) -> T .List [T .Tuple [bool , T .List [T .Union [int , str ]]]]:
961- return [(key .count ('/' ) <= idx , alphanum_key (x )) for idx , x in enumerate (key .split ('/' ))]
962-
963954 if isinstance (i , FunctionNode ) and i .func_name .value in BUILD_TARGET_FUNCTIONS :
964955 src_args = i .args .arguments [1 :]
965956 target_name = [i .args .arguments [0 ]]
@@ -968,7 +959,7 @@ def path_sorter(key: str) -> T.List[T.Tuple[bool, T.List[T.Union[int, str]]]]:
968959 target_name = []
969960 unknown : T .List [BaseNode ] = [x for x in src_args if not isinstance (x , StringNode )]
970961 sources : T .List [StringNode ] = [x for x in src_args if isinstance (x , StringNode )]
971- sources = sorted (sources , key = lambda x : path_sorter (x .value ))
962+ sources = sorted (sources , key = lambda x : pathname_sort_key (x .value ))
972963 i .args .arguments = target_name + unknown + T .cast (T .List [BaseNode ], sources )
973964
974965 def process (self , cmd : T .Dict [str , T .Any ]) -> None :
0 commit comments