gn2bp: Fix arg normalization and remove hack in the VersionSanitizer
There are cmd diffs in Android.bp.swp but it is verified the updated
cmds works.
Test: ./update_results.sh
Change-Id: Iaf916f9de12b18b4e5402fcccd2b154f72a6ac8d
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 5295fde..26f5726 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -626,7 +626,10 @@
# Convert ['--param=value'] to ['--param', 'value'] for consistency.
normalized_args = []
for arg in self.target.args:
- normalized_args.extend(arg.split('='))
+ if arg.startswith('-'):
+ normalized_args.extend(arg.split('='))
+ else:
+ normalized_args.append(arg)
return normalized_args
# There are three types of args:
@@ -768,22 +771,12 @@
return super().get_args()
class VersionSanitizer(BaseActionSanitizer):
- def _sanitize_eval(self):
- assert (self._is_value_arg('-e'))
- # arg for -e EVAL option should be passed in -e PATCH_HI=int(PATCH)//256 format.
- index = self.target.args.index('-e')
- value = '%s=\'%s\'' % (self.target.args[index + 1], self.target.args[index + 2])
- # escape '"' in the value
- value = value.replace('"', r'\"')
- self._set_arg_at(index + 1, value)
- self.target.args.pop(index + 2)
-
def get_args(self):
self._set_value_arg('-o', '$(out)')
# 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._sanitize_eval()
+ self._update_value_arg('-e', lambda arg: arg.replace('"', r'\"'))
return super().get_args()
class JavaCppEnumSanitizer(BaseActionSanitizer):