13
13
from .ast .interpreter import IntrospectionBuildTarget , IntrospectionDependency , _symbol
14
14
from .interpreterbase import UnknownValue , TV_func
15
15
from .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
17
17
from . import mlog , environment
18
18
from functools import wraps
19
19
from .mparser import Token , ArrayNode , ArgumentNode , ArithmeticNode , AssignmentNode , BaseNode , StringNode , BooleanNode , ElementaryNode , IdNode , FunctionNode , PlusAssignmentNode
@@ -951,15 +951,6 @@ def rel_source(src: str) -> str:
951
951
952
952
# Sort files
953
953
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
-
963
954
if isinstance (i , FunctionNode ) and i .func_name .value in BUILD_TARGET_FUNCTIONS :
964
955
src_args = i .args .arguments [1 :]
965
956
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]]]]:
968
959
target_name = []
969
960
unknown : T .List [BaseNode ] = [x for x in src_args if not isinstance (x , StringNode )]
970
961
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 ))
972
963
i .args .arguments = target_name + unknown + T .cast (T .List [BaseNode ], sources )
973
964
974
965
def process (self , cmd : T .Dict [str , T .Any ]) -> None :
0 commit comments