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
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
6
votes
2 answers

How to make a path from a string in starlark?

I'm writing some validation code for a bazel build rule and I need to do some path validation. I need to check that a certain file exists in the same directory as the BUILD file. I notice that there's a context attribute build_file_path which points…
Paymahn Moghadasian
  • 9,301
  • 13
  • 56
  • 94
4
votes
1 answer

How to properly load a Starlark script into another?

I'm trying to make a very simple implementation with Starlark: greeting.bzl def greet(): print ("Hello World!") test.bzl load (":greeting.bzl", "greet") greet() And execute it with: java -jar Starlark_deploy.jar test.bzl The result of the…
Humble Student
  • 3,755
  • 4
  • 20
  • 35
3
votes
1 answer

Instantiating a Bazel macro twice with same generated output file

Suppose I have a Bazel macro that is using a generator rule to generate an output file given an input file: def my_generator( name, input_file, output_file, **kwargs): args = [] args.extend(["--arg1",…
roschach
  • 8,390
  • 14
  • 74
  • 124
3
votes
1 answer

Skylark struct with methods

Here's something I tried to do, and it works well. I find it useful, but it feels like a hack, so I'm afraid it will break in the future. I'm working on converting a large project to Bazel, and we have lots of local wrappers, something…
ugoren
  • 16,023
  • 3
  • 35
  • 65
2
votes
3 answers

How to round output values in telegraf?

I'm looking for a way to round the values output from telergaf. Temperature, usage_idle, memory_usage, etc... to 14 decimals is very huge. It too much for me. It can double some of my measurements. I haven't found a way to do it easily. Now I have…
2
votes
1 answer

Getting runtime path to a package in Bazel toolchain configuration files

What is the best way to refer to an external package's path in any arbitrary files processed by Bazel? I'm trying to understand how Bazel preprocesses BUILD and .bzl files. I see instances where strings contain calls to package() and I am wondering…
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

Bazel - How to Read a String from An Environment File?

I have several k8s_object rules in my project and I supply each of them with the same cluster name like this: k8s_object( name = "k8s_service", kind = "service", cluster = "gke_cents-ideas_europe-west3-b_cents-ideas", template =…
Florian Ludewig
  • 4,338
  • 11
  • 71
  • 137
2
votes
2 answers

Bazel C++ precompiled headers implementation

I have written an MSVC Precompiled Header Files (PCH) implementation for Bazel (2.0) and would like to get some feedback on it as I'm not happy with it. To quickly recap what needs to be done to get PCH working in MSVC: Compile the PCH with /Yc and…
thfabian
  • 125
  • 9
2
votes
1 answer

How to write a Bazel test rule using a provided tool rather than a rule-built one?

I have a test tool (roughly, a diffing tool) that takes two inputs, and returns both an output (the difference between the two inputs), and a return code (0 if the two inputs are matching, 1 otherwise). It's built in Kotlin, and available at…
Marc Plano-Lesay
  • 6,808
  • 10
  • 44
  • 75
1
vote
1 answer

How do I pass user-defined build settings to existing Bazel rules?

I'd like to migrate away from --define flags and to build settings per: https://docs.bazel.build/versions/5.0.0/skylark/config.html Here's the rule to which I'd like to pass command line values. Can this be done in practice when using loaded…
1
vote
1 answer

Is Starlark Turning Complete?

The Starlark configuration language does not support infinite loops or recursion or user defined data types but it does support functions. The docs indicate that means that the language is not Turing complete. I have forgotten a lot of my Computer…
ams
  • 60,316
  • 68
  • 200
  • 288
1
vote
0 answers

How to create rule which when run will also run dependent target first

I am trying to create Bazel rule which would execute docker-compose command and spin up all docker images from docker-compose.yaml file. I was able to get this going but my next step is to make my rule depend on another container_image target from…
1
2 3