Skip to content

Commit ad6ea0f

Browse files
ZhaoCakeRbb666
authored andcommitted
[fix] not ignore notes in
1 parent 21414e8 commit ad6ea0f

File tree

1 file changed

+33
-45
lines changed

1 file changed

+33
-45
lines changed

tools/mkdist.py

Lines changed: 33 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# Change Logs:
2121
# Date Author Notes
2222
# 2017-10-04 Bernard The first version
23+
# 2025-01-07 ZhaoCake components copy and gen doc
2324

2425
import os
2526
import subprocess
@@ -93,7 +94,7 @@ def walk_kconfig(RTT_ROOT, source_list):
9394
def bsp_copy_files(bsp_root, dist_dir):
9495
# copy BSP files
9596
do_copy_folder(os.path.join(bsp_root), dist_dir,
96-
ignore_patterns('build', 'dist', '*.pyc', '*.old', '*.map', 'rtthread.bin', '.sconsign.dblite', '*.elf', '*.axf', 'cconfig.h'))
97+
ignore_patterns('build','__pycache__','dist', '*.pyc', '*.old', '*.map', 'rtthread.bin', '.sconsign.dblite', '*.elf', '*.axf', 'cconfig.h'))
9798

9899
def bsp_update_sconstruct(dist_dir):
99100
with open(os.path.join(dist_dir, 'SConstruct'), 'r') as f:
@@ -172,9 +173,9 @@ def zip_dist(dist_dir, dist_name):
172173
zip.close()
173174

174175
def get_system_features():
175-
"""获取系统内置特性列表"""
176+
"""Get system built-in feature list"""
176177
return {
177-
# 内核特性
178+
# Kernel features
178179
'components_init',
179180
'console',
180181
'cpu_usage_tracer',
@@ -202,7 +203,7 @@ def get_system_features():
202203
}
203204

204205
def parse_components_from_config(config_file):
205-
""".config 文件解析启用的组件"""
206+
"""Parse enabled components from .config file"""
206207
enabled_components = set()
207208

208209
if not os.path.exists(config_file):
@@ -212,26 +213,30 @@ def parse_components_from_config(config_file):
212213
with open(config_file, 'r') as f:
213214
for line in f:
214215
line = line.strip()
216+
# Skip empty lines and comments
217+
if not line or line.startswith('#'):
218+
continue
219+
215220
if line.startswith('CONFIG_'):
216221
if '=' in line:
217-
config = line.split('=')[0][7:] # 去掉 CONFIG_ 前缀
222+
config = line.split('=')[0][7:] # Remove CONFIG_ prefix
218223
if config.startswith('RT_USING_'):
219-
component = config[9:].lower() # 去掉 RT_USING_ 前缀
224+
component = config[9:].lower() # Remove RT_USING_ prefix
220225
enabled_components.add(component)
221226
return enabled_components
222227

223228
def scan_components_dir(RTT_ROOT):
224-
"""扫描组件目录结构,生成组件映射表"""
229+
"""Scan component directory structure and generate component mapping"""
225230
components_map = {}
226231
components_root = os.path.join(RTT_ROOT, 'components')
227232

228233
def parse_kconfig(kconfig_file):
229-
"""解析 Kconfig 文件中的配置选项"""
234+
"""Parse configuration options from Kconfig file"""
230235
components = set()
231236
try:
232237
with open(kconfig_file, 'r') as f:
233238
content = f.read()
234-
# 查找 config RT_USING_XXX 形式的配置
239+
# Find configurations in the form of config RT_USING_XXX
235240
import re
236241
matches = re.finditer(r'config\s+RT_USING_(\w+)', content)
237242
for match in matches:
@@ -242,25 +247,25 @@ def parse_kconfig(kconfig_file):
242247
return components
243248

244249
def get_relative_path(full_path):
245-
"""获取相对于 RTT_ROOT 的路径"""
250+
"""Get path relative to RTT_ROOT"""
246251
return os.path.relpath(os.path.dirname(full_path), RTT_ROOT)
247252

248-
# 扫描所有组件目录
253+
# Scan all component directories
249254
for root, dirs, files in os.walk(components_root):
250255
if 'Kconfig' in files:
251256
kconfig_path = os.path.join(root, 'Kconfig')
252257
component_configs = parse_kconfig(kconfig_path)
253258
rel_path = get_relative_path(kconfig_path)
254259

255-
# 将组件名称与路径关联
260+
# Associate component names with paths
256261
for comp_name in component_configs:
257262
components_map[comp_name] = rel_path
258263

259264
return components_map
260265

261266
def get_component_path(component_name, RTT_ROOT):
262-
"""获取组件的实际路径"""
263-
# 获取动态组件映射
267+
"""Get actual path of component"""
268+
# Get dynamic component mapping
264269
dynamic_map = scan_components_dir(RTT_ROOT)
265270
return dynamic_map.get(component_name)
266271

