Commit e2569db7 authored by Kevin Marshall's avatar Kevin Marshall Committed by Commit Bot

Fuchsia: Generate deps entries for SDK cc_source_lib's "fidl_deps".

Fuchsia SDK source library manifests have a special entry just for
FIDL dependencies that is separate from the other dependencies. Use it!

Bug: 898088
Change-Id: Iab2fdbdefbb3b6cbf169aac81860e698108bd2a6
Reviewed-on: https://chromium-review.googlesource.com/c/1297467Reviewed-by: default avatarScott Graham <scottmg@chromium.org>
Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602403}
parent 12e3ef38
...@@ -27,23 +27,20 @@ def SerializeListOfStrings(strings): ...@@ -27,23 +27,20 @@ def SerializeListOfStrings(strings):
return '[' + ','.join(['"{}"'.format(s) for s in strings]) + ']' return '[' + ','.join(['"{}"'.format(s) for s in strings]) + ']'
def ReformatTargetName(dep_name):
"""Removes the namespace from |target| and substitutes invalid target
characters with valid ones (e.g. hyphens become underscores)."""
return dep_name.split('.')[-1].replace('-','_')
def ConvertCommonFields(json): def ConvertCommonFields(json):
"""Extracts fields from JSON manifest data which are used across all """Extracts fields from JSON manifest data which are used across all
target types.""" target types."""
output = {} return {
'target_name': ReformatTargetName(json['name']),
output['target_name'] = json['name'].replace('-', '_') 'public_deps': [':' + ReformatTargetName(dep) for dep in json['deps']]
}
output['public_deps'] = []
for package_dep in json['deps']:
# If the dep has a namespace prefix, then remove it, and replace any
# hyphens with underscores for compatibility with the GN identifier
# character set.
dep_reformatted = ':' + package_dep.split('.')[-1].replace('-','_')
output['public_deps'].extend([dep_reformatted])
return output
def FormatGNTarget(fields): def FormatGNTarget(fields):
"""Returns a GN target definition as a string. """Returns a GN target definition as a string.
...@@ -87,8 +84,9 @@ def ConvertFidlLibrary(json): ...@@ -87,8 +84,9 @@ def ConvertFidlLibrary(json):
converted['type'] = 'fuchsia_sdk_fidl_pkg' converted['type'] = 'fuchsia_sdk_fidl_pkg'
converted['sources'] = json['sources'] converted['sources'] = json['sources']
# Split "name" into "namespace" and "name" pair. # FIDL names require special handling, because the namespace needs to be
name_parts = converted['target_name'].split('.') # extracted and used elsewhere.
name_parts = json['name'].split('.')
converted['target_name'] = name_parts[-1] converted['target_name'] = name_parts[-1]
converted['namespace'] = '.'.join(name_parts[:-1]) converted['namespace'] = '.'.join(name_parts[:-1])
...@@ -131,6 +129,8 @@ def ConvertCcSourceLibrary(json): ...@@ -131,6 +129,8 @@ def ConvertCcSourceLibrary(json):
converted['sources'] = list(set(converted['sources'])) converted['sources'] = list(set(converted['sources']))
converted['include_dirs'] = [json['root'] + '/include'] converted['include_dirs'] = [json['root'] + '/include']
converted['public_deps'] += \
[':' + ReformatTargetName(dep) for dep in json['fidl_deps']]
return converted return converted
......
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