8 ms·
I highly recommend you give Bazel a look if you haven't. I'm coming from a biased perspective, since I work at Google where we have a nice build setup. But, I l
by jchw 8y ago
I highly recommend you give Bazel a look if you haven't. I'm coming from a biased perspective, since I work at Google where we have a nice build setup. But, I like Bazel so much I use it and hack on it in spare time.
There's really only two things that bother me:
- Windows support is alright but it's a bit weird and wants some Unixy stuff to exist. It's being worked on in small bits but it could be better. If you don't care about this you'll have a good time likely.
- Sadly it isn't widely used outside of Google, so you're mostly on your own. The only upshot is that the Starlark language makes it really easy to compose BUILD files, so I don't find it too difficult to manage a few BUILD files for things like SDL2. Unlike a lot of other build systems, like CMake for example, it would be much less hassle to consume other Bazel projects directly, since it's designed to work that way, so if it ever did gain widespread adoption it would be a really nice solution.
There's definitely some things that would turn off the average user. Like the BUILD files, in order to be predictable, contain dependency information, which either needs to be updated by hand or tools (you can guess which is preferred.) On the other hand, builds are very predictable, and it works such that you can easily express dependencies across different programming languages and even autogenerated code from another target.
Nothing is perfect, but I find Bazel is super nice for C/C++ compared to the alternatives I've used. It's a different way of approaching the problem of building software, one that I've found very novel despite the shortcomings. I'm worried it's too easy to miss what makes it special behind some of the turnoffs people initially hit.
- misnome 8y agoHow does this solve the build time problem the parent post was lamenting? I’ve looked a little bit at bazel but haven’t spent long on it. It seems to really, really want you to do things in its specific googly way ( that seems to stem from monorepo style and always knowing the exact build path and never needing to distribute to users) which is hard if e.g. trying to to convert an existing project that doesn’t perfectly fit (us: combined C++/Python with some legacy fortran generation) Or a project that has external dependencies currently being chain-built but isn’t itself built with bazel (e.g. most the planet) - we don’t all have dedicated build teams to accurately and bug free reproduce other libraries build procedure (also getting away from a buggy reproduced build is part of my system rewrite intention). I seem to remember the documentation also had the usual problem that the easy examples were well documented but hard to tell how to do anything more complex, but maybe I didn’t dig enough. CMake has a similarish problem except the problem is finding more modern ways of doing things that don’t suck (I’m aware of all the talks about this, many of them are big on ambition but low on details, and usually just teach transient dependencies).
- misnome 8y agoIgnore the first sentence, I think I misread what you were specifically commenting on for that.
- jchw 8y agoIt improves the build time problem by offering a way to do fast, hermetic builds. Caching is very accurate, targets only rebuild exactly when they need to, and you can distribute just about any kind of work over a build farm. It may not sound like much, but having the distribution at the build system level, versus say, distcc, makes a big difference, especially if you have long build steps that aren't just compilation. You literally can't accidentally have dependencies that aren't explicitly defined. When you go to compile it will not find headers from targets that are not depended on, for example. >I’ve looked a little bit at bazel but haven’t spent long on it. It seems to really, really want you to do things in its specific googly way ( that seems to stem from monorepo style and always knowing the exact build path and never needing to distribute to users) which is hard if e.g. trying to to convert an existing project that doesn’t perfectly fit (us: combined C++/Python with some legacy fortran generation) I don't really think this is the case. There's definitely certain aspects that can be challenging but I do not feel it has much to do with monorepos. It works well with a monorepo using the workspaces system, but it also should work fairly well using modular git repos as well, each repo is just treated as it's own workspace. It's possible to even have Bazel go and get other workspaces, and you can refer to targets inside of other workspaces. One of my favorite parts about Bazel is combining different languages. If Starlark rules for the language you are trying to build for don't exist, you can write them. Starlark is a fair bit like Python, it's relatively easy to learn and write your own targets. I acknowledge that most people don't want to maintain BUILD files for external stuff. There are some options here. Some people already maintain this, like here: https://github.com/bazelregistry https://github.com/bazelregistry - and there are experimental rules for dealing with external build systems. I use it outside of Google on personal projects and find it perfectly manageable. You don't really need a large build team unless you're doing interesting things. There are a few aspects of Bazel that really are tough, like how you must explicitly specify dependencies on every target, and how actual builds can't even see files not specified in dependencies, and when you get fairly deep you'll probably run into trying to understand what's going on with runfiles. It's definitely a bit more compliant than a Makefile generator at this point. But in exchange, it delivers on its promise of being fast and correct.
- paulddraper 8y agoI'm actually super familiar with Bazel :) And Buck and Pants. Been following it since the presentation at 2015 @Scale conference, attended 2017 Bazel Conf, introduced it at Lucid Software, helped write a bunch of OSS rules. Bazel is mostly great. Besides a few pre-1.0 polish items, I'm mostly frustrated by the expectation that users write build rules in Skylark, while the real rules (including C++) have to be written and compiled into Bazel itself to take advantage of features that Skylark lacks and aren't even on the roadmap. [1] So while I'm disappointed Bazel's not quite a general-purpose build system a la Make, it's awesome for C++ and Java. [1] "Why Skylark is a 2nd class citizen" https://groups.google.com/forum/#!msg/bazel-discuss/8eAMN3Whp2Q/sgWpqz7wCAAJ https://groups.google.com/forum/#!msg/bazel-discuss/8eAMN3Wh...
- laurentlb 8y ago(I work on Bazel) Starlark (Skylark) is used for a huge number of rules. The community has written and used in production lots of rules, such as Closure, Docker, Go, Haskell, Kotlin, Kubernetes, NodeJS, Rust, Scala, Swift, Typescript. We stopped creating native rules many years ago and we are actively migrating them to Starlark. I'd replace the phrase "real rules" with "legacy rules". If you hit critical limitations when writing rules, feel free to ask on the mailing-list (or on a GitHub issue).
- paulddraper 8y agoThanks for your work Laurent! > The community has written and used in production lots of rules I know. I've written them. [1] Github pauldraper > If you hit critical limitations when writing rules, feel free to ask on the mailing-list I have, and you've responded. [2] And a year later it is still is unclear to me whether Starlark is going to get tree artifact actions, or dependency discovery (pruning), which C++ uses to great effect. I proposed a solution to both problems. [3] Oscar from Stripe presented a proposal at the first Bazel Conf. I've concluded that either (1) I'm using the wrong channels or (2) Bazel isn't that aware/interested in Starlark parity. TBH, the number of responses that are ignorant of the dependency discovery disparity alone shows me how unaware Bazel is of the Skylark-only deficiencies. Great project (seriously), but when your bread-and-butter compiled languages* (Java, C++, Objective C) aren't using the same system as everyone else, it's only natural. Again, great project. [1] https://github.com/higherkindness/rules_scala https://github.com/higherkindness/rules_scala [2] https://groups.google.com/forum/#!msg/bazel-discuss/8eAMN3Whp2Q/sgWpqz7wCAAJ https://groups.google.com/forum/#!msg/bazel-discuss/8eAMN3Wh... [3] https://docs.google.com/document/d/16iogGwUlISoN2WLha2TAaUdpYCjRiVQ2sRQ7--INxkg https://docs.google.com/document/d/16iogGwUlISoN2WLha2TAaUdp... * Go is in Starlark but has essentially required the complex Gazelle build tool to be layered on top of Bazel.