@@ -355,16 +360,16 @@ def generate_dist_doc(dist_dir, enabled_components, project_name, BSP_ROOT, RTT_
355360
print(f"=> Generated distribution documentation: {doc_file}")
356361

357362
def components_copy_files(RTT_ROOT, rtt_dir_path, config_file):
358-
"""根据配置复制组件"""
363+
"""Copy components based on configuration"""
359364
print('=> components (selective copy)')
360365

361-
# 获取启用的组件
366+
# Get enabled components
362367
enabled_components = parse_components_from_config(config_file)
363368
if not enabled_components:
364369
print("Warning: No components found in config file")
365370
return enabled_components
366371

367-
# 复制每个启用的组件
372+
# Copy each enabled component
368373
for comp_name in enabled_components:
369374
comp_path = get_component_path(comp_name, RTT_ROOT)
370375
if comp_path:
@@ -390,73 +395,56 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env, project_name, project_path):
390395

391396
rtt_dir_path = os.path.join(dist_dir, 'rt-thread')
392397

393-
# copy BSP files
398+
# Copy BSP files
394399
print('=> %s' % os.path.basename(BSP_ROOT))
395400
bsp_copy_files(BSP_ROOT, dist_dir)
396401

397-
# do bsp special dist handle
402+
# Do BSP special dist handle
398403
if 'dist_handle' in Env:
399404
print("=> start dist handle")
400405
dist_handle = Env['dist_handle']
401406
dist_handle(BSP_ROOT, dist_dir)
402407

403-
# 使用新的组件复制函数并获取启用的组件列表
408+
# Use new component copy function and get list of enabled components
404409
config_file = os.path.join(BSP_ROOT, '.config')
405410
enabled_components = components_copy_files(RTT_ROOT, rtt_dir_path, config_file)
406411

407-
# skip documentation directory
408-
# skip examples
412+
# Skip documentation directory
413+
# Skip examples
409414

410-
# copy include directory
415+
# Copy include directory
411416
print('=> include')
412417
do_copy_folder(os.path.join(RTT_ROOT, 'include'), os.path.join(rtt_dir_path, 'include'))
413418

414-
# copy all libcpu/ARCH directory
419+
# Copy all libcpu/ARCH directory
415420
print('=> libcpu')
416421
import rtconfig
417422
do_copy_folder(os.path.join(RTT_ROOT, 'libcpu', rtconfig.ARCH), os.path.join(rtt_dir_path, 'libcpu', rtconfig.ARCH))
418423
do_copy_file(os.path.join(RTT_ROOT, 'libcpu', 'Kconfig'), os.path.join(rtt_dir_path, 'libcpu', 'Kconfig'))
419424
do_copy_file(os.path.join(RTT_ROOT, 'libcpu', 'SConscript'), os.path.join(rtt_dir_path, 'libcpu', 'SConscript'))
420425

421-
# copy src directory
426+
# Copy src directory
422427
print('=> src')
423428
do_copy_folder(os.path.join(RTT_ROOT, 'src'), os.path.join(rtt_dir_path, 'src'))
424429

425-
# copy tools directory
430+
# Copy tools directory
426431
print('=> tools')
427432
do_copy_folder(os.path.join(RTT_ROOT, 'tools'), os.path.join(rtt_dir_path, 'tools'), ignore_patterns('*.pyc'))
428433

434+
# Copy necessary files
429435
do_copy_file(os.path.join(RTT_ROOT, 'Kconfig'), os.path.join(rtt_dir_path, 'Kconfig'))
430436
do_copy_file(os.path.join(RTT_ROOT, 'AUTHORS'), os.path.join(rtt_dir_path, 'AUTHORS'))
431437
do_copy_file(os.path.join(RTT_ROOT, 'COPYING'), os.path.join(rtt_dir_path, 'COPYING'))
432438
do_copy_file(os.path.join(RTT_ROOT, 'README.md'), os.path.join(rtt_dir_path, 'README.md'))
433439
do_copy_file(os.path.join(RTT_ROOT, 'README_zh.md'), os.path.join(rtt_dir_path, 'README_zh.md'))
434440

435441
print('Update configuration files...')
436-
# change RTT_ROOT in SConstruct
437442
bsp_update_sconstruct(dist_dir)
438-
# change RTT_ROOT in Kconfig
439443
bsp_update_kconfig(dist_dir)
440444
bsp_update_kconfig_library(dist_dir)
441-
# delete testcases in Kconfig
442445
bsp_update_kconfig_testcases(dist_dir)
443446

444-
target_project_type = GetOption('target')
445-
if target_project_type:
446-
child = subprocess.Popen('scons --target={} --project-name="{}"'.format(target_project_type, project_name), cwd=dist_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
447-
stdout, stderr = child.communicate()
448-
if child.returncode == 0:
449-
print(stdout)
450-
else:
451-
print(stderr)
452-
else:
453-
print('suggest to use command scons --dist [--target=xxx] [--project-name="xxx"] [--project-path="xxx"]')
454-
455-
# make zip package
456-
if project_path == None:
457-
zip_dist(dist_dir, project_name)
458-
459-
# 生成说明文档
447+
# Generate documentation
460448
generate_dist_doc(dist_dir, enabled_components, project_name+'-dist', BSP_ROOT, RTT_ROOT)
461449

462450
print('dist project successfully!')

0 commit comments

Comments
 (0)