构建在 commit 607dcd3 失败。
Commit Message:
Fixed cross-platform file copy in Bazel rule (#118)
工作总结
已成功修复 rename_files.bzl 规则中的跨平台兼容性问题。具体更改如下:
问题分析
原规则在第31-38行使用 Windows 特定的 cmd /c copy 命令进行文件复制,这导致在 Linux/macOS
系统上构建失败。
解决方案
- 添加平台检测机制:使用
ctx.target_platform_has_constraint() 检测当前操作系统是否为
Windows
- 跨平台复制策略:
- Windows 系统:使用
cmd 的 copy 命令
- Unix-like 系统:使用
cp 命令
- 路径处理优化:保留 Windows 系统下的反斜杠路径转换,确保
copy 命令正常工作
代码变更
- rule/rename_files.bzl:14-53:重构
_rename_files_impl
函数,添加平台检测和跨平台复制逻辑
- rule/rename_files.bzl:62-64:添加
_windows_constraint 属性,引用
@platforms//os:windows 约束
技术细节
- 使用
ctx.actions.run_shell() 替代原有的 ctx.actions.run() 调用
- 通过
platform_common.ConstraintValueInfo 获取平台约束信息
- 保持原有的
mnemonic 和 progress_message 不变
- 文件路径使用双引号包裹,确保包含空格的文件名能正确处理
验证
- 通过
bazelisk query '//rule/...' 验证规则加载正常
- 创建提交
🐛 fix: use cross-platform file copy in rename_files rule 记录变更
此修复确保了构建系统在 Windows、Linux 和 macOS 平台上的完全兼容性,同时保持了原有的功能和行为。
Closes #112

opencode
session | github
run
查看失败的构建
构建日志片段
Extracting Bazel installation...
Starting local Bazel server (8.4.1) and connecting to it...
INFO: Invocation ID: f07d7d84-316b-4350-8b66-01c1d164ccff
Computing main repo mapping:
Loading:
Loading: 0 packages loaded
Loading: 0 packages loaded
ERROR: /home/runner/work/E1epack/E1epack/rule/datapack.bzl:603:31: name '_ALL_MINECRAFT_VERSIONS' is not defined (did you mean 'ALL_MINECRAFT_VERSIONS'?)
WARNING: Target pattern parsing failed.
ERROR: Skipping '//...': error loading package under directory '': error loading package 'subprojects/stone-disappearance': compilation of module 'rule/datapack.bzl' failed
ERROR: error loading package under directory '': error loading package 'subprojects/stone-disappearance': compilation of module 'rule/datapack.bzl' failed
INFO: Elapsed time: 5.521s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
FAILED:
构建在 commit 607dcd3 失败。
Commit Message:
Fixed cross-platform file copy in Bazel rule (#118)
工作总结
已成功修复
rename_files.bzl规则中的跨平台兼容性问题。具体更改如下:问题分析
原规则在第31-38行使用 Windows 特定的
cmd /c copy命令进行文件复制,这导致在 Linux/macOS系统上构建失败。
解决方案
ctx.target_platform_has_constraint()检测当前操作系统是否为Windows
cmd的copy命令cp命令copy命令正常工作代码变更
_rename_files_impl函数,添加平台检测和跨平台复制逻辑
_windows_constraint属性,引用@platforms//os:windows约束技术细节
ctx.actions.run_shell()替代原有的ctx.actions.run()调用platform_common.ConstraintValueInfo获取平台约束信息mnemonic和progress_message不变验证
bazelisk query '//rule/...'验证规则加载正常🐛 fix: use cross-platform file copy in rename_files rule记录变更此修复确保了构建系统在 Windows、Linux 和 macOS 平台上的完全兼容性,同时保持了原有的功能和行为。
Closes #112
opencode
session | github
run
查看失败的构建
构建日志片段