构建后重命名 bazel 输出(扩展名)

Rename bazel output (extension) after build

我看到有一个帖子已经对此进行了讨论,但有点含糊:

不幸的是,这对我的情况没有帮助。我正在尝试使用 Bazel 在 windows 上为 Autodesk Maya 编译插件,因此我的输出需要是具有自定义扩展名 .mll.dll 文件。这是我的 BUILD 文件设置方式的示例代码:

cc_binary(
    name = "myPlugin.dll",  # can't rename this to .mll, otherwise bazel won't build
    srcs = glob(
        [
            "myPlugin.h",
            "myPlugin.cpp",
        ]
    ),
    deps = [
        "@maya_repo//:Foundation",
        "@maya_repo//:OpenMaya",
    ],
    linkopts = [
        "-export:initializePlugin",
        "-export:uninitializePlugin",
    ],
    linkshared = True,
)

一切都可以编译,但我似乎找不到将扩展名重命名为 .mll 的方法,我尝试在 genrules 上进行记录,但我无法让它工作。

有人能给我指出正确的方向吗?

genrule(
   name = "plugin_mll",
   srcs = ["myPlugin.dll"],
   outs = ["myPlugin.mll"],
   cmd = "cp $(location myPlugin.dll) $(location myPlugin.mll)",
)

或使用 Make 变量:

genrule(
   name = "plugin_mll",
   srcs = ["myPlugin.dll"],
   outs = ["myPlugin.mll"],
   cmd = "cp $< $@",
)

然后 运行 bazel build //path/to/package:plugin_mll 调用 genrule,或 bazel build //path/to/package:myPlugin.mll 直接构建文件目标。