Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] Using BazelDeps with conan center recipes #17112

Open
1 task done
BuildMonkey opened this issue Oct 3, 2024 · 4 comments
Open
1 task done

[question] Using BazelDeps with conan center recipes #17112

BuildMonkey opened this issue Oct 3, 2024 · 4 comments
Assignees

Comments

@BuildMonkey
Copy link

What is your question?

Hello,

I am looking at Bazel as a potential build system. We also use conan, with some of our packages coming from conan center. I noticed that conan can build the BUILD.bazel files for a conan package using BazelDeps, but it seems one has to adjust the conan recipe to include BazelDeps.

I was wondering if there is another alternative to generating the BUILD.bazel files without customising the recipes. This would allow us to continue to use the conan center recipes without having to keep local copies to include BazelDeps.

Thanks!

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded memsharded self-assigned this Oct 3, 2024
@memsharded
Copy link
Member

Hi @BuildMonkey

Thanks for your question.

The files that BazelDeps generate are just the files to locate the dependencies, but it is still necessary to write the necessary build files for the current project.

So moving a package from a build system like CMake to Bazel requires both changing CMakeDeps->BazelDeps, but also to rewrite the build scripts for Bazel. So there is no other way than doing modifications to the current recipe and project, not only to change to Conan generator.

@BuildMonkey
Copy link
Author

Thanks for responding so quickly.

If I understand your explanation correctly, it is not our intention to adjust the third-party dependencies, such as boost, to convert to bazel. We would like to use boost in our current project with bazel as the build system. It seems from the documentation (https://docs.conan.io/2/reference/tools/google/bazeldeps.html) we have to place BazelDeps in the boost recipe to generate the BUILD.bazel file. We would like to avoid this and continue to leverage the boost recipe in conan center.

Is there a way to keep building boost through the conan center recipe while also having it generate a BUILD.bazel file for boost for us to use in our current project?

@franramirez688
Copy link
Contributor

Hi @BuildMonkey

It seems from the documentation (https://docs.conan.io/2/reference/tools/google/bazeldeps.html) we have to place BazelDeps in the boost recipe to generate the BUILD.bazel file. We would like to avoid this and continue to leverage the boost recipe in conan center.

You don't need to rewrite all the third-party dependencies to use BazelDeps or any other XXXDeps generator. Sorry if the documentation is not clear enough, but the documentation explains an example of a consumer using BazelDeps to bring all their dependencies.

For instance, let's imagine that you want to see how looks like the boost BUILD.bazel file created by Conan (and all the other Conan files needed to consume it):

$ conan install --requires=boost/1.86.0 -g BazelDeps -of my-folder --build=missing

This command creates a local folder my-folder where Conan saves all the files and folders created to help the users consume boost. Then, you'll also see the my-folder/boost/BUILD.bazel file.

That would be mostly the same as creating a conanfile.txt and run conan install . --build=missing to install locally all the third-party dependencies. For instance:

conanfile.txt

[requires]
boost/1.86.0

[generators]
BazelDeps
BazelToolchain

[layout]
bazel_layout

If you want to see a complete example of how to use Bazel in your local project:

@BuildMonkey
Copy link
Author

The CLI option is great! This lets us continue to use the external recipe without customisations. I'll give this a try. Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants