bazelbuild / bazelbuild/bazel

Allow starlark rules to expand directories of srcs

Open
#21,031 6 comments 5 reactions 0 assignees View on GitHub
not stale P3 team-Rules-API type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the feature request:

If you have a rule that outputs a tree artifact, native rules like `objc_library` can accept the tree artifact in its `srcs` and internally (in java) it can expand the files to make action mappings knowing each file that the directory contains. For example if you have `dir/a.m` `dir/b.m` it will make actions to output `dir/a.o` and `dir/b.o`. Starlark rules just get the directory for processing, and while the files in the directory are expanded by `actions.run`, the expected outputs for this case cannot be setup correctly.

### Which category does this issue belong to?

Rules API

### What underlying problem are you trying to solve with this feature?

`swift_library` cannot accept directories in their `srcs` correctly https://github.com/bazelbuild/rules_swift/issues/969

### Which operating system are you running Bazel on?

macOS

### What is the output of `bazel info release`?

release 7.0.2

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

### What's the output of `git remote get-url origin; git rev-parse HEAD` ?

_No response_

### Have you found anything relevant by searching the web?

_No response_

### Any other information, logs, or outputs that you want to share?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the Rules API behavior around actions.run and compare how native objc_library handles tree artifacts and expands directory contents. Use the swift_library directory-srcs problem as the motivating case; done means Starlark rules can define expected outputs for expanded tree artifacts so directory-valued srcs work correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.