bazelbuild / bazelbuild/rules_pkg

Suggestion: Option to give a dictionary of srcs for easier folder arrangement

Open
#597 1 comment 0 reactions 0 assignees View on GitHub
p4
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.