bazel-contrib / bazel-contrib/bazel-lib

Should it matter if `write_source_files` goes to the same file?

Open
#1,058 1 comment 0 reactions 0 assignees View on GitHub
can close?
Dominant language
Starlark
Stars
182
Forks
134
Avg merge
1d 46m
Merged PRs (30d)
1

Description

```starlark
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")

copy_file(
name = "foobar",
src = "//some/generated:file",
out = "foobar.json",
)

write_source_files(
name = "write_foobar",
files = {
"foobar.json": ":foobar",
},
)
```

This will complain that `foobar.json` is the same file as `foobar.json`.

Should this be an error?
They have (by definition) the same contents

I am using `copy_file` to get the file into the correct position for usage by another tool.

Contributor guide

Open the contributing guide

Research direction

Start with lib:write_source_files.bzl and trace how the files mapping is checked when copy_file produces the same output path. Reproduce the shown Starlark configuration, then determine whether identical source and destination paths should be accepted; done means the behavior is decided and covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.