Merge changes I7728eb4f,Ia31285bd,I7d08e055,I492d40ff

* changes:
  gn2bp: Remove hardcoded arch support
  gn2bp: Remove .h files from srcs
  gn2bp: Update protoc tool name
  gn2bp: Make local_include_dir order deterministic
This commit is contained in:
Mohannad Farrag
2022-11-17 12:57:56 +00:00
committed by Gerrit Code Review
2 changed files with 346 additions and 834 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -291,7 +291,6 @@ class Module(object):
self.stubs = {}
self.cppflags = set()
self.rtti = False
self.arch = dict()
def to_string(self, output):
if self.comment:
@@ -340,7 +339,6 @@ class Module(object):
self._output_field(output, 'cppflags')
if self.rtti:
self._output_field(output, 'rtti')
self._output_field(output, 'arch')
target_out = []
for arch, target in sorted(self.target.items()):
@@ -406,10 +404,6 @@ def label_to_module_name(label):
module = re.sub(r'^//:?', '', label)
module = re.sub(r'[^a-zA-Z0-9_]', '_', module)
# If it's required to support multi toolchain for more targets, it's better to avoid hardcoding.
if label == "//third_party/boringssl:boringssl_asm(//build/toolchain/android:android_clang_x86)":
module += "_x86"
if not module.startswith(module_prefix):
return module_prefix + module
return module
@@ -437,7 +431,7 @@ def create_proto_modules(blueprint, gn, target):
"""
assert (target.type == 'proto_library')
protoc_gn_target_name = "//third_party/protobuf:protoc(//build/toolchain/linux:clang_x64)"
protoc_gn_target_name = gn.get_target('//third_party/protobuf:protoc').name
protoc_module_name = label_to_module_name(protoc_gn_target_name)
tools = {protoc_module_name}
cpp_out_dir = '$(genDir)/%s/%s/' % (tree_path, target.proto_in_dir)
@@ -1035,8 +1029,10 @@ def create_modules_from_target(blueprint, gn, gn_target_name):
# Add arch-specific properties
for arch_name, arch in target.arch.items():
module.target[arch_name].srcs.update(gn_utils.label_to_path(src)
for src in arch.sources)
module.target[arch_name].srcs.update(
gn_utils.label_to_path(src)
for src in arch.sources
if is_supported_source_file(src) and not src.startswith("//out/test"))
local_include_dirs_set = set()
if target.type in gn_utils.LINKER_UNIT_TYPES:
@@ -1066,7 +1062,7 @@ def create_modules_from_target(blueprint, gn, gn_target_name):
# Order matters for some targets. For example, base/time/time_exploded_icu.cc
# in //base:base needs to have sysroot include after icu/source/common
# include. So adding sysroot include at the end.
for flag in target.cflags:
for flag in sorted(target.cflags):
if '--sysroot' in flag:
sysroot = flag[len('--sysroot=../../'):]
if sysroot == "build/linux/debian_bullseye_amd64-sysroot":
@@ -1150,25 +1146,6 @@ def create_modules_from_target(blueprint, gn, gn_target_name):
raise Error('Unknown dep %s (%s) for target %s' %
(dep_module.name, dep_module.type, module.name))
# TODO: support arch difference in generic way
# Currently, it is expected that only a couple of modules (e.g. partition_alloc, boringssl)
# need arch condition. So, for now, hardcoding arch condition
if module.name == "cronet_aml_base_allocator_partition_allocator_partition_alloc":
x86_srcs = module.srcs.copy()
x86_srcs.discard(
"base/allocator/partition_allocator/starscan/stack/asm/x64/push_registers_asm.cc")
x86_srcs.add("base/allocator/partition_allocator/starscan/stack/asm/x86/push_registers_asm.cc")
module.arch['x86'] = {'srcs': x86_srcs}
module.arch['x86_64'] = {'srcs': module.srcs.copy()}
module.srcs.clear()
elif module.name == "cronet_aml_third_party_boringssl_boringssl":
x86_srcs = module.srcs.copy()
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()}
module.srcs.clear()
return module
def create_java_module(blueprint, gn):
@@ -1230,14 +1207,6 @@ def create_blueprint_for_targets(gn, desc, targets):
for target in targets:
create_modules_from_target(blueprint, gn, target)
# Currently, multi tool chain is not supported for all targets and create_modules_from_target can
# not reach to this target by following the dependency.
# So it's required to specify explicitly.
boringssl_gn_target_name = ('//third_party/boringssl:boringssl_asm' +
'(//build/toolchain/android:android_clang_x86)')
gn.parse_gn_desc(desc, boringssl_gn_target_name)
create_modules_from_target(blueprint, gn, boringssl_gn_target_name)
create_java_module(blueprint, gn)
update_jni_registration_module(blueprint, gn)