gn2bp: Add `get_cmd` logic.

* Move the creation of cmd implementation to `BaseActionSanitizer`. This is important because we don't want to expose the target args as this will change the original target.

Test: update_results.sh
Change-Id: I4932408d8add345ed8e480b0dc2cd65e73d54b09
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 6686f99..4077ab7 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -108,7 +108,8 @@
 # Location of the protobuf src dir in the Android source tree.
 android_protobuf_src = 'external/protobuf/src'
 
-
+# put all args on a new line for better diffs.
+NEWLINE = ' " +\n         "'
 
 # Compiler flags which are passed through to the blueprint.
 cflag_allowlist = [
@@ -731,7 +732,14 @@
     return self.target.args
 
   def get_cmd(self):
-    return ""
+    arg_string = NEWLINE.join(self.target.args)
+    cmd = '$(location %s) %s' % (
+    gn_utils.label_to_path(self.target.script), arg_string)
+
+    if self.use_response_file:
+      # Pipe response file contents into script
+      cmd = 'echo \'%s\' |%s%s' % (self.target.response_file_contents, NEWLINE, cmd)
+    return cmd
 
   def get_outputs(self):
     return self.target.outputs
@@ -884,6 +892,7 @@
   sanitizer = get_action_sanitizer(target)
   sanitizer.sanitize()
   target.args = sanitizer.get_args()
+  module.cmd = sanitizer.get_cmd()
   module.out = sanitizer.get_outputs()
   if sanitizer.is_header_generated():
     module.genrule_headers.add(module.name)
@@ -907,15 +916,6 @@
   script = gn_utils.label_to_path(target.script)
   module.tool_files.add(script)
 
-  # 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 sanitizer.use_response_file:
-    # Pipe response file contents into script
-    module.cmd = 'echo \'%s\' |%s%s' % (target.response_file_contents, NEWLINE, module.cmd)
-
   # gn treats inputs and sources for actions equally.
   # soong only supports source files inside srcs, non-source files are added as
   # tool_files dependency.