I wish to build disk images for an esoteric computing platform (CP/M, if you're interested!) with bazel.
Having looked at the documentation for doing cross-compilation with bazel, it looks like it's set up for the case where the project can compile for any platform, and you don't know what platform you're compiling on until you invoke bazel (the platform is passed in on the command line).
I don't have this situation. My code can only build for this platform, and I cannot cross-compile normal code on it. It needs a single very specific toolchain which is not at all gcc-like. This makes, as far as I can tell, most of bazel's toolchain selection logic useless to me. I should be able to do something with Skylark transition rules, but I'm finding the documentation very heavy going.
What I desperately want to do is this:
cc_binary(
name = "some_host_binary",
srcs = [...]
)
cc_binary(
name = "some_target_binary",
srcs = [...],
...some property here to generate a target binary...
)
genrule(
name = "output_artifact",
data = [":some_host_binary", ":some_target_binary"]
)
Confusingly, the page on toolchains describes a compiler
attribute on cc_binary
which looks like it's precisely what I want, but it seems that this doesn't actually exist and is only there as an example?
If, instead, I want to rely on bazel's automatic toolchain resolution, then I think that I need to be able to specify the platform for some_target_binary
to force it to pick the right toolchain; but I feel like this would just cause a build failure as the genrule
can't tell that I want the two dependencies to be binaries for different architectures.
I'm beginning to feel that I'm grossly overthinking this. Any suggestions, and preferably examples?