nouveau/headers: Run rustfmt after file is closed

If we run a subprocess while the file is still open, we may not have
flushed the file contents to disk.

Fixes: 591b5da4 ("nouveau/headers: Run rustfmt on generated files")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35008>
This commit is contained in:
Mel Henning
2025-05-15 16:14:02 -04:00
committed by Marge Bot
parent 20222cd956
commit da22094593
+5 -5
View File
@@ -109,11 +109,6 @@ def main():
try:
with open(args.out_rs, 'w', encoding='utf-8') as f:
f.write(TEMPLATE_RS.render(root=root))
try:
subprocess.run(['rustfmt', args.out_rs], check=True)
except (subprocess.CalledProcessError, FileNotFoundError):
pass
except Exception:
# In the event there's an error, this imports some helpers from mako
# to print a useful stack trace and prints it, then exits with
@@ -124,5 +119,10 @@ def main():
print(exceptions.text_error_template().render(), file=sys.stderr)
sys.exit(1)
try:
subprocess.run(['rustfmt', args.out_rs], check=True)
except (subprocess.CalledProcessError, FileNotFoundError):
pass
if __name__ == '__main__':
main()