已合并
[feat] add asc_compile_exporter #4980
sjtulxh创建于 8月10日
[feat] add asc_compile_exporter #4980
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 sjtulxh 的贡献)atomgit-bot
8月10日 评论:
8月10日 评论:
变更摘要
本次 PR 新增 asc_compile_exporter 命令行工具,用于递归收集指定目录下的 *_manifest.json 及其关联资源文件,通过代码生成、编译、链接等步骤,输出一个可被 dlopen 动态加载的编译资源共享库(.so)。该工具包含完整的请求校验、路径安全检查(符号链接拒绝、目录深度限制、资源大小上限)、临时工作目录管理和原子发布机制,并接入了 AscendC 工具日志接口。同时更新了 CMake 构建依赖、asc-devkit 打包清单和版本软链接脚本,确保工具正确交付。
主要改动
- 新增
asc_compile_exporterCLI 入口与整体编排:asc_compile_exporter.cpp提供--make、--cxx、--keep-temp、--jobs等命令行参数解析;ManifestBundleCompiler串联请求校验、Manifest 加载、源码生成、make构建和原子发布全流程 - 新增 Manifest 发现与资源收集模块:
CollectedManifestRepository递归遍历目录发现*_manifest.json,解析 JSON 中的base_dir,加载资源文件并按路径排序;内置ResourceBudget对资源数量、文件数、总大小进行容量限制 - 新增 Bundle 源码生成器:
BundleSourceGenerator在临时工作区生成 ABI 头文件(ascendc_manifest_abi.h)、每个 Manifest 对应的 C++ 翻译单元、汇总compile_resource_bundle.cpp和Makefile,将资源二进制数据嵌入为静态字节数组 - 新增原子发布与跨文件系统支持:
BundlePublisher优先使用rename实现同文件系统原子替换,失败时回退到先复制再rename的跨文件系统策略,同时拒绝输出路径为符号链接 - 新增公共工具类与包装更新:
FileUtils封装路径拼合、目录创建/遍历/删除、文件读写、独占输出等文件操作;ProcessRunner封装fork/execv子进程管理、超时终止和进程组回收;更新asc-devkit.xml打包清单和软链接脚本以纳入asc_compile_exporter工具


不准确?
atomgit-bot
8月10日 评论:
8月10日 评论:
8月10日 添加了label:cann-cla/yes
CANN-robot
8月10日 评论:
8月10日 评论:
Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| cmake | ✅ 诸葛洵, XuebinYang (2/2) | ✅ 诸葛洵 (1/1) |
| repo-cann/asc-devkit | ✅ XuebinYang, 诸葛洵 (2/2) | ✅ XuebinYang, 诸葛洵 (2/1) |
| scripts | ✅ 诸葛洵, XuebinYang (2/2) | ✅ 诸葛洵 (1/1) |
| tools/aclrtc | ✅ 诸葛洵, XuebinYang, YANXI_ZHAO (3/2) | ✅ YANXI_ZHAO (1/1) |
| tools/build | ✅ XuebinYang, 诸葛洵 (2/2) | ✅ XuebinYang (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
sjtulxh, thanks for your pull request. All authors of the commits have signed the CLA. 👍


此处折叠了284条消息 查看更多
8月13日 通过审查
8月13日 通过了评审
YANXI_ZHAO
8月13日 评论:
8月13日 评论:
/lgtm
/approve


8月13日 添加了label:approved
8月13日 合入了pull request
描述
新增
asc_compile_exporter工具,用于收集指定目录下的 Manifest JSON 及相关资源,并将其导出为可动态加载的编译资源共享库。主要改动:
新增
asc_compile_exporter命令行工具及 Manifest Bundle 生成模块。支持指定包 ID、Manifest 搜索目录、输出路径、工作目录、并行任务数及临时目录保留选项。
增加路径合法性、符号链接、资源数量和资源大小等安全检查。
接入 AscendC 工具日志接口。
增加 CMake 构建、安装及 JSON 三方库依赖。
更新 asc-devkit 打包清单和版本目录软链接处理。
新增模块单元测试和完整导出流程测试,并接入测试集合。
ManifestBundleCompiler
|
+--> CollectedManifestRepository 发现并加载 Manifest
+--> BuildWorkspace 管理临时构建目录
+--> BundleSourceGenerator 生成 ABI、Manifest 源码和 Makefile
+--> MakeBundleBuilder 调用编译器构建 SO
+--> BundlePublisher 原子发布最终 SO
manifest_bundle_compiler.cpp:请求校验、任务数计算和整体流程编排,目标控制在约 100 行。manifest_bundle_types.h:保存内部 DTOResourceFile、ManifestUnit,不安装、不暴露为公共 API。CollectedManifestRepository:Manifest 发现、JSONbase_dir读取、资源递归加载、排序和容量限制;ResourceBudget保留为其.cpp内部实现。BundleSourceGenerator:生成 ABI 头、Manifest 翻译单元、Bundle 汇总源码和 Makefile。BuildWorkspace:负责私有临时目录的创建、移动语义、--keep-temp和 RAII 清理。MakeBundleBuilder:查找make/编译器、构造环境变量并启动构建;原ExecutableLocator收敛为其.cpp私有函数,不再保留独立类。ProcessRunner:封装fork/execv、超时、进程组终止和退出状态处理。BundlePublisher:输出软链接检查、同文件系统 rename 和跨文件系统安全发布关联的Issue
无。
测试
asc_compile_exporter生产目标,构建通过。ascendc_ut_asc_compile_exporter。git diff --check,通过。文档更新
无文档更新。
类型标签