improve directory scanning in mpir_config.py

This commit is contained in:
Brian Gladman 2019-11-02 20:59:12 +00:00
parent a7bb30d339
commit 1b98ce86b0

View File

@ -5,9 +5,9 @@ Copyright (C) 2011, 2012, 2013, 2014 Brian Gladman
''' '''
from operator import itemgetter from operator import itemgetter
from os import listdir, walk, unlink, makedirs, sep from os import scandir, walk, unlink, makedirs
from os.path import split, splitext, isdir, relpath, join, exists from os.path import join, split, splitext, isdir, exists
from os.path import join, abspath, dirname, normpath, split from os.path import dirname, abspath, relpath, realpath
from copy import deepcopy from copy import deepcopy
from sys import argv, exit, path from sys import argv, exit, path
from filecmp import cmp from filecmp import cmp
@ -27,7 +27,7 @@ if len(argv) > 1:
solution_name = 'mpir.sln' solution_name = 'mpir.sln'
build_dir_name = 'vs{0:d}'.format(vs_version) build_dir_name = 'vs{0:d}'.format(vs_version)
build_root_dir = dirname(__file__) build_root_dir = dirname(realpath(__file__))
mpir_root_dir, build_root_name = split(build_root_dir) mpir_root_dir, build_root_name = split(build_root_dir)
solution_dir = join(build_root_dir, build_dir_name) solution_dir = join(build_root_dir, build_dir_name)
@ -179,11 +179,11 @@ def find_src(dir_list):
di = {'.h': 0, '.c': 1, '.cc': 2, '.cpp': 2, '.asm': 3, '.as': 3} di = {'.h': 0, '.c': 1, '.cc': 2, '.cpp': 2, '.asm': 3, '.as': 3}
list = [[], [], [], []] list = [[], [], [], []]
for d in dir_list: for d in dir_list:
for f in listdir(join(mpir_root_dir, d)): for f in scandir(join(mpir_root_dir, d)):
if f == '.svn': if f == '.svn':
continue # ignore SVN directories continue # ignore SVN directories
if not isdir(f): if not isdir(f):
n, x = splitext(f) # split into name + extension n, x = splitext(f.name) # split into name + extension
if x in di and not n in exclude_file_list: if x in di and not n in exclude_file_list:
list[di[x]] += [(n, x, d)] # if of the right type and is list[di[x]] += [(n, x, d)] # if of the right type and is
for x in list: # not in the exclude list for x in list: # not in the exclude list