gn2bp: collect linker unit deps per target
Both transitive static libraries and LINKER_UNIT_TYPES dependencies need
to be stored separately for every target as they could differ. In
reality, only static deps differ right now.
I am not a big fan of how transitive_static_libs_deps are handled in
this CL; maybe we can come up with a more readable solution.
Test: //components/cronet/android:cronet
Change-Id: Ia4ad8e264b1243b7dd5d58a26543ee78206f9c79
diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp
index 02ccc56..d0d6aae 100644
--- a/tools/gn2bp/Android.bp.swp
+++ b/tools/gn2bp/Android.bp.swp
@@ -697,9 +697,6 @@
"cronet_aml_base_base_static",
"cronet_aml_base_third_party_double_conversion_double_conversion",
"cronet_aml_base_third_party_dynamic_annotations_dynamic_annotations",
- "cronet_aml_base_third_party_symbolize_symbolize",
- "cronet_aml_base_third_party_xdg_mime_xdg_mime",
- "cronet_aml_base_third_party_xdg_user_dirs_xdg_user_dirs",
"cronet_aml_third_party_boringssl_boringssl",
"cronet_aml_third_party_icu_icui18n",
"cronet_aml_third_party_icu_icuuc_private",
@@ -1782,140 +1779,6 @@
},
}
-// GN: //base/third_party/symbolize:symbolize
-cc_library_static {
- name: "cronet_aml_base_third_party_symbolize_symbolize",
- srcs: [
- "base/third_party/symbolize/demangle.cc",
- "base/third_party/symbolize/symbolize.cc",
- ],
- host_supported: true,
- device_supported: false,
- defaults: [
- "cronet_aml_defaults",
- ],
- cflags: [
- "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
- "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
- "-DCR_SYSROOT_KEY=20220331T153654Z-0",
- "-DDCHECK_ALWAYS_ON=1",
- "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
- "-DGLOG_EXPORT=",
- "-DUSE_AURA=1",
- "-DUSE_OZONE=1",
- "-DUSE_UDEV",
- "-D_DEBUG",
- "-D_FILE_OFFSET_BITS=64",
- "-D_GNU_SOURCE",
- "-D_LARGEFILE64_SOURCE",
- "-D_LARGEFILE_SOURCE",
- "-D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1",
- "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
- "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
- "-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
- ],
- local_include_dirs: [
- "./",
- "buildtools/third_party/libc++/",
- "buildtools/third_party/libc++/trunk/include",
- "buildtools/third_party/libc++abi/trunk/include",
- "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
- "build/linux/debian_bullseye_amd64-sysroot/usr/include",
- ],
- cpp_std: "c++20",
-}
-
-// GN: //base/third_party/xdg_mime:xdg_mime
-cc_library_static {
- name: "cronet_aml_base_third_party_xdg_mime_xdg_mime",
- srcs: [
- "base/third_party/xdg_mime/xdgmime.c",
- "base/third_party/xdg_mime/xdgmimealias.c",
- "base/third_party/xdg_mime/xdgmimecache.c",
- "base/third_party/xdg_mime/xdgmimeglob.c",
- "base/third_party/xdg_mime/xdgmimeicon.c",
- "base/third_party/xdg_mime/xdgmimeint.c",
- "base/third_party/xdg_mime/xdgmimemagic.c",
- "base/third_party/xdg_mime/xdgmimeparent.c",
- ],
- host_supported: true,
- device_supported: false,
- defaults: [
- "cronet_aml_defaults",
- ],
- cflags: [
- "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
- "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
- "-DCR_SYSROOT_KEY=20220331T153654Z-0",
- "-DDCHECK_ALWAYS_ON=1",
- "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
- "-DUSE_AURA=1",
- "-DUSE_OZONE=1",
- "-DUSE_UDEV",
- "-D_DEBUG",
- "-D_FILE_OFFSET_BITS=64",
- "-D_GNU_SOURCE",
- "-D_LARGEFILE64_SOURCE",
- "-D_LARGEFILE_SOURCE",
- "-D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1",
- "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
- "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
- "-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
- ],
- local_include_dirs: [
- "./",
- "buildtools/third_party/libc++/",
- "buildtools/third_party/libc++/trunk/include",
- "buildtools/third_party/libc++abi/trunk/include",
- "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
- "build/linux/debian_bullseye_amd64-sysroot/usr/include",
- ],
- cpp_std: "c++20",
-}
-
-// GN: //base/third_party/xdg_user_dirs:xdg_user_dirs
-cc_library_static {
- name: "cronet_aml_base_third_party_xdg_user_dirs_xdg_user_dirs",
- srcs: [
- "base/third_party/xdg_user_dirs/xdg_user_dir_lookup.cc",
- ],
- host_supported: true,
- device_supported: false,
- defaults: [
- "cronet_aml_defaults",
- ],
- cflags: [
- "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
- "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
- "-DCR_SYSROOT_KEY=20220331T153654Z-0",
- "-DDCHECK_ALWAYS_ON=1",
- "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
- "-DUSE_AURA=1",
- "-DUSE_OZONE=1",
- "-DUSE_UDEV",
- "-D_DEBUG",
- "-D_FILE_OFFSET_BITS=64",
- "-D_GNU_SOURCE",
- "-D_LARGEFILE64_SOURCE",
- "-D_LARGEFILE_SOURCE",
- "-D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1",
- "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
- "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
- "-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
- "-D__STDC_CONSTANT_MACROS",
- "-D__STDC_FORMAT_MACROS",
- ],
- local_include_dirs: [
- "./",
- "buildtools/third_party/libc++/",
- "buildtools/third_party/libc++/trunk/include",
- "buildtools/third_party/libc++abi/trunk/include",
- "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
- "build/linux/debian_bullseye_amd64-sysroot/usr/include",
- ],
- cpp_std: "c++20",
-}
-
// GN: //base:tracing_buildflags
genrule {
name: "cronet_aml_base_tracing_buildflags",
@@ -2157,9 +2020,6 @@
"cronet_aml_base_base_static",
"cronet_aml_base_third_party_double_conversion_double_conversion",
"cronet_aml_base_third_party_dynamic_annotations_dynamic_annotations",
- "cronet_aml_base_third_party_symbolize_symbolize",
- "cronet_aml_base_third_party_xdg_mime_xdg_mime",
- "cronet_aml_base_third_party_xdg_user_dirs_xdg_user_dirs",
"cronet_aml_components_prefs_prefs",
"cronet_aml_crypto_crypto",
"cronet_aml_net_net",
@@ -2173,9 +2033,7 @@
"cronet_aml_third_party_icu_icuuc_private",
"cronet_aml_third_party_libevent_libevent",
"cronet_aml_third_party_modp_b64_modp_b64",
- "cronet_aml_third_party_protobuf_protobuf_full",
"cronet_aml_third_party_protobuf_protobuf_lite",
- "cronet_aml_third_party_protobuf_protoc_lib",
"cronet_aml_third_party_zlib_zlib",
"cronet_aml_url_url",
],
@@ -2700,9 +2558,6 @@
"cronet_aml_base_base_static",
"cronet_aml_base_third_party_double_conversion_double_conversion",
"cronet_aml_base_third_party_dynamic_annotations_dynamic_annotations",
- "cronet_aml_base_third_party_symbolize_symbolize",
- "cronet_aml_base_third_party_xdg_mime_xdg_mime",
- "cronet_aml_base_third_party_xdg_user_dirs_xdg_user_dirs",
"cronet_aml_third_party_boringssl_boringssl",
"cronet_aml_third_party_icu_icui18n",
"cronet_aml_third_party_icu_icuuc_private",
@@ -3585,9 +3440,6 @@
"cronet_aml_base_base_static",
"cronet_aml_base_third_party_double_conversion_double_conversion",
"cronet_aml_base_third_party_dynamic_annotations_dynamic_annotations",
- "cronet_aml_base_third_party_symbolize_symbolize",
- "cronet_aml_base_third_party_xdg_mime_xdg_mime",
- "cronet_aml_base_third_party_xdg_user_dirs_xdg_user_dirs",
"cronet_aml_crypto_crypto",
"cronet_aml_net_preload_decoder",
"cronet_aml_net_third_party_quiche_quiche",
@@ -3599,9 +3451,7 @@
"cronet_aml_third_party_icu_icuuc_private",
"cronet_aml_third_party_libevent_libevent",
"cronet_aml_third_party_modp_b64_modp_b64",
- "cronet_aml_third_party_protobuf_protobuf_full",
"cronet_aml_third_party_protobuf_protobuf_lite",
- "cronet_aml_third_party_protobuf_protoc_lib",
"cronet_aml_third_party_zlib_zlib",
"cronet_aml_url_url",
],
@@ -4284,9 +4134,7 @@
"cronet_aml_third_party_icu_icuuc_private",
"cronet_aml_third_party_libevent_libevent",
"cronet_aml_third_party_modp_b64_modp_b64",
- "cronet_aml_third_party_protobuf_protobuf_full",
"cronet_aml_third_party_protobuf_protobuf_lite",
- "cronet_aml_third_party_protobuf_protoc_lib",
"cronet_aml_third_party_zlib_zlib",
"cronet_aml_url_url",
],
@@ -7201,7 +7049,6 @@
"cronet_aml_third_party_icu_icuuc_private",
"cronet_aml_third_party_libevent_libevent",
"cronet_aml_third_party_modp_b64_modp_b64",
- "cronet_aml_third_party_zlib_zlib",
],
generated_headers: [
"cronet_aml_base_debugging_buildflags",
diff --git a/tools/gn2bp/gn_utils.py b/tools/gn2bp/gn_utils.py
index 4d15473..3d86213 100644
--- a/tools/gn2bp/gn_utils.py
+++ b/tools/gn2bp/gn_utils.py
@@ -100,6 +100,8 @@
self.cflags = set()
self.defines = set()
self.include_dirs = set()
+ self.deps = set()
+ self.transitive_static_libs_deps = set()
def __init__(self, name, type):
@@ -142,7 +144,6 @@
self.source_set_deps = set() # Transitive set of source_set deps.
self.proto_deps = set()
self.transitive_proto_deps = set()
- self.transitive_static_libs_deps = set()
# TODO: come up with a better way to only run this once.
# is_finalized tracks whether finalize() was called on this target.
@@ -194,6 +195,7 @@
self.cflags = set.intersection(*[arch.cflags for arch in self.arch.values()])
self.defines = set.intersection(*[arch.defines for arch in self.arch.values()])
self.include_dirs = set.intersection(*[arch.include_dirs for arch in self.arch.values()])
+ self.deps.update(set.intersection(*[arch.deps for arch in self.arch.values()]))
# Deduplicate arch-dependent properties
for arch in self.arch.keys():
@@ -201,6 +203,8 @@
self.arch[arch].cflags -= self.cflags
self.arch[arch].defines -= self.defines
self.arch[arch].include_dirs -= self.include_dirs
+ self.arch[arch].deps -= self.deps
+
def __init__(self):
self.all_targets = {}
@@ -345,7 +349,7 @@
if proto_target_type is None:
target.deps.add(dep.name)
elif dep.type in LINKER_UNIT_TYPES:
- target.deps.add(dep.name)
+ target.arch[arch].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
@@ -355,10 +359,12 @@
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.arch[arch].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)
+ if arch in dep.arch:
+ target.arch[arch].transitive_static_libs_deps.update(
+ dep.arch[arch].transitive_static_libs_deps)
+ target.arch[arch].deps.update(target.arch[arch].transitive_static_libs_deps)
# Collect java sources. Java sources are kept inside the __compile_java target.
# This target can be used for both host and target compilation; only add