Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 35 additions & 19 deletions tools/targets/eclipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
MODULE_VER_NUM = 6

source_pattern = ['*.c', '*.cpp', '*.cxx', '*.cc', '*.s', '*.S', '*.asm','*.cmd']
# Source control metadata directories should not be recursively scanned.
scm_metadata_dirs = ('.git', '.svn', '.hg')


def OSPath(path):
Expand Down Expand Up @@ -94,16 +96,19 @@ def CollectAllFilesinPath(path, pattern):
for item in pattern:
files += glob.glob(path + '/' + item)

list = os.listdir(path)
if len(list):
for item in list:
if item.startswith('.'):
items = os.listdir(path)
if len(items):
for item in items:
# Do not recursively scan source control metadata.
if item in scm_metadata_dirs:
continue
if item == 'bsp':
continue

if os.path.isdir(os.path.join(path, item)):
files = files + CollectAllFilesinPath(os.path.join(path, item), pattern)
fullpath = os.path.join(path, item)
if os.path.isdir(fullpath):
files = files + CollectAllFilesinPath(fullpath, pattern)

return files


Expand All @@ -127,17 +132,20 @@ def ExcludePaths(rootpath, paths):

files = os.listdir(OSPath(rootpath))
for file in files:
if file.startswith('.'):
continue

fullname = os.path.join(OSPath(rootpath), file)

if os.path.isdir(fullname):
# print(fullname)
if not fullname in paths:
ret = ret + [fullname]
# Source control metadata should always be excluded directly.
if file in scm_metadata_dirs:
ret.append(fullname)
continue

# Hidden directories must follow the same exclusion rules
# as normal directories.
if fullname not in paths:
ret.append(fullname)
else:
ret = ret + ExcludePaths(fullname, paths)
ret.extend(ExcludePaths(fullname, paths))
Comment on lines +145 to +148

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果 BSP 自身是 Git 仓库,CollectPaths() 会把根目录下的 .git 加入 all_paths,这里便进入递归。随后候选路径变成 .git/objects,无法命中新增的 .git 名称判断,仍会扫描整个对象库。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 已做修复进行排除


return ret

Expand Down Expand Up @@ -426,16 +434,24 @@ def GenExcluding(env, project):

paths = exclude_paths
exclude_paths = []
# remove the folder which not has source code by source_pattern

# Remove folders which do not contain source files matching source_pattern.
for path in paths:
# add bsp and libcpu folder and not collect source files (too more files)
# Add bsp and libcpu directly and do not collect source files
# because these trees contain too many files.
if path.endswith('rt-thread\\bsp') or path.endswith('rt-thread\\libcpu'):
exclude_paths += [path]
exclude_paths.append(path)
continue

# Source control metadata is never part of the target build and may
# contain a very large number of files, so do not recursively scan it.
if os.path.basename(os.path.normpath(path)) in scm_metadata_dirs:
exclude_paths.append(path)
continue

set = CollectAllFilesinPath(path, source_pattern)
if len(set):
exclude_paths += [path]
files = CollectAllFilesinPath(path, source_pattern)
if len(files):
exclude_paths.append(path)

exclude_paths = [RelativeProjectPath(env, path).replace('\\', '/') for path in exclude_paths]

Expand Down
Loading