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

How use bazel-gazelle in cpp project? #910

Open
roderick-liu opened this issue Sep 18, 2020 · 13 comments
Open

How use bazel-gazelle in cpp project? #910

roderick-liu opened this issue Sep 18, 2020 · 13 comments
Labels

Comments

@roderick-liu
Copy link

hi
It is a very useful tool in golang project. Does it been used in cpp project?

@jayconrod
Copy link
Contributor

There's no native support for C++, but you could write an extension (see https://github.com/bazelbuild/bazel-gazelle/blob/master/extend.rst).

@HALtheWise
Copy link
Contributor

@roderick-liu I may be working on a C++ Gazelle extension soon, if you are interested in collaborating.

@dhanna11
Copy link

dhanna11 commented Oct 7, 2020

Is it possible to get some info about any c/c++ build file generation that Google already has? I’ve seen references to an unsupported “googlify” script that you can run on code checked into third_party.

I suspect a c++ extension won’t be remotely as straightforward as Go’s build system was heavily influenced by Blaze 😰

@roderick-liu
Copy link
Author

roderick-liu commented Dec 10, 2020

@HALtheWise

hi
Do you want to build tools for c++?

@dhanna11
Copy link

@nnWhisperer
Copy link

Hello, I came here after seeing a recent BazelCon video, https://www.youtube.com/watch?v=ol5hwjr48Q4 where the presenters share that they added gazelle rules for c++ and hence facilitated developers' overheads in their project, which is great. I searched online but couldn't proceed further. Are there any updates on this thread, i.e. have you managed to proceed? Thanks

@disdi
Copy link

disdi commented Feb 12, 2023

Any update on C++ Support?

@pieknik
Copy link

pieknik commented Jun 19, 2023

@disdi @HALtheWise @roderick-liu My team is interested in the c++ extension as well. Would anyone be interested in a collaboration? If so I'll submit a new issue saying we'll (attempt to) add it

@albertocavalcante
Copy link

Is there any place where I can find more about ongoing efforts on this?

Gazelle for C++ would be great. If anyone already started working on it I'd love to take look.

@pieknik
Copy link

pieknik commented Oct 5, 2023

hey alberto our team actually went ahead and created a decent mvp for c++, Going to start working with my company to OSS the solution - we've gotten pretty efficient so it shouldn't take long

@mpatou
Copy link

mpatou commented Oct 10, 2023

Hey @pieknik can you publish your MVP somewhere ? I would be curious to see if/how it works.

@lpulley
Copy link

lpulley commented Jan 10, 2024

I found that video too, @nnWhisperer, and I had the same question. @pieknik have you had any luck getting the MVP open-sourced?

michael-christen added a commit to michael-christen/toolbox that referenced this issue Jan 22, 2024
Changes:
- Establish a mechanism for defining external python requirements via a
`requirements.in`, generating updates to a lock file with `bazel run
//:requirements.update`
- Configure gazelle python  and protobufs
- Configures via gazelle directives to use a file based approach, stick
with the BUILD configuration, disable go, default visibility to private
and resolve py imports
- Update dev_setup to install openjdk (java), tree, ranger, ag

New Commands:
```
bazel run //:requirements.update
bazel run //:gazelle_python_manifest.update
bazel run //:gazelle
```

New Tests:
```
//:requirements_test
//::gazelle_python_manifest.test
```

Notes:
- One of the recurring issues I have every time I deal with updating
WORKSPACE is slight incompatibilities with various repos that result in
incomprehensible output errors.
- stackb/rules_proto is one of the only things that seems to support
what I'm looking for, and while it is getting steady contributions
hasn't pubilshed a release in about a year.
https://github.com/rules-proto-grpc/rules_proto_grpc. Additionally, it
could be handy to look into what it would take to make my own "shitty"
version of these rules to learn more about what's going on in gazelle's
/ bazel's internals
- bzlmod migration didn't go well for me, most tutorials out there still
use WORKSPACE, might be good to look into in the future / figure out how
to migrate piecemeal, but bypassed this and 7.0.1 bazel upgrade for now

Related Issues:
- Noting the issue with requiring a gazelle directive for proto
libraries: bazelbuild/rules_python#1703
- bazelbuild/rules_python#1664 fixes the reason
I had to "disable" my py_binary, wait for that to release and then
update. I could probably patch this in, but don't quite know how 🤷
- Sounds like there's some talk around gazelle c++
bazel-contrib/bazel-gazelle#910
- I'm helping ;) bazelbuild/rules_python#1712
(doc update)

References:
- https://github.com/bazelbuild/bazel-gazelle
- https://github.com/stackb/rules_proto
- https://github.com/bazelbuild/rules_python/tree/main/gazelle

Future Things to Look Into:
- Setup a gazelle test that checks output of `//:gazelle -- -mode diff`
is zero
- Configure rust with gazelle: https://github.com/Calsign/gazelle_rust
- A really cool / general parser / generator (what github uses for
"semantic" tool): https://tree-sitter.github.io/tree-sitter/ Could use
to make small code generator / modification? Or maybe more general
utilities?
- General compile command completion:
https://github.com/hedronvision/bazel-compile-commands-extractor
- Maybe play with https://github.com/rules-proto-grpc/rules_proto_grpc
as an alternative to stackb
- If I can't use gazelle for some things, mess around with
https://github.com/bazelbuild/buildtools/tree/master/buildozer
@peakschris
Copy link

@pieknik +1 :-)

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

No branches or pull requests