兼容主项目路径名称问题
This commit is contained in:
parent
6310730b16
commit
e7056dfbf1
@ -30,7 +30,7 @@ class IntegratedPipeline:
|
||||
self.docs_path = "" # Docs 项目路径
|
||||
self.main_project_path = "" # Unity 主项目路径
|
||||
|
||||
# 获取当前工具所在的项目根目录(thrift-related)
|
||||
# 获取当前工具所在的项目根目录(自动检测:IntegratedTool -> PythonWorkSpace -> 项目根目录)
|
||||
if getattr(sys, 'frozen', False):
|
||||
# exe 模式
|
||||
self.tool_root = Path(sys.executable).parent.parent.parent
|
||||
@ -90,7 +90,7 @@ class IntegratedPipeline:
|
||||
paths['cfg_json'] = str(docs_root / "tool" / "cfg" / "cfg_txt.json")
|
||||
paths['config_dir'] = str(docs_root / "config")
|
||||
|
||||
# thrift-related 相关路径(相对路径)
|
||||
# 工具项目相关路径(相对于项目根目录)
|
||||
paths['compiler'] = str(self.tool_root / "compiler" / "exe" / "thrift.exe")
|
||||
paths['thrift_dir'] = str(self.tool_root / "thrift-files" / "meowment")
|
||||
paths['csharp_output_dir'] = str(self.tool_root / "compiled_output" / "csharp")
|
||||
@ -200,7 +200,7 @@ class IntegratedPipeline:
|
||||
preview_lines.append(f" * Config 目录 (xlsx): {paths.get('config_dir', '未配置')}")
|
||||
preview_lines.append("")
|
||||
|
||||
preview_lines.append("[thrift-related 项目相关路径 (相对路径)]")
|
||||
preview_lines.append("[工具项目相关路径 (相对路径)]")
|
||||
preview_lines.append(f" * Thrift 编译器: {paths.get('compiler', '')}")
|
||||
preview_lines.append(f" * Thrift 文件目录: {paths.get('thrift_dir', '')}")
|
||||
preview_lines.append(f" * C# 输出目录: {paths.get('csharp_output_dir', '')}")
|
||||
@ -246,7 +246,7 @@ class IntegratedPipeline:
|
||||
report_lines.append("="*100)
|
||||
report_lines.append(" Thrift 流程执行简报")
|
||||
report_lines.append("="*100)
|
||||
report_lines.append(f"执行时间: {self.report['start_time']} → {self.report['end_time']}")
|
||||
report_lines.append(f"执行时间: {self.report['start_time']} -> {self.report['end_time']}")
|
||||
report_lines.append("")
|
||||
|
||||
# 统计总体状态
|
||||
@ -332,9 +332,9 @@ class IntegratedPipeline:
|
||||
if len(value) > 0:
|
||||
# 特殊处理 failed_files - 显示完整错误信息
|
||||
if key == 'failed_files' and value and isinstance(value[0], dict):
|
||||
report_lines.append(f"❌ 失败详情 ({len(value)} 项):")
|
||||
report_lines.append(f"[FAIL] 失败详情 ({len(value)} 项):")
|
||||
for item in value:
|
||||
report_lines.append(f" • {item['name']}")
|
||||
report_lines.append(f" - {item['name']}")
|
||||
report_lines.append(f" 错误: {item['error']}")
|
||||
if 'detail' in item:
|
||||
# 显示堆栈前10行
|
||||
@ -348,20 +348,20 @@ class IntegratedPipeline:
|
||||
elif key in ['success_files', 'files']:
|
||||
report_lines.append(f"[OK] 成功文件 ({len(value)} 项):")
|
||||
for item in value:
|
||||
report_lines.append(f" • {item}")
|
||||
report_lines.append(f" - {item}")
|
||||
|
||||
# 跳过的文件列表
|
||||
elif key == 'skipped':
|
||||
if value:
|
||||
report_lines.append(f"→ 跳过文件 ({len(value)} 项):")
|
||||
report_lines.append(f"[SKIP] 跳过文件 ({len(value)} 项):")
|
||||
for item in value:
|
||||
report_lines.append(f" • {item}")
|
||||
report_lines.append(f" - {item}")
|
||||
|
||||
# 其他列表
|
||||
elif key not in ['success', 'failed', 'total', 'count', 'deleted', 'expected']:
|
||||
report_lines.append(f"{key} ({len(value)} 项):")
|
||||
for item in value:
|
||||
report_lines.append(f" • {item}")
|
||||
report_lines.append(f" - {item}")
|
||||
|
||||
# 非列表值(跳过已显示的统计值)
|
||||
elif key not in ['success', 'failed', 'total', 'count', 'deleted', 'expected', 'error']:
|
||||
@ -369,7 +369,7 @@ class IntegratedPipeline:
|
||||
|
||||
# 显示错误信息
|
||||
if 'error' in details:
|
||||
report_lines.append(f"❌ 错误信息: {details['error']}")
|
||||
report_lines.append(f"[ERROR] 错误信息: {details['error']}")
|
||||
|
||||
report_lines.append("")
|
||||
report_lines.append("")
|
||||
@ -381,27 +381,27 @@ class IntegratedPipeline:
|
||||
|
||||
paths = self.get_derived_paths()
|
||||
|
||||
report_lines.append("📁 基础路径:")
|
||||
report_lines.append(f" • Docs 项目: {self.docs_path}")
|
||||
report_lines.append(f" • Unity 主项目: {self.main_project_path}")
|
||||
report_lines.append("[基础路径]")
|
||||
report_lines.append(f" - Docs 项目: {self.docs_path}")
|
||||
report_lines.append(f" - Unity 主项目: {self.main_project_path}")
|
||||
report_lines.append("")
|
||||
|
||||
report_lines.append("📁 Docs 派生路径:")
|
||||
report_lines.append(f" • cfg_txt.json: {paths.get('cfg_json', '')}")
|
||||
report_lines.append(f" • Config 目录: {paths.get('config_dir', '')}")
|
||||
report_lines.append("[Docs 派生路径]")
|
||||
report_lines.append(f" - cfg_txt.json: {paths.get('cfg_json', '')}")
|
||||
report_lines.append(f" - Config 目录: {paths.get('config_dir', '')}")
|
||||
report_lines.append("")
|
||||
|
||||
report_lines.append("📁 thrift-related 派生路径 (相对路径):")
|
||||
report_lines.append(f" • Thrift 编译器: {paths.get('compiler', '')}")
|
||||
report_lines.append(f" • Thrift 文件目录: {paths.get('thrift_dir', '')}")
|
||||
report_lines.append(f" • C# 输出目录: {paths.get('csharp_output_dir', '')}")
|
||||
report_lines.append(f" • Bytes 输出目录: {paths.get('bytes_output_dir', '')}")
|
||||
report_lines.append("[工具项目派生路径 (相对路径)]")
|
||||
report_lines.append(f" - Thrift 编译器: {paths.get('compiler', '')}")
|
||||
report_lines.append(f" - Thrift 文件目录: {paths.get('thrift_dir', '')}")
|
||||
report_lines.append(f" - C# 输出目录: {paths.get('csharp_output_dir', '')}")
|
||||
report_lines.append(f" - Bytes 输出目录: {paths.get('bytes_output_dir', '')}")
|
||||
report_lines.append("")
|
||||
|
||||
report_lines.append("📁 Unity 派生路径:")
|
||||
report_lines.append(f" • Unity C# 目录: {paths.get('unity_csharp_dir', '')}")
|
||||
report_lines.append(f" • Unity Bytes 目录: {paths.get('unity_bytes_dir', '')}")
|
||||
report_lines.append(f" • DR 生成目录: {paths.get('dr_output_dir', '')}")
|
||||
report_lines.append("[Unity 派生路径]")
|
||||
report_lines.append(f" - Unity C# 目录: {paths.get('unity_csharp_dir', '')}")
|
||||
report_lines.append(f" - Unity Bytes 目录: {paths.get('unity_bytes_dir', '')}")
|
||||
report_lines.append(f" - DR 生成目录: {paths.get('dr_output_dir', '')}")
|
||||
report_lines.append("="*100)
|
||||
|
||||
return "\n".join(report_lines)
|
||||
@ -412,27 +412,27 @@ class IntegratedPipeline:
|
||||
|
||||
# 验证基础路径
|
||||
if not self.docs_path:
|
||||
errors.append("❌ 请选择 Docs 项目路径")
|
||||
errors.append("[X] 请选择 Docs 项目路径")
|
||||
|
||||
if not self.main_project_path:
|
||||
errors.append("❌ 请选择 Unity 主项目路径")
|
||||
errors.append("[X] 请选择 Unity 主项目路径")
|
||||
|
||||
# 获取派生路径并验证
|
||||
paths = self.get_derived_paths()
|
||||
|
||||
if self.docs_path:
|
||||
if 'cfg_json' in paths and not os.path.exists(paths['cfg_json']):
|
||||
errors.append(f"❌ cfg_txt.json 文件不存在: {paths['cfg_json']}")
|
||||
errors.append(f"[X] cfg_txt.json 文件不存在: {paths['cfg_json']}")
|
||||
|
||||
if 'config_dir' in paths and not os.path.exists(paths['config_dir']):
|
||||
errors.append(f"❌ Config 目录不存在: {paths['config_dir']}")
|
||||
errors.append(f"[X] Config 目录不存在: {paths['config_dir']}")
|
||||
|
||||
# 验证 thrift-related 相关路径
|
||||
# 验证工具项目相关路径
|
||||
if not os.path.exists(paths.get('compiler', '')):
|
||||
errors.append(f"❌ Thrift 编译器不存在: {paths.get('compiler', '')}")
|
||||
errors.append(f"[X] Thrift 编译器不存在: {paths.get('compiler', '')}")
|
||||
|
||||
if not os.path.exists(paths.get('thrift_dir', '')):
|
||||
errors.append(f"❌ Thrift 文件目录不存在: {paths.get('thrift_dir', '')}")
|
||||
errors.append(f"[X] Thrift 文件目录不存在: {paths.get('thrift_dir', '')}")
|
||||
|
||||
if errors:
|
||||
error_msg = "\n".join(errors)
|
||||
@ -557,7 +557,7 @@ class IntegratedPipeline:
|
||||
excel_path = os.path.join(self.config_dir, in_file)
|
||||
|
||||
if not os.path.exists(excel_path):
|
||||
self.log(f" ⚠ Excel 不存在: {in_file}\n")
|
||||
self.log(f" [WARN] Excel 不存在: {in_file}\n")
|
||||
continue
|
||||
|
||||
# 读取 Excel 获取字段和注释
|
||||
@ -689,7 +689,7 @@ class IntegratedPipeline:
|
||||
|
||||
# 调试信息:记录未知类型
|
||||
if type_str and type_str not in type_mapping:
|
||||
self.log(f" ⚠ 未知类型 '{types[idx]}' (字段: {header}),使用默认类型 string\n")
|
||||
self.log(f" [WARN] 未知类型 '{types[idx]}' (字段: {header}),使用默认类型 string\n")
|
||||
|
||||
# 获取注释
|
||||
comment = comments[idx] if idx < len(comments) and comments[idx] else ""
|
||||
@ -850,7 +850,7 @@ class IntegratedPipeline:
|
||||
self.log(f" 找到 {len(file_list)} 个配置项\n\n")
|
||||
|
||||
# 注意:现在只生成 AllConfigs.bytes,不生成单个配置的 bytes 文件
|
||||
self.log(f" ℹ 新策略:只生成 AllConfigs.bytes(合并文件),跳过单个 bytes 文件生成\n\n")
|
||||
self.log(f" [INFO] 新策略:只生成 AllConfigs.bytes(合并文件),跳过单个 bytes 文件生成\n\n")
|
||||
|
||||
# 收集所有成功处理的配置对象,用于生成 AllConfigs
|
||||
for idx, config_item in enumerate(file_list, 1):
|
||||
@ -861,7 +861,7 @@ class IntegratedPipeline:
|
||||
|
||||
# 检查配置完整性(原始:检查所有必需项)
|
||||
if not all([in_file, out_file, sheet_name, coloum_types]):
|
||||
self.log(f" [{idx}/{len(file_list)}] ⚠ 配置项不完整,跳过: {in_file}\n\n")
|
||||
self.log(f" [{idx}/{len(file_list)}] [WARN] 配置项不完整,跳过: {in_file}\n\n")
|
||||
continue
|
||||
|
||||
struct_name = out_file.replace('.txt', '')
|
||||
@ -1038,9 +1038,9 @@ class IntegratedPipeline:
|
||||
|
||||
# 最终统计
|
||||
if allconfigs_generated:
|
||||
self.log(f"\n✅ 生成完成: AllConfigs.bytes(包含 {success_count} 个配置)\n")
|
||||
self.log(f"\n[OK] 生成完成: AllConfigs.bytes(包含 {success_count} 个配置)\n")
|
||||
else:
|
||||
self.log(f"\n❌ 生成失败\n")
|
||||
self.log(f"\n[FAIL] 生成失败\n")
|
||||
|
||||
self.add_step_report("生成Bytes文件", "success", {
|
||||
"success": success_count,
|
||||
@ -1172,7 +1172,7 @@ class IntegratedPipeline:
|
||||
|
||||
self.log(f" 源目录: {self.bytes_output_dir}\n")
|
||||
self.log(f" 目标目录: {self.unity_bytes_dir}\n")
|
||||
self.log(f" ℹ 只复制 AllConfigs.bytes\n\n")
|
||||
self.log(f" [INFO] 只复制 AllConfigs.bytes\n\n")
|
||||
|
||||
# 只复制 AllConfigs.bytes
|
||||
allconfigs_file = 'AllConfigs.bytes'
|
||||
@ -1191,7 +1191,7 @@ class IntegratedPipeline:
|
||||
other_bytes = [f for f in os.listdir(self.bytes_output_dir)
|
||||
if f.endswith('.bytes') and f != allconfigs_file]
|
||||
if other_bytes:
|
||||
self.log(f"\n ℹ 发现 {len(other_bytes)} 个其他 bytes 文件(已废弃,不复制):\n")
|
||||
self.log(f"\n [INFO] 发现 {len(other_bytes)} 个其他 bytes 文件(已废弃,不复制):\n")
|
||||
for f in other_bytes:
|
||||
self.log(f" - {f}\n")
|
||||
|
||||
@ -1223,7 +1223,7 @@ class IntegratedPipeline:
|
||||
self.add_step_report("清理临时文件", "success", {})
|
||||
|
||||
except Exception as e:
|
||||
self.log(f" ⚠ 清理失败: {str(e)}\n")
|
||||
self.log(f" [WARN] 清理失败: {str(e)}\n")
|
||||
self.add_step_report("清理临时文件", "failed", {"error": str(e)})
|
||||
|
||||
def step8_generate_dr(self) -> bool:
|
||||
@ -1268,7 +1268,7 @@ class IntegratedPipeline:
|
||||
properties = self.parse_item_class(item_file_path)
|
||||
|
||||
if not properties:
|
||||
self.log(f" ⚠ 没有找到属性\n")
|
||||
self.log(f" [WARN] 没有找到属性\n")
|
||||
continue
|
||||
|
||||
# 生成 DR 代码
|
||||
|
||||
Loading…
Reference in New Issue
Block a user