Skip to content

607dcd3 构建失败 #129

@github-actions

Description

@github-actions

构建在 commit 607dcd3 失败。

Commit Message:
Fixed cross-platform file copy in Bazel rule (#118)

工作总结

已成功修复 rename_files.bzl 规则中的跨平台兼容性问题。具体更改如下:

问题分析

原规则在第31-38行使用 Windows 特定的 cmd /c copy 命令进行文件复制,这导致在 Linux/macOS
系统上构建失败。

解决方案

  1. 添加平台检测机制:使用 ctx.target_platform_has_constraint() 检测当前操作系统是否为
    Windows
  2. 跨平台复制策略
    • Windows 系统:使用 cmdcopy 命令
    • Unix-like 系统:使用 cp 命令
  3. 路径处理优化:保留 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 获取平台约束信息
  • 保持原有的 mnemonicprogress_message 不变
  • 文件路径使用双引号包裹,确保包含空格的文件名能正确处理

验证

  • 通过 bazelisk query '//rule/...' 验证规则加载正常
  • 创建提交 🐛 fix: use cross-platform file copy in rename_files rule 记录变更

此修复确保了构建系统在 Windows、Linux 和 macOS 平台上的完全兼容性,同时保持了原有的功能和行为。

Closes #112

New%20session%20-%202026-01-24T17%3A05%3A28.653Z
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: 

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions