2

I see there's a thread where this has been discussed already, but a bit vaguely:

Can I instruct bazel to emit a ".elf" suffix to executables?

Unfortunately that doesn't help in my case. I am trying to compile plugins for Autodesk Maya on windows using Bazel, so my output needs to be a .dll file with custom extension .mll. Here's an example code of how my BUILD file is setup:

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,
)

Everything compiles, but I can't seem to find a way to rename the extension to .mll, I tried documenting on genrules but I couldn't make it work.

Could someone point me in the right direction?

Vertexwahn
  • 7,709
  • 6
  • 64
  • 90
mdilena
  • 55
  • 1
  • 6

1 Answers1

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

or with the Make variables:

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

and then run bazel build //path/to/package:plugin_mll to invoke the genrule, or bazel build //path/to/package:myPlugin.mll to build the file target directly.

Jin
  • 12,748
  • 3
  • 36
  • 41
  • thanks for your answer! However I think I have another issue to solve before I can get it working: currently myPlugin.dll outputs three files, basically it copies .dll files from Maya that it depends on (OpenMaya.dll, Foundation.dll) other than generating my output. So when I do cp `($location myPlugin.dll)` it says that there are multiple outputs, but I can't find a way to tell Bazel to avoid putting those extra libs in there. Is that possible? – mdilena Sep 02 '18 at 09:07
  • 2
    Ha, found out what the problem was, I had to use `tools = [":myPlugin.dll"]` to make it work, so that it won't consider the external libraries. Thanks a lot for your help! – mdilena Sep 02 '18 at 20:18