Questions tagged [bazel-rules]
274 questions
3
votes
1 answer
How to use Bazel rules_docker container_flatten to create a Docker image?
I'd like to slim down a debian 10 Docker image using Bazel and then flatten the result into a single layer image.
Here's the code I have:
load("@io_bazel_rules_docker//container:container.bzl", "container_image", "container_flatten",…

Joe
- 3,370
- 4
- 33
- 56
3
votes
0 answers
Bazel build - go:generate stringer "stringer: can't happen: constant is not an integer"
I am trying to create an auto-generated file "txstatus_string.go" within Bazel sandbox which relies on a go file and it is getting created with below stringer command:
go:generate stringer -type TxStatus
I am using a bazel genrule like…

alanmas
- 61
- 4
3
votes
0 answers
How to glob an absolute path for files in Bazel
Context: I'm trying to come up with a fix for https://github.com/tensorflow/tensorflow/issues/37861 where header files of an external dependency are manually listed but that list is version specific and hence impossible to keep up to date.
What is…

Flamefire
- 5,313
- 3
- 35
- 70
3
votes
1 answer
Bazel get location of external dependency as command line arg for py_binary
I need the path to external (or internal) dependency to pass it as an argument to a function inside. We need the location to the folder, not specific files. Also, sometimes, we need the path to the folder where a shared library, generated by…

user9092688
- 171
- 10
3
votes
1 answer
Bazel using with lerna and yarn workspace
Many people are using lerna and/or yarn workspace.
I guess either migrating from them to Bazel, or just using them with Bazel together is good to be guided with an example project.
For example, currently, I have a directory structure like this,…

jjangga
- 441
- 5
- 14
2
votes
1 answer
bazel: Cycle in the workspace file detected. This indicates that a repository is used prior to being defined
I have the following files and try to compile simple python app using bazel 6.1.1 and getting error.
my files:
➜ tree
.
├── BUILD
├── main.py
└── WORKSPACE
the error:
➜ bazel build //...
WARNING: Ignoring JAVA_HOME,…

DmitrySemenov
- 9,204
- 15
- 76
- 121
2
votes
0 answers
Installing python packages with extras using Bazel pip_parse
I use Python Rules for Bazel to build my python projects. I use pip_parse to install pip packages, as described in the guide, but that doesn't seem to be working for packages with extras.
For example, I have the following dependency in my…

andrii
- 1,248
- 1
- 11
- 25
2
votes
2 answers
How to see the native implementation of predefined rules in Bazel
I am learning currently Bazel and after going through a few tutorials I feel like I have some basic working knowledge with it. Now I would like to dig slightly deeper and see how some of the rules I am using, like android_binary,…

VCODE
- 535
- 5
- 19
2
votes
0 answers
Looking for example of Bazel genrule for calling shell script
I have a shell script(.sh) for generating metadata of media files. I need to run the script while building the AOSP by using bazel genrule. Do any have similar examples or directions for me?

Midhun PM
- 512
- 1
- 7
- 24
2
votes
2 answers
How to properly use bazel transitions for multiarch build
I'm trying to define a bazel rule that will build 2 different cc_binaries for 2 different platforms with just 1 bazel build invocation. I'm struggling with how to define the transition properly and attach it.
I would like ultimately to be able to do…

seth
- 31
- 1
2
votes
1 answer
Google Benchmark: "***WARNING*** Library was built as DEBUG. Timings may be affected."
In ~/install/benchmark, I have checked out Google Benchmark (https://github.com/google/benchmark) and built it in Release mode according to the instructions here.
In ~/personal-projects/benchmarking, I have my own code with a BUILD file and a…

bun9
- 161
- 8
2
votes
1 answer
Consuming contents of declare_directory
I have rule A implemented with a macro that uses declare_directory to produce a set of files:
output = ctx.actions.declare_directory("selected")
Names of those files are not known in advance. The implementation returns the directory created by…

Marek
- 23
- 3
2
votes
2 answers
How to reference bazel c++ protobuf output headers in a different workspace/package
I just started using Bazel a couple days ago in hopes of something better than CMake. I have a small library that contains only protobuf definitions in its own repository. I've gotten bazel building the proto types and see them in the…

weagle08
- 1,763
- 1
- 18
- 27
2
votes
1 answer
How to query repository rule in bazel?
I'm trying to translate my company's project from legacy build tool to bazel. Now I'm facing this problem and searched a lot, but unfortunately, I haven't had a clue so far.
Here's the thing:
For compliance with open source audit, we must provide a…

Chen Zhuo
- 71
- 5
2
votes
1 answer
Runfiles from multiple targets in a single directory in Bazel
I have an integration test target which uses runfiles from two different targets:
java_test(
name = "test",
srcs = ["Test.java"],
data = ["//package:resource1", "//package:resource2"],
...
)
The first one is a filegroup:
filegroup(
name…

agluszak
- 90
- 1
- 6