From 71722b10e5df36b3508e1afe165c3831cde13e2a Mon Sep 17 00:00:00 2001 From: Frederick Mayle Date: Wed, 27 Jul 2022 00:13:52 +0000 Subject: [PATCH] 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 --- scripts/cargo2android.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cargo2android.py b/scripts/cargo2android.py index a9d57ebeb..3071a10a3 100755 --- a/scripts/cargo2android.py +++ b/scripts/cargo2android.py @@ -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')