Questions tagged [bazel-rules]
274 questions
2
votes
1 answer
What is RULES_JVM_EXTERNAL_TAG and RULES_JVM_EXTERNAL_SHA in bazel WORKSPACE file?
I'm trying to move to bazel from maven. I saw the tutorial in bazel documentation and it has a sample WORKSPACE file. link
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "2.8"
RULES_JVM_EXTERNAL_SHA =…

Pavan Kumar Lekkala
- 85
- 5
2
votes
2 answers
Bazel | How to copy resources to build directory?
I am making some openGL project, and want to just copy one of my directory into build directory (I store my textures there).
So basically this is what my project structure looks like:
|-WORKSPACE
|-/src/
| -BUILD
| -main.cpp
| -*some folders…

Morph
- 165
- 2
- 9
2
votes
1 answer
BAZEL + bash: execute bash/python script to do code generation and use them in bazel system
I am new to Bazel. I have a project which is built with Bazel.
But some of the source files are pre-codegened and then compile them with Bazel.
Now I can run the bash script standalone and run the bazel command:
.
|-- project
| |-- BUILD (will…

ReneSun
- 23
- 2
- 5
2
votes
2 answers
Package transitive deps in Bazel
I would like to package lets say a binary with the pkg_tar command. But I would also automatically like it to include all deps to that binary, for example all .so files from other Bezel targets that are referenced with deps. Is it…

Rolle
- 2,900
- 5
- 36
- 40
2
votes
2 answers
Feed Bazel output to another Bazel rule
I am pretty new to Bazel and have a difficult time figuring out a solution for this:
Say I have this nodejs_binary rule:
nodejs_binary(
name = "js_scirpt",
data = [
"@npm//some_lib",
],
entry_point =…

Yar
- 7,020
- 11
- 49
- 69
2
votes
1 answer
Include a generated header file using a relative path
Currently, I try to build a library with Bazel (5.1.0) that originally uses CMake as a build system.
I am running into a problem when trying to include a generated a header file using a relative path (in the CMake build it uses configure_file):
(The…

Vertexwahn
- 7,709
- 6
- 64
- 90
2
votes
2 answers
Build Bazel package from multiple repos
I am trying to build OpenCV with external modules, but haven't been able to come up with a clean solution.
I have successfully built OpenCV using CMake (rules_foreign_cc). But to be able to build with external modules I need to download a separate…

sdmello
- 431
- 2
- 6
- 14
2
votes
1 answer
Bazel C++ rules(cc_liibrary): why can a target access headers of its dependency that are not exposed via hdrs?
An example repo can be found at https://github.com/versemonger/bazel-test

Zhu Li
- 585
- 6
- 18
2
votes
0 answers
What is the expected pattern for exposing make variables from a custom bazel toolchain?
I'm trying to expose a make variable to a genrule so that I can pass along some information from toolchain selection to a custom rule. In this case it is the object file format that corresponds to the currently selected toolchain for my language…

Eric Dobson
- 343
- 2
- 8
2
votes
1 answer
How to strip folder names in py_library imports?
I'm having a problem understanding the python import directories of bazel.
Given a tree like this:
.
├── WORKSPACE
├── python_lib_a/
│ ├── BUILD
│ └── src/
│ └── package1/
│ └── folder1/
│ └── some_file.py
└──…

Melih Yıldız'
- 415
- 5
- 17
2
votes
1 answer
Understanding "inputs" parameter of Bazel "run" action
I am writing a simple Bazel rule that uses ctx.actions.run. Unfortunately, I have a hard time understanding inputs param of run action.
The doc says inputs is "a list or depset of the input files of the action". What if my action just runs an…

Michael
- 41,026
- 70
- 193
- 341
2
votes
1 answer
How to retrieve bazel remote cache metrics on the client
Context
We want to get client metrics so that we can track how long each target takes to build, how big the target outputs are and if they're remote cache hits.
Normally, we can retrieve the size of each output, if it's a remote cache hit and how…

GGhe
- 663
- 5
- 17
2
votes
2 answers
Bazel Starlark: how can I generate a BUILD file procedurally?
After downloading an archive throug http_archive I'd like to run a script to generate a BUILD file from the folder structure and Cmake files in it (I currently do that by hand and it is easy enough that it could be scripted). I don't find anything…

matthias_buehlmann
- 4,641
- 6
- 34
- 76
2
votes
0 answers
How to properly handle test coverage report (HTML) generation with Bazel?
Goal
I would like to handle the entire process of generating the HTML report with test coverage data through Bazel.
Components
In order to achieve my goal I understand that the following components are necessary:
lcov .dat file: provides…

Humble Student
- 3,755
- 4
- 20
- 35
2
votes
1 answer
What is the relationship between DefaultInfo and PyInfo
It's not clear to me what the difference between the DefaultInfo runfiles's transitive_files and PyInfo transitive_sources are. Are they redundant or is there an important difference?
For example, I have a custom starlark rule which I want to…

daicoden
- 404
- 3
- 10