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
661 stars 241 forks source link

legacy dependency macro fails to set up transitive dependencies #1286

Open oliverlee opened 2 weeks ago

oliverlee commented 2 weeks ago
ERROR: Skipping '@symengine': error loading package '@@symengine//': at /private/var/tmp/_bazel_oliver/e888b1acfe919fa909be3f7123974edb/external/rules_foreign_cc/foreign_cc/defs.bzl:3:6: at /private/var/tmp/_bazel_oliver/e888b1acfe919fa909be3f7123974edb/external/rules_foreign_cc/foreign_cc/boost_build.bzl:5:5: at /private/var/tmp/_bazel_oliver/e888b1acfe919fa909be3f7123974edb/external/rules_foreign_cc/foreign_cc/private/framework.bzl:5:6: at /private/var/tmp/_bazel_oliver/e888b1acfe919fa909be3f7123974edb/external/bazel_features/features.bzl:3:6: Unable to find package for @@bazel_features_globals//:globals.bzl: The repository '@@bazel_features_globals' could not be resolved: Repository '@@bazel_features_globals' is not defined.

bazel_features is pulled in here: https://github.com/bazelbuild/rules_foreign_cc/blob/b25485b26d6ddf6be8bde2bc0c651b1a06ebe54c/foreign_cc/repositories.bzl#L86-L92

But I don't see (a second macro for) bazel_features_deps: https://github.com/bazel-contrib/bazel_features/blob/main/deps.bzl which in turn sets up these: https://github.com/bazel-contrib/bazel_features/blob/main/private/repos.bzl

aaron-michaux commented 2 weeks ago

The code below is a workaround; however, @oliverlee , do you think rules_foreign_cc_dependencies() itself should be calling bazel_feature_deps()?

load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")

rules_foreign_cc_dependencies()

load("@bazel_features//:deps.bzl", "bazel_features_deps")

bazel_features_deps()
jsharpe commented 2 weeks ago

rules_foreign_cc_dependencies() can't do it as it defines the repository; we'd have to add an additional workspace macro to do that setup. I think the best we can do is update the documentation to include the bazel_features setup as I don't think we need to be introducing a new workspace macro at this point given the future is bzlmod.

oliverlee commented 2 weeks ago

I think either two macros or a note in the README is fine.