Questions tagged [bazel]
Bazel is a build tool that builds code quickly and reliably. It is used to build the majority of Google's software, and thus it has been designed to handle build problems present in Google's development.
2,721
questions
0
votes
1
answer
9
views
How to cross compile for a non-standard platform in Bazel
I wish to build disk images for an esoteric computing platform (CP/M, if you're interested!) with bazel.
Having looked at the documentation for doing cross-compilation with bazel, it looks like it's ...
0
votes
0
answers
12
views
Getting stale protobuf source code when using bazel
I'm new to bazel and working on a big project. I noticed that the protobuf .h files in my working directory (.cache/bazel/...) are stale.
Have been trying to find where bazel is downloading the source ...
0
votes
1
answer
12
views
Bazel build failed for `does not contain a toolchain for cpu 'darwin_arm64'`
when I try to build bazel, I got the below errors:
/private/var/tmp/_bazel_user/a436f601856ed4b73afb5a5d5d56a412/external/llvm_toolchain/BUILD:24:18:
in cc_toolchain_suite rule @llvm_toolchain//:...
0
votes
1
answer
28
views
Bazel not running flutter correctly
I'm trying to execute a flutter command using bazel. This is my BUILD.bazel file:
genrule(
name = "flutter_build",
srcs = [
"//:root_filegroup"
],
outs = [&...
0
votes
0
answers
16
views
Issue while importing Bazel project into IntellijIDEA
I face the following problem when open an existing Bazel project in IntellijIDEA.
Although the project already exists, I'm creating it from scratch as this is the only way (?)
java.lang....
0
votes
1
answer
27
views
Why does Bazel http_archive rule not download archive?
I'm a Bazel newbie and am working through the C++ guide here, trying to include an external testing library (gtest): https://bazel.build/tutorials/cpp-use-cases#include-external-libraries
This is my ...
1
vote
1
answer
24
views
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, ...
0
votes
1
answer
19
views
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 ...
0
votes
1
answer
18
views
Bazel out-of-source build
I was recently introduced to 'Bazel' build system while learning gtest. Apparently I am a
beginner in this thing. So far it is going well, I really appreciate bazel's simplicity. My question is:
How ...
0
votes
0
answers
12
views
Bazel can'f find my external lib header files
I'm testing bazel and now have a problem with external library.
My demo project is like this: a simple main.cpp trying to use 3rd party libary of fastcdr.
bazel-demo/
├── src
│ ├── BUILD
│ └── ...
0
votes
0
answers
14
views
Bazel clean only a subset of the cached rules
I am currently developing in a monorepo that has a pretty large workspace file.
Right now, I am noting that one of my testing rules, is not getting its dependency rules re-built when I update one of ...
1
vote
0
answers
16
views
Can `bazel test` call `bazel run`?
I'm writing an integration test for a script that calls bazel run (which produces a file in the source workspace). Ideally, the test can be called via bazel test.
I know bazel test creates a sandbox ...
0
votes
0
answers
12
views
Build EFI Application with Bazel
I am trying to build a simple EFI app with Bazel on Linux, which apparently means I need to use a cross compiler: x86_64-w64-mingw32-gcc. Right now I have:
cc_binary(
name = "boot-loader"...
0
votes
0
answers
21
views
How do I `select` over execution target?
I have the following rule but it isn't working because the select is evaluating target platform instead of host platform or execution platform.
Does anyone know how to make it work?
...
1
vote
1
answer
18
views
Where does bazel store fetched packages?
In my WORKSPACE file I have defined a http_archive like
http_archive(
name = "awscli_zip",
urls = [
"https://awscli.amazonaws.com/awscli-exe-linux-x86_64-{version}.zip&...
1
vote
1
answer
20
views
Why is BUILD_WORKSPACE_DIRECTORY not getting set?
I'm using bazel 5.1.0 and have the following in a BUILD file:
sh_binary(
name = "aoeu",
srcs = ["aoeu.sh"]
)
The contents of aoeu.sh is:
#!/bin/bash
echo "...
0
votes
1
answer
37
views
linking existed c++ static libaray in Bazel failed
I am writing a OpenGL programe on windows.
I want to link precompiled GLEW32.lib, but failed and failed for a couple of hours.
In WORKSPACE, a http_archive uses to download GLEW32.lib
http_archive(
...
0
votes
1
answer
26
views
Getting "name 'genrule' is not defined (did you mean 'rule'?)" error when using genrule in .bzl files
I can see everywhere in docs, SO questions, github, etc. that people are using genrule without any direct load statement, but when I try to use it in any .bzl file, I get the following error and I ...
0
votes
1
answer
39
views
Include C++ library in Bazel project
I'm currently messing around with Google's Mediapipe, which uses Bazel as a build tool. The folder has the following structure:
mediapipe
├ mediapipe
| └ examples
| └ desktop
|...
0
votes
1
answer
9
views
what's bazel dynamic library search path?
I used the ldd command to print out the binary build through bazel and the result is as follows.
libexternal_Scom_Ugoogle_Uprotobuf_Slibprotobuf.so => /apollo/bazel-bin/cyber/../_solib_k8/...
0
votes
0
answers
13
views
Bazel's Java lcov report uses package instead of file paths
I am collecting code coverage for a Java-based repository using the following command:
bazel coverage --jobs=$PARALLEL_JOBS --keep_going --flaky_test_attempts=3 --cache_test_results=no --...
0
votes
0
answers
9
views
what are bazel cc_library SONAME rules?
I use bazel to build a so library using cc_library, and then use cc_binary to deps on it.
but seems bazel change the name of the so library.
below is an example by readelf -d bazel-bin/cyber/mainboard
...
0
votes
0
answers
33
views
Bazel fails to compile TypeScript project
I'm trying to convert multiple repos of microservices into a single monorepo. I want to use Bazel for this. Im new to Bazel and just started migrating the repos. At the moment I just want to migrate ...
0
votes
1
answer
35
views
How to get bazel genrule to access transitive dependencies?
I have the following in a BUILD file:
proto_library(
name = "proto_default_library",
srcs = glob(["*.proto"]),
visibility = ["//visibility:public"],
deps =...
1
vote
0
answers
29
views
go application build with bazel can't link when running inside container
I am trying to containerize my application build, though, when running the build that uses bazel with bazel-gazelle inside a container I will get this error:
$ bazel run --spawn_strategy=local //:...
0
votes
0
answers
23
views
WARNING: Ignoring JAVA_HOME, because it must point to a JDK, not a JRE
what happend: i can't solve the warnings
fjw@MacBook-Pro googletest % [master] bazel info
WARNING: Ignoring JAVA_HOME, because it must point to a JDK, not a JRE.
WARNING: Ignoring JAVA_HOME, because ...
0
votes
1
answer
47
views
Provide run time environment variable path (e.g. LD_LIBRARY_PATH) to third party dependency in bazel
In the code base I am working with we use the oracle instant client library as a third party dependency in Bazel as follows:
cc_library(
name = "instant_client_basiclite",
srcs = ...
0
votes
0
answers
16
views
Manually building C++ library in bazel (4.2.1) sandbox
For a proof on concept I want to use a CMAKE library in a large bazel (4.2.1) project.
In my first attempt I build the library outside bazel by hand and am loading it using new_local_repository.
This ...
0
votes
2
answers
21
views
Bazel pass flaky test if 1 out of 3 retries pass
I have a Java based test suite running Bazel 4.2.2, and my goal is to collect code coverage regardless of test flakiness. I tried to add these options:
bazel coverage ... --runs_per_test=3 --...
0
votes
1
answer
15
views
How to select a platform from the command line in Bazel
I'm messing around with Bazel example files. This one in particular on github, seems to select a tool by checking which platform is detected (specified?). If I execute:
bazel build :sh
it uses Linux. ...
0
votes
1
answer
19
views
Does `bazel run` use sandboxing? If not, why not?
From my tests, it doesn't appear that bazel run runs in a sandbox. For example, I ran bazel run //:some_target --spawn_strategy=darwin-sandbox --sandbox_debug, and it didn't generate a new directory ...
0
votes
0
answers
17
views
Building tensorflow lite using bazel didnt produce external static libs in linux
I've added a custom op code to tensorflow lite and trying to compile the c api version using bazel. Now with macos/ios/windows in addition to the shared lib (.dylib/.dll) it'll also create static ...
0
votes
0
answers
19
views
Shared objects of dependencies of a Bazel target
I'm trying to build a shared object .so using Bazel.
The target is a cc_library and using bazel build <target>, I can successfully recover the shared object.
My problem arises when I try to use ...
0
votes
0
answers
30
views
Invoke function after loading my custom.bzl
Let's suppose I have custom.bzl with only one function (def foo():).
I load custom.bzl from 2 BUILD files and invoke 'manually' function foo().
According to domain model, I know that each loading of ...
1
vote
1
answer
26
views
How do I see the command line that `bazel run` executes?
How do I get the commands executed by Bazel answers a similar question for bazel build, and --subcommands works well for that. But --subcommands does not show the command that's executed for bazel run....
1
vote
1
answer
24
views
Why dependent workspace doesn't automatically include/execute the WORKSPACE file it has a dependency on in Bazel
I have two repositories with Bazel builds. The one uses the Bazel imports for building protobuf types. When I make this repo/workspace a dependency of my other repo/workspace I have to re-add all of ...
0
votes
1
answer
29
views
Under what conditions can a remotely cached test result be drawn from in bazel?
I'm trying to understand why these test executions I'm running never secure a remote cache hit on the first try. These tests are configured to pull in some remote cache configuration when executed and ...
0
votes
1
answer
23
views
How to use a filename based on a build setting
I have a build setting like:
string_flag(
name = "version",
build_setting_default = "0.1")
I want to use it to create a file, e.g.:
ctx.actions.run_shell(
outputs = [&...
0
votes
2
answers
68
views
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 ...
0
votes
0
answers
53
views
how to configure bazel toolchain for cross compile use rules_foreign_cc
my project need cross compile for arm aarch64 on ubuntu x86_64, but failed at configure stage, below is log
log
# Execution platform: //platforms:linux_gcc9_aarch64
SUBCOMMAND: # @boost//:filesystem [...
0
votes
1
answer
32
views
How to use shell script that generates output files prior to subsequent Bazel build targets
I have a few protobuf files that I'm building with a shell script like so:
proto.sh
#!/usr/bin/env bash
rm -rf ./proto-out
mkdir -p proto-out
protoc -Iproto --cpp_out=./proto-out ./proto/*.proto
...
0
votes
1
answer
33
views
in-tree include directory with bazel custom toolchain
Is it possible to configure a Bazel custom toolchain to include directories in the repository?
Assume that I have following in the root of my repository:
sysroots/armhf/include/myheader.h
sysroots/...
0
votes
0
answers
25
views
How to get interface test code coverage with bazel?
We can get unit test code coverage with bazel coverage, but I have to get interface test code coverage.
The interface test is that I upload my package to a remote docker container,and run it,Then I ...
0
votes
1
answer
56
views
How to use Conan in Bazel
I am new in bazel and conan.
I try run conan in bazel use it https://docs.conan.io/en/1.44/integrations/build_system/bazel.html
In WORSPACE file:
load("//third-party/grpc:direct.bzl", "...
0
votes
1
answer
29
views
Why can't Bazel find my test class when running bazel test on a java_test rule?
I have a test class defined in src/handlers/MyHttpHandlerTest.java (sorry, I know it's best practice to put tests in a tests directory).
Here is my src/handlers/BUILD file:
java_test(
name = "...
0
votes
1
answer
20
views
How to get list diff in Skylark?
I'd like to do something like:
srcs = glob(["*.proto"]) - ["some.proto"],
That particular syntax isn't valid in Skylark. How do I go about accomplishing a list diff in Skylark?...
0
votes
1
answer
35
views
How can I stop bazel from creating an entire copy of my project's source files?
I have a simple Java project in a directory called java-fun. Bazel is installed and runs correctly. But whenever it runs, it generates a directory called bazel-java-fun that contains copies of all the ...
0
votes
0
answers
30
views
Pass generated sources to go_library
I have a set of openapi-generator-bazel generated go sources. Is there a way to pass them to a go_library rule?
0
votes
0
answers
29
views
NameError with extend_path using Bazel
I am trying to make a python program using bazel. When running the following snippet of code:
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
I am given the following error:
...
0
votes
0
answers
24
views
How to properly handle cyclic dependencies in Bazel without changing the source code?
I have read the question, but unfortunately the proposed solutions are to change source code of header files location, which on this case it's not possible.
Let's imagine I have the following ...