gn2bp: Add escape quotations as part of BaseActionSanitizer
* Quotations escaping is a universal operation that would benefit every subclass. Moving this up in the BaseActionSanitizer to cover for the `java_genrule` errors.
Test: update_results.sh
Change-Id: If6a7296b85170294b596566da413332fe395913f
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 218ea2a..c2dae3f 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -627,8 +627,10 @@
def _normalize_args(self):
# Convert ['--param=value'] to ['--param', 'value'] for consistency.
+ # Escape quotations.
normalized_args = []
for arg in self.target.args:
+ arg = arg.replace('"', r'\"')
if arg.startswith('-'):
normalized_args.extend(arg.split('='))
else:
@@ -838,7 +840,6 @@
# args for the version.py contain file path without leading --arg key. So apply sanitize
# function for all the args.
self._update_all_args(self._sanitize_filepath_with_location_tag)
- self._update_value_arg('-e', lambda arg: arg.replace('"', r'\"'))
super()._sanitize_args()
class JavaCppEnumSanitizer(BaseActionSanitizer):