bazelbuild / bazelbuild/rules_pkg
Suggestion: Option to give a dictionary of srcs for easier folder arrangement
- Dominant language
- Starlark
- Stars
- 253
- Forks
- 221
- Avg merge
- 10h 33m
- Merged PRs (30d)
- 1
Description
I think the ergonomics of these rules could be greatly improved by allowing `srcs` to be a dictionary, where the keys are paths in the package (zip, tar, etc.) and the values are labels.
The behavior when a list is given as `srcs` would be unchanged.
For example, given this source-tree:
```
.
├── a
│ └── apple.txt
├── banana.txt
└── c
└── h
└── cherry.txt
```
And this rule:
```python
pkg_zip(
name = "test",
srcs = {
"apple/apple.txt": "a/apple.txt",
"banana/banana.txt": "banana.txt",
"cherry/cherry.txt": "c/h/cherry.txt",
}
)
```
The tree in the zip would be:
```
.
├── apple
│ └── apple.txt
├── banana
│ └── banana.txt
└── cherry
└── cherry.txt
```
**Advantages**
- A very natural way to create complex folder structures
- Not a breaking change (can test if a dictionary or list is provided)
- This approach is already used successfully in Buck for C/C++ headers
Related: https://github.com/bazelbuild/rules_pkg/issues/354
Contributor guide
Assessment
This issue has not been assessed yet.