gn2bp: merge pre_create_action_module into create_action_module
Having access to the created Module object will become useful for
target-specific modifications.
Test: //base:base
Change-Id: I48b8a854f39d280b2be36741276981e028efe04d
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 88b2b5a..4505b7a 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -666,9 +666,10 @@
blueprint.add_module(module)
-# There may be a better way to do target specific modification
-# Target specific modification before create_action_module
-def pre_create_action_module(target):
+def create_action_module(blueprint, target):
+ bp_module_name = label_to_module_name(target.name)
+ module = Module('genrule', bp_module_name, target.name)
+
# Convert ['--param=value'] to ['--param', 'value'] for consistency.
# TODO: we may want to only do this for python scripts arguments. If argparse
# is used, this transformation is safe.
@@ -697,10 +698,6 @@
filename = re.sub('^\.\./\.\./', '', target.args[i + 1])
target.args[i + 1] = '$(location %s)' % filename
-
-def create_action_module(blueprint, target):
- bp_module_name = label_to_module_name(target.name)
- module = Module('genrule', bp_module_name, target.name)
script = gn_utils.label_to_path(target.script)
module.tool_files.add(script)
@@ -805,7 +802,6 @@
name_without_toolchain == gn_utils.GEN_VERSION_TARGET:
module = create_gen_version_module(blueprint, target, bp_module_name)
else:
- pre_create_action_module(target)
module = create_action_module(blueprint, target)
elif target.type == 'copy':
# TODO: careful now! copy targets are not supported yet, but this will stop