Skip to content

Commit

Permalink
Remove objc_library resource attribute processing from the resource a…
Browse files Browse the repository at this point in the history
…spect.

objc_library no longer has any resource attributes starting from Bazel 0.26.

RELNOTES: None
PiperOrigin-RevId: 250274755
  • Loading branch information
sergiocampama authored and swiple-rules-gardener committed May 28, 2019
1 parent f0c71cc commit 48119cd
Showing 1 changed file with 1 addition and 52 deletions.
53 changes: 1 addition & 52 deletions apple/internal/aspects/resource_aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,6 @@ load(
"@build_bazel_rules_swift//swift:swift.bzl",
"SwiftInfo",
)
load(
"@bazel_skylib//lib:partial.bzl",
"partial",
)

# List of native resource attributes to use to collect by default. This list should dissapear in the
# long term; objc_library will remove the resource specific attributes and the native rules (that
# have these attributes) will dissapear. The new resource rules will either have specific attributes
# or use data, but in any of those cases, this list won't be used as if there are specific
# attributes, we will not merge them to split them again.
_NATIVE_RESOURCE_ATTRS = [
"asset_catalogs",
"data",
"datamodels",
"resources",
"storyboards",
"strings",
"xibs",
]

def _apple_resource_aspect_impl(target, ctx):
"""Implementation of the resource propation aspect."""
Expand All @@ -62,20 +43,13 @@ def _apple_resource_aspect_impl(target, ctx):
owner = None

if ctx.rule.kind == "objc_library":
collect_args["res_attrs"] = _NATIVE_RESOURCE_ATTRS
collect_args["res_attrs"] = ["data"]

# Only set objc_library targets as owners if they have srcs, non_arc_srcs or deps. This
# treats objc_library targets without sources as resource aggregators.
if ctx.rule.attr.srcs or ctx.rule.attr.non_arc_srcs or ctx.rule.attr.deps:
owner = str(ctx.label)

if hasattr(ctx.rule.attr, "bundles"):
# Collect objc_library's bundles dependencies and propagate them.
providers.extend([
x[AppleResourceInfo]
for x in ctx.rule.attr.bundles
])

elif ctx.rule.kind == "swift_library":
bucketize_args["swift_module"] = target[SwiftInfo].module_name
collect_args["res_attrs"] = ["data"]
Expand Down Expand Up @@ -107,31 +81,6 @@ def _apple_resource_aspect_impl(target, ctx):
resources.bucketize(files, owner = owner, **bucketize_args),
)

# If the target has structured_resources, we need to process them with a different
# parent_dir_param
if hasattr(ctx.rule.attr, "structured_resources"):
if ctx.rule.attr.structured_resources:
# TODO(kaipi): Validate that structured_resources doesn't have processable resources,
# e.g. we shouldn't accept xib files that should be compiled before bundling.
structured_files = resources.collect(
ctx.rule.attr,
res_attrs = ["structured_resources"],
)

# Avoid processing PNG files that are referenced through the structured_resources
# attribute. This is mostly for legacy reasons and should get cleaned up in the future.
providers.append(
resources.bucketize(
structured_files,
owner = owner,
parent_dir_param = partial.make(
resources.structured_resources_parent_dir,
parent_dir = None,
),
avoid_buckets = ["pngs"],
),
)

# Get the providers from dependencies.
for attr in ["deps", "data"]:
if hasattr(ctx.rule.attr, attr):
Expand Down

0 comments on commit 48119cd

Please sign in to comment.