已合并
refactor(build): consolidate common build infrastructure #5247
refactor(build): consolidate common build infrastructure #5247
已合并
XuebinYang创建于 8月21日
XuebinYang成员
8月21日

修改内容

  • 将 pack、register、specialization 重复使用的进程执行能力提取到 tools/build/common
  • 将临时目录创建与生命周期管理提取为公共 RAII 能力
  • 迁移 aclrtc specialization 与 asc_compile_exporter,删除不再使用的旧实现
  • 增加中文详细设计和实施文档

验证

  • ACLRTC UT:184/184 通过
  • asc_compile_exporter UT:70/70 通过
  • acl_rtc 生产构建通过
  • 变更文件格式、OAT、codespell 检查通过
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 XuebinYang 的贡献)
XXuebinYang成员
8月21日 创建了 pull request,commit fc75030b
atomgit-bot
atomgit-bot
8月21日 评论:

变更摘要

本 PR 旨在整合构建基础设施:将 pack、register、specialization 等流程中重复使用的进程执行能力与临时目录管理能力抽取到公共模块 tools/build/common,新增 ProcessExecutor(及其 ProcessExecutionRequest/ProcessExecutionResult、ProcessOutputMode、ProcessTermination 类型)取代旧的 ProcessRunner,新增 RAII 类 TemporaryDirectory 取代旧的 BuildWorkspace;同时将 aclrtc specialization 与 asc_compile_exporter 迁移到上述公共能力并删除不再使用的旧实现,并补充中文详细设计与实施文档。

主要改动

  • 新增公共进程执行能力 ProcessExecutor:在 tools/build/common/process_executor.h/cpp 中新增 ProcessExecutor::Execute,支持环境变量覆盖与移除、输出继承或合并捕获(ProcessOutputMode::Inherit/CaptureCombined)、执行超时、终止宽限期与输出字节上限,并通过 ProcessExecutionResult::HasSuccessfulExit()、GetTerminationName() 返回结构化结果;同时删除旧实现 process_runner.cpp。
  • 新增 RAII 临时目录 TemporaryDirectory:在 tools/build/common/temporary_directory.h/cpp 中新增 TemporaryDirectory,提供 CreateUniqueUnder、AdoptExistingForCleanup、RemoveNow、RetainAfterDestruction 及移动语义,统一负责临时目录的创建、私有权限(S_IRWXU)与生命周期清理;删除 tools/build/asc_compile_exporter/build_workspace.cpp 中的旧 BuildWorkspace。
  • aclrtc specialization 迁移到公共能力:compilation_plan_executor.cpp 删除约 549 行内联的子进程 spawn、输出排空与进程组终止逻辑,改用 ProcessExecutor::Execute 并通过 MapProcessResultToCompilationError 映射为编译/链接错误码;kernel_specialization_types.h 移除 CompilationProcessTermination 与 CompilationProcessResult 类型,kernel_compilation_workspace.cpp 与 resource_registry.cpp 改用 TemporaryDirectory 管理 worktree 与临时根目录(引入 retainMaterializedDirectories_ 保留策略)。
  • asc_compile_exporter 迁移到公共能力:manifest_bundle_compiler.cpp 改用 ProcessExecutor 执行 make 构建(30 分钟超时、移除 MAKEFLAGS/MFLAGS/MAKEFILES/GNUMAKEFLAGS 环境变量、输出继承模式),并用 TemporaryDirectory 替代 BuildWorkspace 管理构建与发布工作目录。
  • 测试同步更新:删除 test_build_workspace.cpp 与 test_process_runner.cpp,新增 test_temporary_directory.cpp 与 test_process_executor.cpp,并将 test_compilation_plan_executor.cpp、test_kernel_specialization_diagnostics.cpp、test_kernel_specialization_session.cpp、test_resource_registry.cpp、test_asc_compile_exporter.cpp 等用例迁移到新的 ProcessExecutionResult/ProcessTermination/TemporaryDirectory 接口。
likedislike
不准确?
atomgit-bot
atomgit-bot
8月21日 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
8月21日 添加了label:stat/needs-squash
CANN-robotCANN-robot成员
8月21日 添加了label:cann-cla/yes
此处折叠了105条消息 查看更多
YYANXI_ZHAO成员
8月25日 通过审查
YYANXI_ZHAO成员
8月25日 通过了评审
YANXI_ZHAO成员
8月25日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
8月25日 添加了label:lgtmapproved
CANN-robotCANN-robot成员
8月25日 合入了pull request