-
Notifications
You must be signed in to change notification settings - Fork 4.1k
bazel: dev generate bazel trashes generated files if it fails before re-generating them #76503
Copy link
Copy link
Closed
Labels
A-build-systemC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Description
(This is a new issue / regression - did not fail in this way as late as one or two weeks ago)
Describe the problem
-
I started with a working, building repository.
-
I ran
dev generate bazel. -
The command failed to complete due to some missing UI tool.
-
As a result, all the previously-good generated files were removed, causing the following git diff:
modified pkg/gen/docs.bzl…
modified pkg/gen/excluded.bzl…
modified pkg/gen/execgen.bzl…
modified pkg/gen/gomock.bzl…
modified pkg/gen/misc.bzl…
modified pkg/gen/optgen.bzl…
modified pkg/gen/protobuf.bzl…
modified pkg/gen/stringer.bzl…
(all these files had empty contents)
It's important that generated files remain in-place even when a generate command fails.
The “traditional” algorithm for file generation is this:
file:
generate >file.tmp || rm -f file.tmp
mv -f file.tmp file
This way if the generate file fails, the tmp file gets deleted and the final file does not get altered.
It would be good if dev generate would use the same idea for all generated files.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-build-systemC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.