Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 561199538
Change-Id: Ib5cbd24ab06d1f3e8312ca58fd4f44ca50b63ce3
  • Loading branch information
timpeut authored and copybara-github committed Aug 30, 2023
1 parent fa49d7b commit 8098c69
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions rules/native_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,13 @@ def _get_libs_dir_name(android_config, target_platform):
name = name + "-hwasan"
return name

def process(ctx, filename, merged_native_libs = {}):
def process(ctx, filename):
""" Links native deps into a shared library
Args:
ctx: The context.
filename: String. The name of the artifact containing the name of the
linked shared library
merged_native_libs: A dict that maps cpu to merged native libraries. This maps to empty
lists if native library merging is not enabled.
Returns:
Tuple of (libs, libs_name) where libs is a depset of all native deps
Expand Down Expand Up @@ -97,15 +95,13 @@ def process(ctx, filename, merged_native_libs = {}):
),
)
libraries = []
if merged_native_libs:
libraries.extend(merged_native_libs[key])

native_deps_lib = _link_native_deps_if_present(ctx, cc_info, cc_toolchain, build_config, actual_target_name)
if native_deps_lib:
libraries.append(native_deps_lib)
native_libs_basename = native_deps_lib.basename

libraries.extend(_filter_unique_shared_libs(libraries, cc_info))
libraries.extend(_filter_unique_shared_libs(native_deps_lib, cc_info))

if libraries:
libs[libs_dir_name] = depset(libraries)
Expand Down Expand Up @@ -137,18 +133,11 @@ def _all_inputs(cc_info):
for lib in input.libraries
]

def _filter_unique_shared_libs(linked_libs, cc_info):
def _filter_unique_shared_libs(linked_lib, cc_info):
basenames = {}
artifacts = {}
if linked_libs:
basenames = {
linked_lib.basename: linked_lib
for linked_lib in linked_libs
}
artifacts = {
linked_lib: None
for linked_lib in linked_libs
}
if linked_lib:
basenames[linked_lib.basename] = linked_lib
for input in _all_inputs(cc_info):
if input.pic_static_library or input.static_library:
# This is not a shared library and will not be loaded by Android, so skip it.
Expand Down Expand Up @@ -180,7 +169,7 @@ def _filter_unique_shared_libs(linked_libs, cc_info):
"unique basename to avoid name collisions when packaged into " +
"an apk, but two libraries have the basename '" + basename +
"': " + artifact + " and " + old_artifact + (
" (the library already seen by this target)" if old_artifact in linked_libs else ""
" (the library compiled for this target)" if old_artifact == linked_lib else ""
),
)
else:
Expand Down

0 comments on commit 8098c69

Please sign in to comment.