please icon indicating copy to clipboard operation
please copied to clipboard

Add copy/update support to `generate` command

Open cemeceme opened this issue 5 months ago • 1 comments

Currently, you can use plz generate //path/to:rule with a rule that contains the codegen label, to build and then soft or hard link the output back to the source tree. However, it is not possible to either copy the output or update an existing file in the source using this method.

This would be a very useful feature when dealing with things like generating translation files, which have to be edited and updated separately. That is, where a rule can extract all the required strings in the source into its output, and then a translator can edit them and add the translations. Later, when there are new strings that need to be translated in the source, the generate command can be run again to update the file with new strings.

cemeceme avatar Jul 30 '25 13:07 cemeceme

I'm not sure if this is intended or not, but I just happened to notice that updating a file like this is actually possible. Specifically, if you edit the file within a build rule, it edits the file in the source as well (I believe regardless of if the command succeeds).

However, if you try to use the generate command, it will instead replace the file in the source tree with a link to the generated one.

cemeceme avatar Aug 01 '25 17:08 cemeceme