gn2bp: Move replacing of `response_file` to Sanitizer

* This was affecting the original target args as it was being executed after setting target.args . So this is a step in maintaining the original target as a read-only object.

Test: update_results.sh
Change-Id: I6852dbecbd1ce304af091f3e4d00e0d698cd53f8
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 3f1318b..3737130 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -108,6 +108,8 @@
 # Location of the protobuf src dir in the Android source tree.
 android_protobuf_src = 'external/protobuf/src'
 
+response_file = '{{response_file_name}}'
+
 # Compiler flags which are passed through to the blueprint.
 cflag_allowlist = [
   # needed for zlib:zlib
@@ -732,7 +734,14 @@
     return self.target.outputs
 
   def _sanitize_args(self):
-    pass
+    # Handle passing parameters via response file by piping them into the script
+    # and reading them from /dev/stdin.
+
+    self.use_response_file = response_file in self.target.args
+    if self.use_response_file:
+      # Replace {{response_file_contents}} with /dev/stdin
+      self.target.args = ['/dev/stdin' if it == response_file else it for it in
+                          self.target.args]
 
   def _sanitize_outputs(self):
     pass
@@ -895,20 +904,12 @@
   script = gn_utils.label_to_path(target.script)
   module.tool_files.add(script)
 
-  # Handle passing parameters via response file by piping them into the script
-  # and reading them from /dev/stdin.
-  response_file = '{{response_file_name}}'
-  use_response_file = response_file in target.args
-  if use_response_file:
-    # Replace {{response_file_contents}} with /dev/stdin
-    target.args = ['/dev/stdin' if it == response_file else it for it in target.args]
-
   # put all args on a new line for better diffs.
   NEWLINE = ' " +\n         "'
   arg_string = NEWLINE.join(target.args)
   module.cmd = '$(location %s) %s' % (script, arg_string)
 
-  if use_response_file:
+  if sanitizer.use_response_file:
     # Pipe response file contents into script
     module.cmd = 'echo \'%s\' |%s%s' % (target.response_file_contents, NEWLINE, module.cmd)