So I'm playing with codegen (I've created a target...
# plugins
p
So I'm playing with codegen (I've created a target, a GenerateSourcesRequest, and a rule). The rule is using some bogus content 😛
asdf\n
to test outputing a "generated" file. Writing the "generated" file works as expected. But
./pants export-codegen
puts all generated files under
dist/codegen
- is there a way to get that written (or moved/copied) to the actual workspace? Or is there a better generic goal that will update a generated file in the workspace? I don't want to create a custom goal for this.
c
Ah, the codegen is by design for producing content ad-hoc for consumption by other rules in their sandboxes, so the “only” way to get it out is as you’ve discovered to the
dist/codegen
path.. Perhaps a
experimental_run_shell_command
could take that generated content as input (i.e. as a dependency) and have a small shell script that copies it out into your source tree. And that would be triggered by a
./pants run :your_shell_command
p
I could tie it to the fmt goal, though that feels a little odd. I need to make sure that some files (a conf file and some jsonschema specs) get both generated and checked into source control whenever the python sources change. It has to be in source control, because people consume them via GitHub raw content urls.
Can lint/fmt depend on / trigger codegen? If so, then lint would compare the workspace file with dist/codegen and fail if they differ, and fmt would copy from dist/codegen to the workspace.
c
Pass. @hundreds-father-404?