我看到已经有一个讨论这个话题的话题了,但是有点含糊:
Can I instruct bazel to emit a ".elf" suffix to executables?
不幸的是,这对我的情况没有帮助。我正在尝试使用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的方法,我尝试记录各种类型的文档,但无法使其正常工作。
有人可以指出我正确的方向吗?
谢谢!
答案 0 :(得分:2)
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
来直接构建文件目标。