HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
bazelbuild
examples
Starlark2019–2024
bazelbuild / examples

examples

Examples for Bazel

4Distinct people
4Mentions
0Explicit recommenders
958GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Examples for Bazel

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 1:49:46 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year4 dated mentions

Observed mentions: 2019-10-10 18:02:00 UTC to 2024-09-11 01:00:52 UTC.

0122019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20192020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments20212022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2024

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC101
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC101
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC000
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC000
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC000
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC202

What Hacker News says

4 sources
Here you go! https://github.com/bazelbuild/examples/tree/main/rust-exampl... I wrote all of those examples and contributed them back to Bazel because I've been there... Personally, I prefer the Bazel ecosystem by a wide margin over buck2. By technology alone, buck2 is better, but as my requirements were growing, I needed a lot more mature rule sets such as rules OCI to build and publish container images without Docker and buck2 simply doesn't have the ecosystem available to support complex builds beyond a certain level. It may get there one day.
In Rust in illumos
I've worked in a few monorepos, and organize my personal projects into a monorepo. The most common tool I have seen to manage them (and what I use for my personal stuff) has been bazel. The first monorepo I worked in was a python/typescript monorepo. It largely grew organically, and was heavily iterated on. We had no tooling to manage the complexity, and constant bumped into sharp edges that made life difficult. - Dependencies change and silently break applications or developer environments. - Figuring out how to start up applications you didn't work on could be difficult because you needed to figure out the tool chains and how to invoke them. This painpoint came up everytime toolchains changed. - Figuring out where dependencies were used was really hard. This lead to lots of zombie code, we weren't sure if it was alive or dea
Read the rest
d. There are a bunch of 'meta' tools for this, bazel, pants, buck, gradle, etc. Professionally I have only seen bazel used. I suspect its less to do with the tools themselves, but more to do with the ecosystem. With that being said, bazel does seem to solve most of the sharp edges we had with our ad-hoc/no tooling, but it comes at a cost. Bazel is not trivial, and won't allow you to do some things that the underlying toolchain might have been okay with. So that may leave you making code changes to fit inside bazels constraints. Bazel tooling also isn't equally mature across all languages. The go tooling is pretty mature, and there are great generators that 'make things work', the situation for frontend is less mature, but getting better. It will add additional friction that webdevs might not love. At the end of the day though, I would choose to use something like bazel (or one of the alternates), and the friction it brings over not having it. Example bazel frontend. https://github.com/bazelbuild/examples/tree/main/frontend/ne...
In Ask HN: Best Tools for Monorepo?
Fundamentally, bazel and make treat "targets" differently. A make target is an invokable thing. That's about the extent of it. You have a dag of invokables, and invoking one will cause you to invoke all of its dependencies (usually, other people have discussed the limitations of make's caching already). But let's look at how a rule is implemented in bazel[0]. Here's a rule "implementation" for a simple executable rule[1]: def _impl(ctx): # The list of arguments we pass to the script. args = [ctx.outputs.out.path] + [f.path for f in ctx.files.chunks] # Action to call the script. # actions.run will call "executable" with # "arguments", saving the result to "output" # access to files not listed in "inputs" will # cause errors. ctx.actions.run( inputs = ctx.file
Read the rest
s.chunks, outputs = [ctx.outputs.out], arguments = args, progress_message = "Merging into %s" % ctx.outputs.out.short_path, executable = ctx.executable.merge_tool, ) concat = rule( implementation = _impl, attrs = { "chunks": attr.label_list(allow_files = True), "out": attr.output(mandatory = True), "merge_tool": attr.label( executable = True, cfg = "exec", allow_files = True, default = Label("//actions_run:merge"), ), }, ) This is, admittedly, not easy to follow at first glance. Concat defines a "rule" (just like cc_binary) that takes three arguments: "chunks", "out", and "merge_tool" (and "name", because every target needs a name). Targets of this form have metadata, they have input and output files that are known and can be queried as part of the dag. Other types of rules can be tagged as test or executable, so that `blaze test` and `blaze run` can autodiscover test and executable targets. This metadata can also be used by other rules[2], so that a lot of static analysis can be done as a part of the dag creation, without even building the binary. To give an example, a rule like does_not_depend_on( name = "check_deps", src = ":opensource_thing", forbidden_deps = [ "//super/secret:sauce", ] ) can be built and implemented natively within bazel by analyzing the dependency graph, so this test could actually run and fail before any code is compiled (in practice there are lots of more useful, although less straightforward to explain, uses for this kind of feature). Potentially, one could create shadow rules that do all of these things, but you'd need to do very, very silly things like, off the top of my head, creating a shadow filesystem that keeps a file-per-make-target that can be used to query for dependency information (make suggests something similar for per-file dependencies[3], but bazel allows for much more complex querying). That's what I mean by "object-oriented". Targets in bazel and similar are more than just an executable statement with file dependencies. They're complex, user-defined structs. This object-oriented nature is also what allows querying (blaze query/cquery/aquery), which are often quite useful for various sort of things like dead or unusued code detection or refactoring (you can reverse dependency query a library that defines an API, see all direct users and then be sure that they have all migrated to a new version). My personal favorite from some work I did over the past year or so was is `query --output=build record_rule_instantiation_callstack`, which provides a stacktrace of any intermediate startlark macros. Very useful when tracking down macros that conditionally set flags, but you don't know why, and a level of introspection, transparency, and debugability that just isn't feasible in make. That's what I mean by object-oriented vs. text oriented. Bazel has structs with metadata and abstractions and functions that can be composed along and provide shared, well known interfaces. Make has text substitution and files. While a sufficiently motivated individual could probably come up with something in make that approximates many of the features bazel natively provides, I'm confident they couldn't provide all of them, and I'm confident it wouldn't be pretty or ergonomic. [0]: https://docs.bazel.build/versions/master/skylark/rules.html [1]: https://github.com/bazelbuild/examples/blob/master/rules/act... [2]: https://docs.bazel.build/versions/master/skylark/aspects.htm... [3]: https://www.gnu.org/software/make/manual/html_node/Automatic...
In Please – A cross-language build system
I started by going through the Java tutorial[1] to get a feel for it. It's fairly approachable and you don't actually need any Java knowledge. Once you familiarize yourself with the concept of rules and targets, you can follow the instructions for whichever ruleset you want to use. The official one for JS is rules_nodejs[2] Another thing that really helped me cement my understanding of Bazel was to deep dive into Starlark and write my own rules. The examples repo[3] is a great resource for that [1] https://docs.bazel.build/versions/0.29.1/tutorial/java.html [2] https://github.com/bazelbuild/rules_nodejs [3] https://github.com/bazelbuild/examples/tree/master/rules
In Bazel Release 1.0

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.