Skip to content

Commit

Permalink
Automated rollback of commit 8e68a3c.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 487932502
  • Loading branch information
googlewalt authored and swiple-rules-gardener committed Nov 11, 2022
1 parent d8ab65d commit 17f4ac4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 110 deletions.
21 changes: 0 additions & 21 deletions apple/internal/apple_framework_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ def _apple_dynamic_framework_import_impl(ctx):
framework_includes = _framework_search_paths(framework.header_imports),
grep_includes = grep_includes,
header_imports = framework.header_imports,
kind = "dynamic",
label = label,
libraries = framework.binary_imports,
)
providers.append(cc_info)

Expand Down Expand Up @@ -265,26 +263,10 @@ def _apple_static_framework_import_impl(ctx):
)

# Create CcInfo provider
linkopts = []
if sdk_dylibs:
for dylib in ctx.attr.sdk_dylibs:
if dylib.startswith("lib"):
dylib = dylib[3:]
linkopts.append("-l%s" % dylib)
if sdk_frameworks:
for sdk_framework in ctx.attr.sdk_frameworks:
linkopts.append("-framework")
linkopts.append(sdk_framework)
if weak_sdk_frameworks:
for sdk_framework in ctx.attr.weak_sdk_frameworks:
linkopts.append("-weak_framework")
linkopts.append(sdk_framework)

providers.append(
framework_import_support.cc_info_with_dependencies(
actions = actions,
additional_cc_infos = additional_cc_infos,
alwayslink = alwayslink,
cc_toolchain = cc_toolchain,
ctx = ctx,
deps = deps,
Expand All @@ -295,10 +277,7 @@ def _apple_static_framework_import_impl(ctx):
),
grep_includes = grep_includes,
header_imports = framework.header_imports,
kind = "static",
label = label,
libraries = framework.binary_imports,
linkopts = linkopts,
),
)

Expand Down
5 changes: 0 additions & 5 deletions apple/internal/apple_xcframework_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,7 @@ def _apple_dynamic_xcframework_import_impl(ctx):
framework_includes = xcframework_library.framework_includes,
grep_includes = grep_includes,
header_imports = xcframework_library.headers,
kind = "dynamic",
label = label,
libraries = [xcframework_library.binary],
)
providers.append(cc_info)

Expand Down Expand Up @@ -612,17 +610,14 @@ def _apple_static_xcframework_import_impl(ctx):
cc_info = framework_import_support.cc_info_with_dependencies(
actions = actions,
additional_cc_infos = additional_cc_infos,
alwayslink = alwayslink,
cc_toolchain = cc_toolchain,
ctx = ctx,
deps = deps,
disabled_features = disabled_features,
features = features,
grep_includes = grep_includes,
header_imports = xcframework_library.headers,
kind = "static",
label = label,
libraries = [xcframework_library.binary],
linkopts = linkopts,
includes = xcframework_library.includes,
)
Expand Down
94 changes: 10 additions & 84 deletions apple/internal/framework_import_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def _cc_info_with_dependencies(
*,
actions,
additional_cc_infos = [],
alwayslink = False,
cc_toolchain,
ctx,
deps,
Expand All @@ -34,17 +33,14 @@ def _cc_info_with_dependencies(
framework_includes = [],
grep_includes,
header_imports,
kind,
label,
libraries,
linkopts = [],
includes = []):
"""Returns a new CcInfo which includes transitive Cc dependencies.
Args:
actions: The actions provider from `ctx.actions`.
additional_cc_infos: List of additinal CcInfo providers to use for a merged compilation contexts.
alwayslink: Boolean to indicate if force_load_library should be set for static frameworks.
cc_toolchain: CcToolchainInfo provider for current target.
ctx: The Starlark context for a rule target being built.
deps: List of dependencies for a given target to retrieve transitive CcInfo providers.
Expand All @@ -54,9 +50,7 @@ def _cc_info_with_dependencies(
grep_includes: File reference to grep_includes binary required by cc_common APIs.
header_imports: List of imported header files.
includes: List of included headers search paths (defaults to: []).
kind: whether the framework is "static" or "dynamic".
label: Label of the target being built.
libraries: The list of framework libraries.
linkopts: List of linker flags strings to propagate as linker input.
Returns:
CcInfo provider.
Expand Down Expand Up @@ -87,30 +81,17 @@ def _cc_info_with_dependencies(

linking_contexts = [cc_info.linking_context for cc_info in all_cc_infos]

if kind == "static":
libraries_to_link = _libraries_to_link_for_static_framework(
actions = actions,
alwayslink = alwayslink,
libraries = libraries,
)
else:
libraries_to_link = _libraries_to_link_for_dynamic_framework(
actions = actions,
cc_toolchain = cc_toolchain,
feature_configuration = feature_configuration,
libraries = libraries,
if linkopts:
linking_contexts.append(
cc_common.create_linking_context(
linker_inputs = depset([
cc_common.create_linker_input(
owner = label,
user_link_flags = linkopts,
),
]),
),
)
linking_contexts.append(
cc_common.create_linking_context(
linker_inputs = depset([
cc_common.create_linker_input(
owner = label,
libraries = depset(libraries_to_link),
user_link_flags = linkopts,
),
]),
),
)

linking_context = cc_common.merge_linking_contexts(
linking_contexts = linking_contexts,
Expand Down Expand Up @@ -222,61 +203,6 @@ def _classify_framework_imports(framework_imports):
swift_interface_imports = framework_imports_by_category.swift_interface_imports,
)

def _libraries_to_link_for_dynamic_framework(
*,
actions,
cc_toolchain,
feature_configuration,
libraries):
"""Return a list of library_to_link's for a dynamic framework.
Args:
actions: The actions provider from `ctx.actions`.
cc_toolchain: CcToolchainInfo provider for current target.
feature_configuration: The cc enabled features.
libraries: List of dynamic libraries.
Returns:
A list of library_to_link's.
"""
libraries_to_link = []
for library in libraries:
library_to_link = cc_common.create_library_to_link(
actions = actions,
cc_toolchain = cc_toolchain,
feature_configuration = feature_configuration,
dynamic_library = library,
)
libraries_to_link.append(library_to_link)

return libraries_to_link

def _libraries_to_link_for_static_framework(
*,
actions,
alwayslink,
libraries):
"""Return a list of library_to_link's for a static framework.
Args:
actions: The actions provider from `ctx.actions`.
alwayslink: Whather the libraries should be always linked.
libraries: List of static libraries.
Returns:
A list of library_to_link's.
"""
libraries_to_link = []
for library in libraries:
library_to_link = cc_common.create_library_to_link(
actions = actions,
alwayslink = alwayslink,
static_library = library,
)
libraries_to_link.append(library_to_link)

return libraries_to_link

def _framework_import_info_with_dependencies(
*,
build_archs,
Expand Down

1 comment on commit 17f4ac4

@keith
Copy link
Member

@keith keith commented on 17f4ac4 Feb 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skipping because was reverted by ed4e8c6

Please sign in to comment.