load() arbitary file
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the problem / feature request:
`load_content()` loads the content of the file label into a variable. Syntax would be restricted to top-level load-ish restrictions.
Example usage:
```python
load_content("//example:file.json, "example")
example_parsed = json_parse(example) # https://github.com/erickj/bazel_json
```
Alternatively, the `load()` function could be augmented in some way.
### Feature requests: what underlying problem are you trying to solve with this feature?
I want to import data sets into WORKSPACE/BUILD files: dependency lock files, bazel query-type results.
Current approaches:
* Use a repository rule to read the content, but this can cause extra levels of WORKSPACE complication, e.g. https://github.com/bazelbuild/rules_jvm_external/issues/265
* Only store data in Starlark syntax. However, (1) this is harder for other tools to generate (2) this is harder for other tools to analyze.
### Have you found anything relevant by searching the web?
https://stackoverflow.com/a/56034788/1212596
https://github.com/bazelbuild/bazel/issues/3766
https://github.com/bazelbuild/bazel/pull/7309
### Any other information, logs, or outputs that you want to share?
What reasons are there for build-time data is restricted to *.bzl files/Starlark syntax? AFAIK there is none, other than consistency.
Contributor guide
Research direction
The request centers on load_content(), load(), and importing data into WORKSPACE/BUILD files. Start by reviewing the existing load restrictions and the linked Bazel issue 3766 and pull request 7309, then clarify whether arbitrary file loading or an augmented load() is intended. Done means an agreed feature shape, scope, and constraints.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100