gn2bp: fix genrule cmd escaping
Test: //net:net
Change-Id: Ie85b61e3b42421766e5ab8010579eae1fba15e69
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 27f69d2..53b138b 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -736,6 +736,12 @@
# Replace {{response_file_contents}} with /dev/stdin
target.args = ['/dev/stdin' if it == response_file else it for it in target.args]
+ # escape " and \$ in target.args.
+ # once all actions are properly implemented, this may not be necessary anymore.
+ # TODO: is this the right place to do this?
+ target.args = [arg.replace('"', r'\"') for arg in target.args]
+ target.args = [arg.replace(r'\$', r'\\$') for arg in target.args]
+
# put all args on a new line for better diffs.
NEWLINE = ' " +\n "'
arg_string = NEWLINE.join(target.args)