添加普冉 PY32F040 OTA 双工程代码生成模板
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""验证共享层结构:uvprojx XML 合法性 + 所有 FilePath/IncludePath 相对解析存在。"""
|
||||
import os, sys, re, xml.etree.ElementTree as ET
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
PROJS = [
|
||||
('App', 'MDK-ARM/project.uvprojx', 'App'),
|
||||
('Bootloader', 'MDK-ARM/Bootloader.uvprojx', 'Bootloader'),
|
||||
]
|
||||
|
||||
ok = True
|
||||
for name, rel, proj in PROJS:
|
||||
p = os.path.join(ROOT, proj, rel)
|
||||
d = os.path.dirname(p)
|
||||
print('===== %s (%s) =====' % (name, rel))
|
||||
# 1) XML 合法性
|
||||
try:
|
||||
tree = ET.parse(p)
|
||||
print(' XML: 合法')
|
||||
except Exception as e:
|
||||
print(' XML: 非法 -> %s' % e)
|
||||
ok = False
|
||||
continue
|
||||
# 2) FilePath 存在性
|
||||
missing = []
|
||||
for fp in tree.iter('FilePath'):
|
||||
v = fp.text or ''
|
||||
if not v.strip():
|
||||
continue
|
||||
full = os.path.normpath(os.path.join(d, v))
|
||||
if not os.path.isfile(full):
|
||||
missing.append(v)
|
||||
print(' FilePath: %d 个,缺失 %d 个' % (
|
||||
len(list(tree.iter('FilePath'))), len(missing)))
|
||||
for m in missing[:10]:
|
||||
print(' MISSING: %s' % m)
|
||||
ok = False
|
||||
# 3) IncludePath 存在性(目录)
|
||||
inc_missing = []
|
||||
for ip in tree.iter('IncludePath'):
|
||||
v = ip.text or ''
|
||||
for seg in v.split(';'):
|
||||
if not seg.strip():
|
||||
continue
|
||||
full = os.path.normpath(os.path.join(d, seg))
|
||||
if not os.path.isdir(full):
|
||||
inc_missing.append(seg)
|
||||
print(' IncludePath 段: 缺失 %d 个' % len(inc_missing))
|
||||
for m in inc_missing[:10]:
|
||||
print(' MISSING: %s' % m)
|
||||
ok = False
|
||||
# 4) 是否引用对方工程(除 Shared/Drivers 外)
|
||||
cross = []
|
||||
for fp in tree.iter('FilePath'):
|
||||
v = fp.text or ''
|
||||
low = v.lower()
|
||||
if ('..\\..\\' in low) and ('shared' not in low) and ('drivers' not in low):
|
||||
cross.append(v)
|
||||
print(' 跨工程引用(非 Shared/Drivers): %d 个' % len(cross))
|
||||
for c in cross[:10]:
|
||||
print(' CROSS: %s' % c)
|
||||
if cross:
|
||||
ok = False
|
||||
|
||||
print('\n%s' % ('=== 全部通过 ✓ ===' if ok else '=== 存在缺失 ✗ ==='))
|
||||
sys.exit(0 if ok else 1)
|
||||
Reference in New Issue
Block a user