Questions tagged [starlark]

Starlark is a dialect of Python intended for use as a configuration language. Developed for the Bazel build tool and previously called Skylark.

Starlark is a dialect of Python intended for use as a configuration language. Developed for the Bazel build tool and previously called Skylark.

42 questions
0
votes
1 answer

Pass named arguments in args field in py_binary

Consider I have a py_binary : py_binary( name = "mock", srcs = ["mock.py"], args = [ "$(location @mockref//mockpackage)", ], data = [ "@mockref//:mockfile", ], deps = [ …
kartikeykant18
  • 1,737
  • 6
  • 28
  • 42
0
votes
1 answer

How do you handle include dependencies passed as #defines in Bazel?

I am attempting to build a legacy C/C++ embedded code base using Bazel. The code is separated into software sets. Because the system is embedded, there is an environment header include passed as an argument to the compiler for each software set. The…
kierench
  • 3
  • 1
0
votes
1 answer

How to pass test args in Skylark Bazel?

I'm writing some bazel tests where I need to be able to provide the full path to some file. bazel test //webservice:checkstyle-test --test_arg="path_to_some_file" My question is how can you parse the input arguments in your bazel test? Is there…
KeykoYume
  • 2,497
  • 6
  • 24
  • 48
0
votes
1 answer

Starlark debugger for Bazel in Visual Studio Code

i am new to Visual studio Code. I followed this tutorial to set up a Bazel build configuration in Visual studio code (I use Windows 10). I created a simple task.json { "version": "2.0.0", "tasks": [ { "label": "Build Example (Debug)", …
Fed
  • 207
  • 2
  • 14
0
votes
1 answer

Chain expand_template and run in one bazel rule

I am trying to write a custom rule, where I first generate a file from a template, then pass this file to a script to generate some c++ headers that are the output of my rule. def _msg_library_impl(ctx): # For each target in deps, print its label…
niosus
  • 738
  • 8
  • 22
0
votes
2 answers

bazel midl rule generated c++ header file and winmd file locates in different folder

When I use bazel to generate c++ header source code and winmd file from midl file, I found MyType.winmd file is in output folder, while MyType.h locates at same directory as source code MyType.idl. What I want is that my generated header file…
Sammi Song
  • 36
  • 7
0
votes
1 answer

Is there a way to directly access the built-in types of starlark language in Bazel?

For example, is there a way to call the constructor of File class to create an instance of it?
xiay
  • 855
  • 8
  • 19
0
votes
1 answer

Read file content in WORKSPACE

I'm using container_pull in my WORKSPACE file. (It's part of bazel docker rules) Here is what it looks like: container_pull( name = "base-image", registry = "registry:9999", repository = "base-image", digest =…
Emran
  • 544
  • 7
  • 26
0
votes
1 answer

What is the most efficient way to extract/collect files from a list of targets/providers in Bazel?

I'm writing some rules and learning Starlark as I progress. Assume I have my own provider: ModularResources = provider( doc = "Modular resources", fields = { "artifactId": "Former Maven artifact id (don't ask me why)", …
Gunnar
  • 2,264
  • 17
  • 31
0
votes
0 answers

Obtain base directory for declared files

Sometimes in my bazel rules I need to run a tool which produces bunch of files but writes them into output directory and directory path should be used as argument. So I ended up with following pattern: out_dir = "{}_out".format(ctx.label) out_files…
0
votes
1 answer

How do I implement local_archive() in starlark

I want to implement a starlark repository rule that takes a tar.gz from the WORKSPACE directory (I'm putting files in git LFS there) and extracts it, then uses the extracted contents as an external repository (i.e., extracts the file, then does the…
Silas Snider
  • 1,460
  • 1
  • 14
  • 23
0
votes
1 answer

Does bazel theoretically allow http requests inside bazel build rules?

Is there any possibility to write http requests in starlark build rule or via some executable invoked by ctx.actions.run ? I know it can be done with bazel test (inside test runners), but can it be done in build phase? I know this goes against…
Natan
  • 1,944
  • 1
  • 11
  • 16
1 2
3