bazel | a fast , scalable , multi-language and extensible build system | Build Tool library
kandi X-RAY | bazel Summary
kandi X-RAY | bazel Summary
Build and test software of any size, quickly and reliably.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Add legacy features .
- Execute the given command and return the result .
- Creates a new target .
- The binary operator .
- Parse the member specification arguments .
- Evaluate a single instruction block .
- Visit an instruction .
- Visit a program class .
- Configures the skyframe execution .
- Search for cycles .
bazel Key Features
bazel Examples and Code Snippets
def retrieve_bazel_version():
"""Retrieve installed bazel version (or bazelisk).
Returns:
The bazel version detected.
"""
bazel_executable = which('bazel')
if bazel_executable is None:
bazel_executable = which('bazelisk')
if ba
def get_bazel_gcc_flags(self):
ICELAKE_ARCH_OLD = "skylake-avx512"
ICELAKE_ARCH_NEW = "icelake-server"
AVX512_FLAGS = ["avx512f", "avx512cd"]
if IntelPlatform.use_old_arch_names(self, 8, 4):
ret_val = self.BAZEL_PREFIX_ + self.A
def get_bazel_gcc_flags(self):
NEHALEM_ARCH_OLD = "corei7"
NEHALEM_ARCH_NEW = "nehalem"
if self.use_old_arch_names(4, 9):
return self.BAZEL_PREFIX_ + self.ARCH_PREFIX_ + \
NEHALEM_ARCH_OLD + " "
else:
return s
Community Discussions
Trending Discussions on bazel
QUESTION
I try to build drake1.0.0 from source using bazel. However I encounter the following error:
...ANSWER
Answered 2022-Mar-05 at 15:32It turns out that the install_repreqs.sh
has been updated and I forget to rerun it. After installing the prerequisite by rerunning install_repreqs.sh
, I can build drake from source successfully.
QUESTION
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:
...ANSWER
Answered 2022-Feb-16 at 17:13I followed your steps with Mac OSX 10.15.7, Qt (installed by homebrew) 5.15.1 and both bazel 4.2.2-homebrew and 5.0.0-homebrew and initially I could not build the project from git:
* 3fe5f6c - (4 weeks ago) Add macOS support — Vertexwahn (HEAD -> add-macos-support, origin/add-macos-support)
This is the result that I get when building:
QUESTION
I'm working on a C++ project and I need Numpy like arrays and functionalities in C++. I found some alternatives like xtensor, NumCpp etc. These are header only libraries. The problem is I'm experimenting with Bazel for the first time so, I don't have any idea about how do I add header only library to Bazel workspace. There are some suggestions like genrule-environment, rules-foreign-cc suggested on other questions around Bazel. I've added http_archive to WORKSPACE file, but I'm not sure what to add in BUILD file.
WORKSPACE file
...ANSWER
Answered 2022-Feb-07 at 19:50For simple things like header-only libraries, I would write BUILD files yourself, without using rules_foreign_cc. Just write a cc_library
with no srcs
. Something like this:
QUESTION
I'm using bazel to run a go test on my CI system. The go test will need to use a helper binary built from another go file.
The dir structure looks like the following:
...ANSWER
Answered 2022-Jan-24 at 20:06You want data
, not deps
. deps
is for things linked into a binary, data
is for things the binary uses at runtime.
Once your binary is in data
, use runfiles.go to run it. Add @io_bazel_rules_go//go/tools/bazel:go_default_library
to deps
(it's a library you want linked in), and then use FindBinary
to find the path.
QUESTION
Is there a way that I can use a Bazel-based library like for example lyra inside a CMake-based project? Example: I have a simple hello world program, which is built using CMake - can I somehow use CMake to automatically build the Bazel library and link it somehow in my CMake project so that I can use the lyra library in the main file?
...ANSWER
Answered 2021-Dec-22 at 13:39After a lot of research, it turns out that this is kind of possible. I made an easy to follow tutorial on GitHub, which demonstrates the manual steps on how one can cross-compile a Bazel project and then link the result into a Zephyr project (CMake-based).
Note: depending on the complexity of the existing Bazel project itself and the limited capabilities of the toolchain you are using, you might not be able to integrate the Bazel project into Zephyr without serious code adaptation or refactoring on the Bazel project side!
QUESTION
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:
...ANSWER
Answered 2021-Nov-17 at 08:43Figured it out, posting here if anyone else stumbles on this.
The answer is simple - you need to embed the go_library
rule within the go_image
rule. Here is my cmd/hello/BUILD.bazel
where I also embed the go image in a docker container
QUESTION
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.
ANSWER
Answered 2021-Nov-09 at 11:38load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
rules_foreign_cc_dependencies()
AWS_BUILD = """\
filegroup(
name = "sdk",
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)
"""
new_git_repository(
name = "aws_sdk",
build_file_content = _ALL_CONTENT,
commit = "2550901e1011e0ee1dc1bae44b42e1a2c6947c24",
recursive_init_submodules = True,
remote = "https://github.com/aws/aws-sdk-cpp",
shallow_since = "1628277923 +0000",
)
QUESTION
I'm interested in seeing if bazel ran in the recent past. Where can I find general logging for past bazel build/run/fetch (maybe somewhere in /var/log)?
...ANSWER
Answered 2021-Nov-02 at 20:13You can find logs in the output base for the workspace, which for Linux is typically $HOME/.cache/bazel/_bazel_$USER//
You can find the output base for a workspace by running bazel info output_base
in that workspace. Note though that there's a command.log
file which contains the output of the last command, and bazel info
is itself a command, so that will overwrite command.log
. You can do echo -n $(pwd) | md5sum
in a bazel workspace to get the md5, or find the README files in the output base directories which say what workspace each is for.
QUESTION
I am randomly getting the following error when I am executing the binary (sometime it works):
...ANSWER
Answered 2021-Oct-29 at 20:27You should be able to remove the gc_linkopts
options from the build. Statically linking glibc
is not really supported, and may be causing problems.
If you have other cgo libraries you need to link statically, you will need to provide the linker flags for those libraries specifically.
If the only use of cgo is for name resolution on linux, you can almost always build without cgo and rely on the native Go implementations when a static binary is desired without a portable C implementation.
QUESTION
Been reading the Bazel docs over and over to the point where nothing feels new, but I cannot seem to grasp how to setup configurations and variants for variants other than the native ones, e.g. --cpu
and --compilation_mode
.
To explain what I mean with configuration and variants, consider this table of Configuration rows, and Variant Points columns, and Variant cells (making this table up, hope it at least makes abstract sense):
Has hardware module X Connected on interface Fail fast Customer configuration 1 Yes Ethernet Yes Customer configuration 2 Yes USB Yes Customer configuration 3 No USB No Debug hw configuration No UART YesFrom a Bazel user perspective:
- All targets should be buildable for all configurations by default
- Not ok adding "Customer configuration X" everywhere on adding a configuration
- Configuration specific components should be possible to explicitly state which configuration it is specific to
- I think this is what constraint_value is for
- Rules should add flags based on configuration
- For example
-DVARIANT_POINT_CONNECTED_ETH
for Ethernet connection and-DVARIANT_POINT_CONNECTED_USB
for USB connection
- For example
- I want a simple build command for building/testing/running a single configuration
- Something like
bazel build //my/target --//:configuration=debughw
- Think there is something about it in the skylark config docs, but not seeing how to go from the example to using constraint_values and
select()
in rules
- Something like
ANSWER
Answered 2021-Oct-15 at 23:59You're looking for platforms. Build settings (that you found first) are better for independent pieces of configuration where setting them in any permutation is useful, vs platforms tie all the pieces together. The resulting settings and constraints can then be used to drive compiler flags and limit targets to certain configurations.
For your example, I think something like this makes sense:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install bazel
Get started with Bazel
Follow our tutorials: Build C++ Build Java Android iOS
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page