4 ms·
What's the option if I want to learn Bazel to an intermediate level and I don't work with former Googlers? There's a decent number of Hello World examples arou
by dijit 2y ago
What's the option if I want to learn Bazel to an intermediate level and I don't work with former Googlers?
There's a decent number of Hello World examples around, and I can get moving with some rulesets, but using it for more than toy projects seems to be really hard for me and there's not a lot of intermediate content from what I can tell. There's "Advanced" reference materials, and countless "getting started" tutorials, but rarely is there anything relating to best practices or even what constitutes good rules.
Seems like most of the hobby community prefers NIX for deterministic builds too, so the situation is not improving for novices like myself who really like the idea of hermitic builds, monorepo's and distributed cache.
- shaftway 2y agoMost Google engineers don't do anything more complicated than the hello world examples. Probably far less complicated because they don't need to do any repo setup, it all just works out of the box. Most engineers just make simple java build targets. Larger teams would have someone who specializes in tweaking the build and writes Skylark rules, but to other engineers they just look like simple build targets. I'd suggest finding an open source project and playing with it locally. Try to get everything building and running, including unit tests. Make the build as granular as you can. Try to pick a project that has a variety of kinds of things that need to be built, like Java, C++, Protobufs, etc. Then look for patterns in the build targets you wrote and see if you can refactor them to simplify it with custom Skylark rules.
- shaftway 2y ago> but to other engineers they just look like simple build targets. I forgot to mention, this is by design. It is uncommon at Google for a BUILD file to be more than 3 or 4 build targets. Maybe someone will add a for loop to the build so that they can define various flavors of the build easily, but that's it. Anything more complicated and it should be extracted to a separate Skylark file, included, and in the BUILD file it should look like a basic task.
- mbarr 2y agoSelenium has a pretty good Bazel setup which uses a lot of different functionality: https://github.com/SeleniumHQ/selenium/ https://github.com/SeleniumHQ/selenium/
- zeroDivisible 2y agoYou can check some open source projects (envoy is the one I know) which are using it. The bigger projects are fun way to learn some tricks.
- sluongng 2y ago> What's the option if I want to learn Bazel to an intermediate level and I don't work with former Googlers? The best way to learn it would be to use it yourself and try solving problems with it. You don't need an xoogler to learn it, my former company did not have one when we first evaluated Bazel. There is a very active community Slack and StackOverflow for questions as well. > rarely is there anything relating to best practices or even what constitutes good rules. I think rules_go has been a stellar example of what a well-made rule should look like: - Managing toolchains and stdlib within Starlark - Provide wrapper around core toolchains to enforce best practices - Break down a build into fine-grained, reusable actions - Provide concrete APIs for downstream rules (i.e. graphql, swagger, proto code gen) to consume. > Seems like most of the hobby community prefers NIX for deterministic builds too, so the situation is not improving for novices like myself who really like the idea of hermitic builds, monorepo's and distributed cache. Nix figured out the external dependencies story much better than Bazel, much thanks to nixpkgs repo. So naturally, in a fragmented opensource ecosystem, Nix thrives much better. However, in a closed ecosystem within an enterprise, Bazel provides a more granular approach to managing your build: smaller actions mean finer, more granular caching. It also has a much better set of APIs for distributed builds and build telemetry that folks could depend on from day 1. It's also copying some for Nix playbook with the new Bazel Central Registry resembling nixpkgs. I think you can learn either build system. Most of the skills and concepts are transferrable: sandboxing, build hermeticity, remote caching, remote build, etc... So you often see some experts in this field being involved in multiple build tools development and not just one.
- aaomidi 2y agoJoin the Bazel slack imo.