MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / check_files

Function check_files

tools/ci/bsp_detail.py:62–124  ·  view source on GitHub ↗
(root_dir, file_list)

Source from the content-addressed store, hash-verified

60
61# 这个函数通过检查文件是否存在来检查bsp的支持情况
62def check_files(root_dir, file_list):
63 data = []
64 folders_checked = set()
65
66 for projects in sconstruct_paths:
67 found_arch = False # Flag to track if ARCH has been found
68 found_cpu = False # Flag to track if ARCH has been found
69 if projects not in folders_checked:
70 #file_dict = {file: True if os.path.isfile(os.path.join(projects, file)) else '' for file in file_list}
71 file_dict = {}
72 for file in file_list:
73 file_exists = os.path.isfile(os.path.join(projects, file))
74 if file == 'template.uvprojx':
75 file_dict['mdk5'] = True if file_exists else False
76 elif file == 'template.ewp':
77 file_dict['iar'] = True if file_exists else False
78 elif file == 'template.uvproj':
79 file_dict['mdk4'] = True if file_exists else False
80 elif file == 'template.Uv2':
81 file_dict['mdk3'] = True if file_exists else False
82 elif file == 'Kconfig':
83 file_dict['menuconfig'] = True if file_exists else False
84 else:
85 file_dict[file] = True if file_exists else False
86
87 # 提取 rtconfig.py 中的 PREFIX 信息
88 rtconfig_path = os.path.join(projects, 'rtconfig.py')
89 if os.path.isfile(rtconfig_path):
90 print(f"Reading {rtconfig_path}")
91 with open(rtconfig_path, 'r') as f:
92 for line in f:
93 if not found_arch and line.strip().startswith('ARCH'):
94 arch_value = line.split('=')[1].strip().strip("'\"")
95 file_dict['arch'] = f"{arch_value}"
96 print(f"Found ARCH: {arch_value} in {rtconfig_path}")
97 found_arch = True # Set the flag to True
98
99 # 解析CPU属性
100 if not found_cpu and line.strip().startswith('CPU'):
101 cpu_value = line.split('=')[1].strip().strip("'\"")
102 file_dict['cpu'] = f"{cpu_value}"
103 print(f"Found CPU: {cpu_value} in {rtconfig_path}")
104 found_cpu = True
105
106 if line.strip().startswith('PREFIX'):
107 prefix_value = line.split('=')[1].strip().strip("'\"")
108 # 只提取实际的编译器前缀
109 if 'os.getenv' in prefix_value:
110 prefix_value = prefix_value.split('or')[-1].strip().strip("'\"")
111 file_dict['gcc'] = f"{prefix_value}gcc"
112 print(f"Found PREFIX: {prefix_value} in {rtconfig_path}")
113 break
114 else:
115 print(f"No PREFIX found in {rtconfig_path}")
116
117 # 去掉路径中的 '/workspaces/rt-thread/bsp/' 部分
118 projects2 = projects.replace(root_dir + '/', '')
119 file_dict['Folder'] = projects2

Callers 1

bsp_detail.pyFile · 0.85

Calls 3

setFunction · 0.50
openFunction · 0.50
joinMethod · 0.45

Tested by

no test coverage detected