cc_binary(
name = "bin",
deps = ["lib-a"],
)
cc_library(
name = "lib-a",
deps = ["lib-b"],
)
cc_library(
name = "lib-b",
deps = ["lib-c"],
)
cc_library(
name = "lib-c",
) cc_binary(
name = "bin",
deps = ["lib-a"], replace("lib-b", "lib-b-stub"), # Is something like this possible?
) cc_binary(
name = "bin",
deps = ["lib-a"],
)Hi Marcel,Thanks for your answer! However, I don't think it will solve my issue.
I was a bit unclear in my first post. I don't want to replace a direct dependency, but a transitive dependency.
In my example we had this cc_binary:
cc_binary(
name = "bin",
deps = ["lib-a"],
)
and the following transitive dependencies: lib-a -> lib-b -> lib-c.
I don't want to replace the dependency to "lib-a". Instead I want to replace a cc_library further down in the dependency chain, like "lib-b" or "lib-c".I suppose the answer is "No, this is not possible". Do you think that this is a feature that we should add to Bazel? If the community accepts this new feature, a group from my company can implement it.BR,Magnus2017-08-28 12:46 GMT+02:00 Marcel Hlopko <hlo...@google.com>:Hi Magnus,You cannot do it in the same way as you were used to right now. What you need is to have multiple configurations in a single build, and that is work in progress (it's a complex problem to make it scale). But if you can live with two separate bazel invocations, you can make it work using select:config_setting(name = "mocked_deps",values = {"define": "mocked_deps=true"})cc_binary(name = "main",srcs = [ "main.cc" ],deps = select({":mocked_deps": [":mocked"],"//conditions:default": ["real_dep"]}),)cc_library(name = "mocked",srcs = [ "mocked.cc" ],)cc_library(name = "real_dep",srcs = [ "real_dep.cc" ],)If you run bazel with:bazel build :main --define=mocked_deps=truethe mocked dep is used. If you just run:bazel build :mainit will use real dependencies.Is this what you were trying to accomplish?
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/c2212e76-6634-4b4c-91b9-17f298c8fcd3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--Marcel Hlopko----Marcel Hlopko | Software Engineer | hlo...@google.com |Google Germany GmbH | Erika-Mann-Str. 33 | 80636 München | Germany | Geschäftsführer: Geschäftsführer: Paul Manicle, Halimah DeLaine Prado | Registergericht und -nummer: Hamburg, HRB 86891
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/e424774f-7eda-4170-8d90-229588339954%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/8b9e4770-daee-4f2f-9b8f-558c60914980%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.