Skip to content

Commit

Permalink
Forecefully remove CC toolchain dependency for Slack
Browse files Browse the repository at this point in the history
  • Loading branch information
erikkerber committed Nov 20, 2024
1 parent 0663d0d commit e013f9a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 52 deletions.
10 changes: 5 additions & 5 deletions rules/android_binary/attrs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@ ATTRS = _attrs.replace(
# This is for only generating proguard outputs when proguard_specs is not empty or of type select.
_generate_proguard_outputs = attr.bool(),
_enable_manifest_merging = attr.bool(default = True),
_cc_toolchain_split = attr.label(
cfg = android_split_transition,
default = "@bazel_tools//tools/cpp:current_cc_toolchain",
aspects = [split_config_aspect],
),
# _cc_toolchain_split = attr.label(
# cfg = android_split_transition,
# default = "@bazel_tools//tools/cpp:current_cc_toolchain",
# aspects = [split_config_aspect],
# ),
_optimizing_dexer = attr.label(
cfg = "exec",
allow_single_file = True,
Expand Down
95 changes: 48 additions & 47 deletions rules/native_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -72,53 +72,54 @@ def process(ctx, filename, merged_libraries_map = {}):
native_libs_basename = None
libs_name = None
libs = dict()
for key, deps in ctx.split_attr.deps.items():
cc_toolchain_dep = ctx.split_attr._cc_toolchain_split[key]
cc_toolchain = cc_toolchain_dep[cc_common.CcToolchainInfo]
build_config = cc_toolchain_dep[SplitConfigInfo].build_config
libs_dir_name = _get_libs_dir_name(
cc_toolchain_dep[SplitConfigInfo].target_platform,
)
linker_input = cc_common.create_linker_input(
owner = ctx.label,
user_link_flags = ["-Wl,-soname=lib" + target_name],
)
cc_info = cc_common.merge_cc_infos(
cc_infos = _concat(
[CcInfo(linking_context = cc_common.create_linking_context(
linker_inputs = depset([linker_input]),
))],
[dep[JavaInfo].cc_link_params_info for dep in deps if JavaInfo in dep],
[dep[AndroidCcLinkParamsInfo].link_params for dep in deps if AndroidCcLinkParamsInfo in dep],
[dep[CcInfo] for dep in deps if CcInfo in dep],
),
)
new_libraries = []
stub_libraries = []
if merged_libraries_map:
new_libraries.extend(merged_libraries_map[key].new_libraries)
stub_libraries.extend(merged_libraries_map[key].stub_libraries)

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

shared_libs = _collect_unique_shared_libs(
new_libraries,
stub_libraries,
cc_info,
)

if shared_libs:
libs[libs_dir_name] = depset(shared_libs)

if libs and native_libs_basename:
libs_name = ctx.actions.declare_file("nativedeps_filename/" + target_name + "/" + filename)
ctx.actions.write(output = libs_name, content = native_libs_basename)

transitive_native_libs = _get_transitive_native_libs(ctx)
return AndroidBinaryNativeLibsInfo(libs, libs_name, transitive_native_libs)
return AndroidBinaryNativeLibsInfo(libs, libs_name, depset([]))
# for key, deps in ctx.split_attr.deps.items():
# # cc_toolchain_dep = ctx.split_attr._cc_toolchain_split[key]
# # cc_toolchain = cc_toolchain_dep[cc_common.CcToolchainInfo]
# # build_config = cc_toolchain_dep[SplitConfigInfo].build_config
# # libs_dir_name = _get_libs_dir_name(
# # cc_toolchain_dep[SplitConfigInfo].target_platform,
# # )
# linker_input = cc_common.create_linker_input(
# owner = ctx.label,
# user_link_flags = ["-Wl,-soname=lib" + target_name],
# )
# cc_info = cc_common.merge_cc_infos(
# cc_infos = _concat(
# [CcInfo(linking_context = cc_common.create_linking_context(
# linker_inputs = depset([linker_input]),
# ))],
# [dep[JavaInfo].cc_link_params_info for dep in deps if JavaInfo in dep],
# [dep[AndroidCcLinkParamsInfo].link_params for dep in deps if AndroidCcLinkParamsInfo in dep],
# [dep[CcInfo] for dep in deps if CcInfo in dep],
# ),
# )
# new_libraries = []
# stub_libraries = []
# if merged_libraries_map:
# new_libraries.extend(merged_libraries_map[key].new_libraries)
# stub_libraries.extend(merged_libraries_map[key].stub_libraries)

# native_deps_lib = _link_native_deps_if_present(ctx, cc_info, cc_toolchain, build_config, target_name)
# if native_deps_lib:
# new_libraries.append(native_deps_lib)
# native_libs_basename = native_deps_lib.basename

# shared_libs = _collect_unique_shared_libs(
# new_libraries,
# stub_libraries,
# cc_info,
# )

# # if shared_libs:
# # libs[libs_dir_name] = depset(shared_libs)

# if libs and native_libs_basename:
# libs_name = ctx.actions.declare_file("nativedeps_filename/" + target_name + "/" + filename)
# ctx.actions.write(output = libs_name, content = native_libs_basename)

# transitive_native_libs = _get_transitive_native_libs(ctx)
# return AndroidBinaryNativeLibsInfo(libs, libs_name, transitive_native_libs)

# Collect all native shared libraries across split transitions. Some AARs
# contain shared libraries across multiple architectures, e.g. x86 and
Expand Down

0 comments on commit e013f9a

Please sign in to comment.