cargo2android: Fix edge case in --add_workspace feature

If the last line of a Cargo.toml was a `[*]`, then appending
`[workspace]` without newlines would result in an invalid toml file.

external/crosvm/tracing/Cargo.toml is an example.

Test: ran on crosvm
Change-Id: Ib949e7f92d0205b1bc6433d1e231924832ddb536
This commit is contained in:
Frederick Mayle
2022-07-27 00:13:52 +00:00
parent 5a5aa3357a
commit 71722b10e5

View File

@@ -1360,7 +1360,7 @@ class Runner(object):
print('### WARNING: found [workspace] in Cargo.toml')
else:
with open(cargo_toml, 'a') as out_file:
out_file.write('[workspace]\n')
out_file.write('\n\n[workspace]\n')
added_workspace = True
if self.args.verbose:
print('### INFO: added [workspace] to Cargo.toml')