Skip to content

Always use generated subtargets #10455

@Eric-Arellano

Description

@Eric-Arellano

Currently, if there are multiple owners of a source file, then we do not use generated subtargets:

if file_name in file_name_to_generated_address:
file_names_with_multiple_owners.add(file_name)
original_addresses_due_to_multiple_owners.add(candidate_tgt.address)
# We also add the original target of the generated address already stored.
already_stored_generated_address = file_name_to_generated_address[file_name]
original_addresses_due_to_multiple_owners.add(
already_stored_generated_address.maybe_convert_to_base_target()
)

We solely do this to avoid the representation problem of how to represent a file address when there are multiple of them, but they have different generated_base_target_name. In Pants output, like ./pants list, we would show the same file foo.txt multiple times, which looks redudant, even though they're different targets. We'd need a syntax like foo.txt@:original to show the base target when there was ambiguity.

--

Why change this?

  1. It makes the experience with file arguments more consistent for end users. We no longer have a special case. When using file args, you always get generated subtargets / files, no matter what.
  2. We can remove AddressWithOrigin et al. The only reason we use WithOrigin right now is for SpecifiedSourceFiles. If we fix this issue, then there is no need for SpecifiedSourceFiles as described in Optimize generated subtargets' interaction with SpecifiedSourceFiles #10454. This results in much less complexity for plugin authors to no longer need to know about OriginSpec.

--

Note that we will continue to need to use the original owning address if we detect a deleted file:

deleted_files_matched = bool(set(matching_files) - all_source_files)
if deleted_files_matched:
original_addresses_due_to_deleted_files.add(candidate_tgt.address)

This is important for --changed-since to work properly.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions