Questions tagged [bazel-rules]
274 questions
6
votes
1 answer
Bazel for packages with a "bootstrap->configure->make" build?
I'm experimenting with using libhttpserver and, by extension, libmicrohttpd from inside a Bazel build. The build process for these libraries seems to go:
./bootstrap
mkdir build
cd build
../configure
make
which is a slight variation, that I haven't…

BCS
- 75,627
- 68
- 187
- 294
6
votes
5 answers
Bazel Build Multiple Targets at Once
I want a Bazel rule that is able to build multiple targets at once. So basically something like this:
build_all(
name = "build_all",
targets = [
"//services/service1:build",
"//services/service2:build",
"//services/service3:build",
…

Florian Ludewig
- 4,338
- 11
- 71
- 137
5
votes
1 answer
Execute typescript files passed as arguments from a bazel rule
I'm writing a bazel rule in js for a mono repo. The idea behind this is services inside the mono repo(micro services) define there api spec in a open api schema files. In our case these schemas are in ts files since spec is broken as each route and…

Susitha Ravinda Senarath
- 1,648
- 2
- 27
- 49
5
votes
2 answers
Fine-grained builds with dynamic dependencies?
I am interested in understanding whether bazel can handle "two stage builds", where dependencies are discovered based on the file contents and dependencies must be compiled before the code that depends on them (unlike C/C++ where dependencies are…

Gregory
- 1,205
- 10
- 17
5
votes
1 answer
In Bazel, how to prevent some C++ compiler flags from passing to external dependencies?
Our project is written in C++ and uses gRPC as a dependency. We are using clang as compiler. We set up the C++ toolchain file with -Wall -Werror, but this is causing issues with the warnings raised by gRPC itself.
Is there a way to prevent Bazel…

user3856970
- 319
- 1
- 3
- 11
4
votes
1 answer
groovy_test reports could not find class
I run into some problems when trying to use rules_groovy.
Minimal steps to reproduce:
git clone https://github.com/Vertexwahn/BazelDemos
cd BazelDemos
cd GroovyDemo
bazel test //...
In the case you have not installed Bazel you can installed it on a…

Vertexwahn
- 7,709
- 6
- 64
- 90
4
votes
1 answer
Why is Bazel run_shell not placing arguments correctly?
I have rule a:
def _a_impl(ctx):
src = ctx.actions.declare_file("src.txt")
ctx.actions.write(src, "nothin")
dst = ctx.actions.declare_file("dst.txt")
ctx.actions.run_shell(
outputs = [dst],
inputs = [src],
…

Erran
- 131
- 1
- 10
4
votes
3 answers
How do I debug a 'java_binary' target executed by a Bazel rule via 'ctx.actions.run(...)'?
I have a java_binary target in my workspace that I'm later passing as an executable to ctx.actions.run inside the rule. So far so good.
Now I want to debug this java_binary while Bazel is executing the rule. In order to attach a debugger I need the…

Gunnar
- 2,264
- 17
- 31
3
votes
1 answer
Instantiating a Bazel macro twice with same generated output file
Suppose I have a Bazel macro that is using a generator rule to generate an output file given an input file:
def my_generator(
name,
input_file,
output_file,
**kwargs):
args = []
args.extend(["--arg1",…

roschach
- 8,390
- 14
- 74
- 124
3
votes
2 answers
Creating Python zip for AWS Lambda using Bazel
I've a monorepo that contains a set of Python AWS lambdas and I'm using Bazel for building and packaging the lambdas. I'm now trying to use Bazel to create a zip file that follows the expected AWS Lambdas packaging and that I can upload to Lambda.…

Ricardo Fonseca
- 51
- 5
3
votes
1 answer
Build and run a Qt application on macOS via Bazel
I tried to build and run a Qt5 (5.15.2) application on macOS (10.15.7) using Bazel 5.0.0.
Unfortunately, I run into some problems.
The building part seems to work, but not the run part.
I installed Qt5 on my machine using Homebrew:
brew install…

Vertexwahn
- 7,709
- 6
- 64
- 90
3
votes
2 answers
Apply cpu transition to cc_binary rule in Bazel
I've a c target that always must be compiled for darwin_x86_64, no matter the --cpu set when calling bazel build. It's the only target that always must be compiled for a specific cpu in a big project.
cc_binary(
name = "hello-world",
srcs =…

StianE
- 3,055
- 20
- 20
3
votes
1 answer
Bazel build docker container with local golang module
Let me start by saying I'm new to Bazel. I am trying to build a Docker container from a golang project that contains local module references.
First I'm creating a local golang module:
go mod init go-example
Here is the general project…

hampusohlsson
- 10,109
- 5
- 33
- 50
3
votes
2 answers
What is the proper way to optionally compile a library with a build flag (to place in `target_compatible_with`)?
Suppose I have a library implementation that I only want to compile when the user specifies it at build time.
Should I use the features flag?
If so, how could I use the features flag to constrain compilation like you can with target_compatible_with…

Robbie
- 287
- 1
- 9
3
votes
2 answers
Using Rules Foreign CC to Build AWS C++ SDK with Bazel
Is there a way to do this? I'm trying to build parts of the AWS SDK (s3 and rds) to use in my Bazel project. I've heard that rules_foreign_cc can be used to integrate CMake projects with Bazel.

user15507541
- 43
- 1
- 3