添加普冉 PY32F040 OTA 双工程代码生成模板

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-18 18:59:56 +08:00
co-authored by Cursor
commit 331864dc64
496 changed files with 329040 additions and 0 deletions
+66
View File
@@ -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)