gn2bp: sanitize eval arg from VersionSanitizer
Test: ./update_results.sh
Change-Id: Ifdae480fa013e96413ae9eaf29c81c877198962b
diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp
index 7db56a3..e3060a2 100644
--- a/tools/gn2bp/Android.bp.swp
+++ b/tools/gn2bp/Android.bp.swp
@@ -8586,7 +8586,6 @@
"$(location chrome/VERSION) " +
"-e " +
"VERSION_FULL='\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH)' " +
- " " +
"-o " +
"$(out) " +
"$(location components/cronet/version.h.in)",
@@ -8612,7 +8611,6 @@
"$(location chrome/VERSION) " +
"-e " +
"VERSION_FULL='\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH)' " +
- " " +
"-o " +
"$(out) " +
"$(location components/cronet/version.h.in)",
@@ -8638,7 +8636,6 @@
"$(location chrome/VERSION) " +
"-e " +
"VERSION_FULL='\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH)' " +
- " " +
"-o " +
"$(out) " +
"$(location components/cronet/version.h.in)",
@@ -8664,7 +8661,6 @@
"$(location chrome/VERSION) " +
"-e " +
"VERSION_FULL='\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH)' " +
- " " +
"-o " +
"$(out) " +
"$(location components/cronet/version.h.in)",
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 4c9c40c..107652c 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -769,11 +769,20 @@
arg = self._add_location_tag(arg)
return arg
+ 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])
+ 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_version_filepath)
+ self._sanitize_eval()
return super().get_args()
def get_action_sanitizer(target):
@@ -849,11 +858,6 @@
elif target.script == "//build/util/version.py":
# android_chrome_version.py is not specified in anywhere but version.py imports this file
module.tool_files.add('build/util/android_chrome_version.py')
- for i, val in enumerate(target.args):
- if val == '-e':
- # arg for -e EVAL option should be passed in -e PATCH_HI=int(PATCH)//256 format.
- target.args[i + 1] = '%s=\'%s\'' % (target.args[i + 1], target.args[i + 2])
- target.args[i + 2] = ''
script = gn_utils.label_to_path(target.script)
module.tool_files.add(script)