Commit 312e65e1 by Geoff Lang Committed by Commit Bot

Make sure all target names are unique in the generate Android.bp

generate_android_bp.py prepends "angle_" to target names to avoid conflicts with other Android projects. This can sometimes generate conflicts when there are two targets such as "angle_vulkan_headers" and "vulkan_headers". This patch turns the gn path+target into the blueprint target name. BUG= b/155396154 Change-Id: I7a709013969ae8e312a781a2fd3c1ec530fca430 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2173833 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent 7e5d7dc3
......@@ -82,13 +82,30 @@ def gn_target_to_blueprint_target(target, target_info):
if 'output_name' in target_info:
return target_info['output_name']
# Prefix all targets with angle_
# Remove the prefix //: from gn target names
cleaned_path = re.sub(r'^//.*:', '', target)
prefix = "angle_"
if not cleaned_path.startswith(prefix):
cleaned_path = prefix + cleaned_path
return cleaned_path
# Split the gn target name (in the form of //gn_file_path:target_name) into gn_file_path and
# target_name
target_regex = re.compile(r"^//([a-zA-Z0-9\-_/]*):([a-zA-Z0-9\-_\.]+)$")
match = re.match(target_regex, target)
assert match != None
gn_file_path = match.group(1)
target_name = match.group(2)
assert len(target_name) > 0
# Clean up the gn file path to be a valid blueprint target name.
gn_file_path = gn_file_path.replace("/", "_").replace(".", "_").replace("-", "_")
# Generate a blueprint target name by merging the gn path and target so each target is unique.
# Prepend the 'angle' prefix to all targets in the root path (empty gn_file_path). Skip this step if the target name already starts with 'angle' to avoid target names such as 'angle_angle_common'.
root_prefix = "angle"
if len(gn_file_path) == 0 and not target_name.startswith(root_prefix):
gn_file_path = root_prefix
# Avoid names such as _angle_common if the gn_file_path is empty.
if len(gn_file_path) > 0:
gn_file_path += "_"
return gn_file_path + target_name
def remap_gn_path(path):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment