gn2bp: add basic action support

WARNING: this is completely untested and probably wrong in more ways
than one. Actions are not universally convertable to soong, so
"additional_args" need to be configured.

This does get us one step closer to running the script without any
errors. No new targets are supported with this CL though.

Test: //base:base
Change-Id: I38a0e05f5e9b2153fc667882f4b35de3e330f898
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 9031290..036a20b 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -667,6 +667,27 @@
 
   blueprint.add_module(module)
 
+def create_action_module(blueprint, target):
+  bp_module_name = label_to_module_name(target.name)
+  module = Module('genrule', bp_module_name, target.name)
+  module.tool_files = [target.script]
+
+  arg_string = ' '.join(target.args)
+  module.cmd = '%s %s' % (target.script, arg_string)
+
+  # TODO: is this correct?
+  module.tool_files.extend(':' + label_to_module_name(it) for it in target.deps)
+
+  # For gn actions, sources and inputs are treated equally.
+  # TODO: there should be a label_to_path function that takes a set / list.
+  module.srcs.update(gn_utils.label_to_path(it) for it in target.inputs)
+  module.srcs.update(gn_utils.label_to_path(it) for it in target.sources)
+
+  module.out.update(target.outputs)
+  blueprint.add_module(module)
+  return module
+
+
 
 def _get_cflags(target):
   cflags = {flag for flag in target.cflags if re.match(cflag_allowlist, flag)}
@@ -723,7 +744,7 @@
         name_without_toolchain == gn_utils.GEN_VERSION_TARGET:
       module = create_gen_version_module(blueprint, target, bp_module_name)
     else:
-      raise Error('Unhandled action: {}'.format(target.name))
+      module = create_action_module(blueprint, target)
   else:
     raise Error('Unknown target %s (%s)' % (target.name, target.type))