Merge changes Ie937102c,I47405379,Ic88a99ed,I37ad0250,I1583db83

* changes:
  gn2bp: change filegroup to cc_defaults
  gn2bp: change remove to discard
  gn2bp: move module_is_compiled to Module class
  gn2bp: using dep.name when adding dependency is more correct
  gn2bp: properly add proto_deps
This commit is contained in:
Motomu Utsumi
2022-11-17 06:36:24 +00:00
committed by Gerrit Code Review
3 changed files with 438 additions and 436 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -377,6 +377,9 @@ class Module(object):
value = getattr(self, name)
return write_blueprint_key_value(output, name, value, sort)
def is_compiled(self):
return self.type not in ('genrule', 'filegroup', 'cc_defaults')
class Blueprint(object):
"""In-memory representation of an Android.bp file."""
@@ -990,7 +993,7 @@ def create_modules_from_target(blueprint, gn, gn_target_name):
elif target.type == 'shared_library':
module = Module('cc_library_shared', bp_module_name, gn_target_name)
elif target.type == 'source_set':
module = Module('filegroup', bp_module_name, gn_target_name)
module = Module('cc_defaults', bp_module_name, gn_target_name)
elif target.type == 'group':
# "group" targets are resolved recursively by gn_utils.get_target().
# There's nothing we need to do at this level for them.
@@ -1070,8 +1073,7 @@ def create_modules_from_target(blueprint, gn, gn_target_name):
module.local_include_dirs.append(sysroot + "/usr/include/x86_64-linux-gnu")
module.local_include_dirs.append(sysroot + "/usr/include")
module_is_compiled = module.type not in ('genrule', 'filegroup')
if module_is_compiled:
if module.is_compiled():
module.host_supported = target.host_supported()
module.device_supported = target.device_supported()
@@ -1124,8 +1126,9 @@ def create_modules_from_target(blueprint, gn, gn_target_name):
module.genrule_headers.add(dep_module.name)
module.genrule_headers.update(dep_module.genrule_headers)
# For filegroups and genrule, recurse but don't apply the deps.
if not module_is_compiled:
# For cc_defaults, filegroups, and genrule, recurse but don't apply the
# deps.
if not module.is_compiled():
continue
if dep_module is None:
@@ -1134,8 +1137,8 @@ def create_modules_from_target(blueprint, gn, gn_target_name):
module.shared_libs.add(dep_module.name)
elif dep_module.type == 'cc_library_static':
module.static_libs.add(dep_module.name)
elif dep_module.type == 'filegroup':
module.srcs.add(':' + dep_module.name)
elif dep_module.type == 'cc_defaults':
module.defaults.append(dep_module.name)
elif dep_module.type == 'genrule':
module.generated_headers.update(dep_module.genrule_headers)
module.srcs.update(dep_module.genrule_srcs)
@@ -1160,7 +1163,7 @@ def create_modules_from_target(blueprint, gn, gn_target_name):
module.srcs.clear()
elif module.name == "cronet_aml_third_party_boringssl_boringssl":
x86_srcs = module.srcs.copy()
x86_srcs.remove(":cronet_aml_third_party_boringssl_boringssl_asm")
x86_srcs.discard(":cronet_aml_third_party_boringssl_boringssl_asm")
x86_srcs.add(":cronet_aml_third_party_boringssl_boringssl_asm_x86")
module.arch['x86'] = {'srcs': x86_srcs}
module.arch['x86_64'] = {'srcs': module.srcs.copy()}

View File

@@ -280,7 +280,9 @@ class GnParser(object):
target.proto_paths.update(self.get_proto_paths(proto_desc))
target.proto_exports.update(self.get_proto_exports(proto_desc))
target.proto_in_dir = self.get_proto_in_dir(proto_desc)
target.deps.update(proto_desc.get('deps', []))
for gn_proto_deps_name in proto_desc.get('deps', []):
dep = self.parse_gn_desc(gn_desc, gn_proto_deps_name)
target.deps.add(dep.name)
target.arch[arch].sources.update(proto_desc.get('sources', []))
assert (all(x.endswith('.proto') for x in target.arch[arch].sources))
elif target.type == 'source_set':
@@ -324,24 +326,23 @@ class GnParser(object):
# Recurse in dependencies.
for gn_dep_name in desc.get('deps', []):
dep = self.parse_gn_desc(gn_desc, gn_dep_name)
dep_name = label_without_toolchain(gn_dep_name)
if dep.is_third_party_dep_:
target.deps.add(dep_name)
target.deps.add(dep.name)
elif dep.type == 'proto_library':
target.proto_deps.add(dep_name)
target.transitive_proto_deps.add(dep_name)
target.proto_deps.add(dep.name)
target.transitive_proto_deps.add(dep.name)
target.proto_paths.update(dep.proto_paths)
target.transitive_proto_deps.update(dep.transitive_proto_deps)
elif dep.type == 'source_set':
target.source_set_deps.add(dep_name)
target.source_set_deps.add(dep.name)
target.update(dep) # Bubble up source set's cflags/ldflags etc.
elif dep.type == 'group':
target.update(dep) # Bubble up groups's cflags/ldflags etc.
elif dep.type in ['action', 'action_foreach', 'copy']:
if proto_target_type is None:
target.deps.add(dep_name)
target.deps.add(dep.name)
elif dep.type in LINKER_UNIT_TYPES:
target.deps.add(dep_name)
target.deps.add(dep.name)
elif dep.type == 'java_group':
# Explicitly break dependency chain when a java_group is added.
# Java sources are collected and eventually compiled as one large
@@ -351,7 +352,7 @@ class GnParser(object):
if dep.type == 'static_library':
# Bubble up static_libs. Necessary, since soong does not propagate
# static_libs up the build tree.
target.transitive_static_libs_deps.add(dep_name)
target.transitive_static_libs_deps.add(dep.name)
target.transitive_static_libs_deps.update(dep.transitive_static_libs_deps)
target.deps.update(target.transitive_static_libs_deps)