Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docc rule to support deps and data #2450

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apple/internal/aspects/docc_archive_aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _docc_bundle_info_aspect_impl(target, ctx):
first_docc_bundle = _first_docc_bundle(target, ctx)
if first_docc_bundle:
return [DocCBundleInfo(bundle = first_docc_bundle)]
elif hasattr(ctx.rule.attr, "deps"):
if hasattr(ctx.rule.attr, "deps"):
# If this target has "deps", try to find a DocCBundleInfo provider in its deps.
for dep in ctx.rule.attr.deps:
if DocCBundleInfo in dep:
Expand Down
21 changes: 21 additions & 0 deletions test/starlark_tests/docc_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,27 @@ def docc_test_suite(name):
tags = [name],
)

# Verify doccarchive bundle is created for an ObjC library which defines data and has a dependency on a Swift lib.
archive_contents_test(
name = "{}_contains_doccarchive_when_objc_library_with_swift_dep".format(name),
build_type = "simulator",
target_under_test = "//test/starlark_tests/targets_under_test/ios:basic_objc_lib_with_data_and_docc_bundle_dependency.doccarchive",
contains = [
"$BUNDLE_ROOT/index.html",
"$BUNDLE_ROOT/documentation/basiclib/readme/index.html",
],
text_file_not_contains = [],
text_test_file = "$BUNDLE_ROOT/metadata.json",
text_test_values = [
"\"bundleDisplayName\":\"BasicLib\"",
"\"bundleIdentifier\":\"com.google.example.objc.lib\"",
"\"major\":0",
"\"minor\":1",
"\"patch\":0",
],
tags = [name],
)

native.test_suite(
name = name,
tags = [name],
Expand Down
18 changes: 18 additions & 0 deletions test/starlark_tests/targets_under_test/ios/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4880,6 +4880,24 @@ swift_library(
visibility = ["//visibility:public"],
)

objc_library(
name = "basic_objc_lib_with_data_and_docc_bundle_dependency",
srcs = [
"//test/starlark_tests/resources:shared.h",
"//test/starlark_tests/resources:shared.m",
],
data = ["//test/starlark_tests/resources:additional.txt"],
deps = [":basic_framework_lib_with_docc_bundle"],
)

docc_archive(
name = "basic_objc_lib_with_data_and_docc_bundle_dependency.doccarchive",
dep = ":basic_objc_lib_with_data_and_docc_bundle_dependency",
fallback_bundle_identifier = "com.google.example.objc.lib",
fallback_bundle_version = "1.0",
fallback_display_name = "BasicLib",
)

ios_dynamic_framework(
name = "basic_framework_with_docc_bundle",
bundle_id = "com.google.example.framework",
Expand Down