caeus
caeus

Reputation: 3716

Define target by reading a file in the package. (Bazel)

So in the spirit of migrating from gradle to bazel, we started moving all configuration from .gradle files to .yaml files.

.gradle file is now generically reading that .yaml file, and configuring the project with what's defined in it.

I'd like to do the same in Bazel. Have Bazel read from such yaml file, and define the targets using that info.

That may be against the principles of Bazel, I fear. But then, how can I make an attribute depend on what another target calculates?

Upvotes: 0

Views: 300

Answers (1)

Brian Silverman
Brian Silverman

Reputation: 3848

The way to generate BUILD files is a custom repository rule. Basically you can write rules which run before the main part of the build and generate targets. Make sure to pay attention to the ways of informing Bazel that your repository rule reads a file so Bazel can re-run it when the file changes.

Upvotes: 1

Related Questions