bazel-contrib / rules_foreign_cc

Build rules for interfacing with "foreign" (non-Bazel) build systems (CMake, configure-make, GNU Make, boost, ninja, Meson)
https://bazel-contrib.github.io/rules_foreign_cc
Apache License 2.0
673 stars 248 forks source link

Build ninja from source if prebuilt binary is absent for a platform #1019

Open dmkurilov opened 1 year ago

dmkurilov commented 1 year ago

The problem

ninja's prebuilt binaries are available for a limited number of platforms.

For example, if you pick a linux_aarch64, you'll get an error:

No matching toolchains found for types @rules_foreign_cc~0.9.0//toolchains:ninja_toolchain

How to reproduce

Please, take a look at https://github.com/bazelbuild/rules_foreign_cc/issues/1018, section "How to reproduce".

Expected behavour

ninja is built from source if there is no binary for a platform.

jsharpe commented 1 year ago

I think this is just that the bzlmod MODULE.bazel file doesn't register the built ninja toolchain by default. You should be able to register the toolchain in your root MODULE.bazel file to work around this.

tkekan commented 3 weeks ago

@jsharpe Sorry can you please provide some details on how to work around this ? I'm facing similar issue wherein a third-party ( libevent) which is a transitive dependency is being built using the cmake rule. But this complains about unable to find toolchain since I'm building this on OL8 arm64 docker running on Apple silicon.

third-party/rules_libevent/BUILD:26:6: While resolving toolchains for target //third-party/rules_libevent:event (47d3177): No matching toolchains found for types @@rules_foreign_cc~//toolchains:ninja_toolchain.