Questions tagged [bazel-genrule]

13 questions
10
votes
3 answers

Bazel: genrule that outputs a directory

I'm just getting started working with Bazel. So, I apologize in advance that I haven't been able to figure this out. I'm trying to run a command that outputs a bunch of files to a directory and make this directory available for subsequent targets. I…
Skylar Saveland
  • 11,116
  • 9
  • 75
  • 91
2
votes
2 answers

Calling gcloud from bazel genrule

I am having some issues getting gcloud to run in a Bazel genrule. Looks like python path related issues. genrule( name="foo", outs=["bar"], srcs=[":bar.enc"], cmd="gcloud decrypt --location=global --keyring=foo --key=bar…
Justin Poehnelt
  • 2,992
  • 1
  • 19
  • 23
1
vote
1 answer

Generating C++ files via py_binary and genrule

I have a Python script named blob_to_cpp.py (located at scirpts/blob_to_cpp.py relative to the WORKSPACE.bazel file). The Python script takes an input file (e.g. weights/rt_alb.tza) and generates from that a C++ header (.h) and source file (.cpp)…
Vertexwahn
  • 7,709
  • 6
  • 64
  • 90
1
vote
1 answer

Can't use Python's sh module in Bazel genrule

When I run a python script, which uses the 'sh' module, from bazel genrule, it failed with this: INFO: Analysed target //src:foo_gen (8 packages loaded). INFO: Found 1 target... ERROR: /home/libin11/workspace/test/test/src/BUILD:1:1: Executing…
bin.li
  • 61
  • 5
0
votes
2 answers

In Bazel is there a concept for creating genrules based on an input file?

Imagine a Bazel based build workflow which lets a genrule() take the content of a file (say sources-list.txt) and creates files for each line of sources-list.txt. Now you also know that each line and it's output are independent from all other, i.e.…
frans
  • 8,868
  • 11
  • 58
  • 132
0
votes
0 answers

Getting Error variable not defined while sending cc_library's name as argument to python file demo.py through cmd in defined in genrule

Getting Error variable not defined while sending cc_library's name as argument to python file demo.py through cmd defined in genrule. I want to pass cc_library's name(string) as argument to python file demo.py through cmd in defined in genrule. When…
0
votes
1 answer

Bazel genrule python import from a script in different directory

I have a Bazel native.genrule that calls a python script to generate a file. In the working configuration my files are the following: Python script: ## test/sub1/test_python_script.py def test_python_import(): print("this is a function to test…
roschach
  • 8,390
  • 14
  • 74
  • 124
0
votes
1 answer

How to make cmdline with bazel genrule concatenate multiple srcs with cmdline options?

I have a cmdline tool which can accept multiple inputs with different cmd options. mytool --include=some_include1 --include=some_include2 --inlcude=... source1 source2 ... So I have to write a genrule with filegroup( name = "include_group", …
Alexander Chen
  • 417
  • 3
  • 17
0
votes
1 answer

With Bazel how do I make part of one genrules' source files (e.g. header files) available to another genrule?

Maybe this is a no-brainer and I just didn't get the concept yet. I have a genrule, basically wrapping an existing make/config workflow to integrate it into a Bazel-based build configuration. In my example I'd like to build openssl, and then (with…
frans
  • 8,868
  • 11
  • 58
  • 132
0
votes
1 answer

bazel genrule cmd that needs a filename

I am trying to run objcopy --redefine-syms=filename command in Bazel genrule. My idea is: first create the filename using echo command in the first genrule, and use the filename in objcopy command in the second genrule. But I got this error message:…
EngMe
  • 83
  • 5
0
votes
1 answer

Fetch output of ISPC using a genrule

I am trying to make use of ISPC (Implicit SPMD Program Compiler) using Bazel. Therefore, I started to implement rules_ispc. Unfortunately, I run into an issue with generating files using ispc. You can reproduce my issue by: git clone…
Vertexwahn
  • 7,709
  • 6
  • 64
  • 90
0
votes
1 answer

Running docker build with bazel genrule and a dockerfile

I have a monorepo with multiple languages and artifacts and I want to transition to Bazel. We want to build docker images using our existing Dockerfiles, using a genrule - to avoid translating all dockerfiles to docker-rules (at least at this…
Alonr
  • 1
  • 1
0
votes
1 answer

Bazel genrule where outputs depend on the input

This answer to Looking for examples of Bazel genrules that generate data files states that "A genrule needs to know all its input files and output files". Is it possible to write a genrule whose outputs depend on the input file? For…
Bulletmagnet
  • 5,665
  • 2
  • 26
  • 56