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] Compatibility with bazel 7.0 #15363

Closed
1 task done
marlamb opened this issue Dec 30, 2023 · 9 comments · Fixed by #16196
Closed
1 task done

[question] Compatibility with bazel 7.0 #15363

marlamb opened this issue Dec 30, 2023 · 9 comments · Fixed by #16196
Assignees
Milestone

Comments

@marlamb
Copy link
Contributor

marlamb commented Dec 30, 2023

Hi! I have a question regarding the compatibility of conan with bazel. I tried to make my first steps following this guide, which works fine for bazel 6.2.0, but fails for me using bazel 7.0.0 at the build step with the following error message:

❯ bazel --bazelrc=./conan/conan_bzl.rc build --config=conan-config //main:demo
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
WARNING: --enable_bzlmod is set, but no MODULE.bazel file was found at the workspace root. Bazel will create an empty MODULE.bazel file. Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. For more details, please refer to https://github.com/bazelbuild/bazel/issues/18958.
ERROR: /tmp/examples2/examples/tools/google/bazeltoolchain/string_formatter/WORKSPACE:2:24: //external:fmt: invalid label '/tmp/examples2/examples/tools/google/bazeltoolchain/string_formatter/conan/fmt/BUILD.bazel' in attribute 'build_file' in 'new_local_repository' rule: invalid target name '/tmp/examples2/examples/tools/google/bazeltoolchain/string_formatter/conan/fmt/BUILD.bazel': target names may not start with '/'
WARNING: Target pattern parsing failed.
ERROR: Skipping '//main:demo': error loading package 'main': Encountered error while reading extension file 'cc/defs.bzl': no such package '@@rules_cc//cc': error loading package 'external': Could not load //external package
ERROR: error loading package 'main': Encountered error while reading extension file 'cc/defs.bzl': no such package '@@rules_cc//cc': error loading package 'external': Could not load //external package
INFO: Elapsed time: 4.572s
INFO: 0 processes.
ERROR: Build did NOT complete successfully

Getting rid of the warning by passing --noenable_bzlmod does not solve the errors and I have now two questions:

  • Is is possible (or planned) to support the bzlmod mode of bazel within the generated files? As it is the new default it looks worthwhile to me.
  • How to get rid of the error? Are some adaptions within the generated files necessary? Or do you think it is also in the long-term favorable to have some special configuration for bazel (which I don't know, yet...)?

For both it would be great, depending on your preferred solution, to update the linked guide above.

Thanks in advance!

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded
Copy link
Member

Hi @marlamb

Thanks for your question.
Yes, it is true that the current integration is designed for Bazel 6, and does not support yet Bazel 7.
I think we will want to support it at some point, but I am assigning @franramirez688 for feedback, estimation of what would need to be done, etc.

@franramirez688
Copy link
Contributor

Hi @marlamb

Thanks for the question. I am so glad to see you involved in testing the BazelDeps generator 👏

I just tried the Bazel hello-world example (https://bazel.build/start/cpp), and it's not working for Bazel v7.0.0 yet. IMO, I think it's worth waiting for those Bazel examples to be updated to see the changes we should make in the conan new templates before trying anything else.

Anyway, do you have any other Hello-World example working with Bazel 7.0.0?

@marlamb
Copy link
Contributor Author

marlamb commented Jan 8, 2024

Hi @franramirez688

Unfortunately I don't have further examples. I am completely new to bazel and therefore just out of ignorance chose the newest version to start with. I am totally fine with waiting a little until it becomes clearer how the new version should be handled. Until then I will learn it with version 6. I am looking forward to your future developments and will try out version 7 as soon as I see that conan supports it as well 😃 .

@destinydesigner
Copy link

Same issue. Looking forward to seeing the Bazel 7 support. 😄

@peakschris
Copy link

The lack of bazel 7 support has started to impact us, as we are now all-in on bazel 7 and are aiming for 100% module based builds. So I have fixed up the cpp-example to work with bazel 7 and conan in the hope that it will make it easier for you all to support bazel 7.

Here it is: https://github.com/peakschris/bazel7-conan-module-example

The readme explains what is going on. I've taken the same approach used by rules_dotnet, wrapping the repo file in a module extension. I'm not sure that this is the best approach, but it is one approach, and it works.

My repo requires bazel 7.2.0rc2, but prior versions can be supported by un-including the conan.MODULE.bazel file and moving its contents into the main MODULE.bazel file. Using the include statement makes for cleaner MODULE files, but is a brand new feature.

I will also start a conversation on the Bazel issues page to get some inputs into this structure and see if that community has any ideas.

@peakschris
Copy link

bazelbuild/bazel#22594

@memsharded
Copy link
Member

Hi all,

This is the PR that you want to track and test if possible: #16196

It is ready to be merged for next Conan 2.4 release, to be released soon. Early feedback over that PR very welcome!

@peakschris
Copy link

@memsharded @franramirez688 and @Neeeflix thank you! Amazing to see that so much work has been done on this :-). Is there a way I can grab a windows executable containing the PR to test?

@memsharded
Copy link
Member

You can run from source with (from https://github.com/conan-io/conan?tab=readme-ov-file#setup)

  • git clone the project
  • move to the folder cloned
  • fetch and checkout the branch with the source of the PR
  • pip install -e .

Then your conan will be pointing to the source code of that specific branch

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

Successfully merging a pull request may close this issue.

5 participants