Skip to content

Commit

Permalink
Migrate Objc compile info to CcCompilationContext
Browse files Browse the repository at this point in the history
Step 1 of 3-step plan:
1. Migrate the definitions.
2. Migrate the uses.
3. Delete old ObjcProvider definitions.

See bazelbuild/bazel#10674.

RELNOTES: None
PiperOrigin-RevId: 297752500
  • Loading branch information
Googler authored and swiple-rules-gardener committed Feb 28, 2020
1 parent 0122e6a commit e8a6593
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
7 changes: 6 additions & 1 deletion swift/internal/swift_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ def _swift_library_impl(ctx):
library_to_link.pic_static_library,
])

generated_headers = compact([compilation_outputs.generated_header])

providers = [
DefaultInfo(
files = depset(direct_output_files),
Expand All @@ -205,6 +207,9 @@ def _swift_library_impl(ctx):
libraries_to_link = [library_to_link],
private_cc_infos = get_providers(private_deps, CcInfo),
user_link_flags = linkopts,
headers = generated_headers,
includes = [ctx.bin_dir.path],
defines = ctx.attr.defines,
),
coverage_common.instrumented_files_info(
ctx,
Expand All @@ -214,7 +219,7 @@ def _swift_library_impl(ctx):
),
swift_common.create_swift_info(
defines = ctx.attr.defines,
generated_headers = compact([compilation_outputs.generated_header]),
generated_headers = generated_headers,
module_name = module_name,
swiftdocs = [compilation_outputs.swiftdoc],
swiftinterfaces = compact([compilation_outputs.swiftinterface]),
Expand Down
2 changes: 2 additions & 0 deletions swift/internal/swift_module_alias.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ def _swift_module_alias_impl(ctx):
cc_infos = get_providers(deps, CcInfo),
compilation_outputs = compilation_outputs,
libraries_to_link = [library_to_link],
headers = compact([compilation_outputs.generated_header]),
includes = [ctx.bin_dir.path],
),
swift_common.create_swift_info(
module_name = module_name,
Expand Down
6 changes: 6 additions & 0 deletions swift/internal/swift_protoc_gen_aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ def _swift_protoc_gen_aspect_impl(target, aspect_ctx):
# Propagate an `objc` provider if the toolchain supports Objective-C
# interop, which ensures that the libraries get linked into
# `apple_binary` targets properly.
headers = []
includes = []
if swift_toolchain.supports_objc_interop:
objc_infos = get_providers(
proto_deps,
Expand All @@ -421,6 +423,8 @@ def _swift_protoc_gen_aspect_impl(target, aspect_ctx):
objc_info_args["header"] = depset([
compilation_outputs.generated_header,
])
headers = compact([compilation_outputs.generated_header])
includes = [aspect_ctx.bin_dir.path]
if library_to_link.pic_static_library:
objc_info_args["library"] = depset(
[library_to_link.pic_static_library],
Expand Down Expand Up @@ -459,6 +463,8 @@ def _swift_protoc_gen_aspect_impl(target, aspect_ctx):
cc_infos = cc_infos,
compilation_outputs = compilation_outputs,
libraries_to_link = [library_to_link],
headers = headers,
includes = includes,
),
objc_info = objc_info,
),
Expand Down
10 changes: 9 additions & 1 deletion swift/internal/utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def create_cc_info(
compilation_outputs = None,
libraries_to_link = [],
private_cc_infos = [],
user_link_flags = []):
user_link_flags = [],
headers = [],
includes = [],
defines = []):
"""Creates a `CcInfo` provider from Swift compilation info and deps.
Args:
Expand Down Expand Up @@ -115,6 +118,11 @@ def create_cc_info(
libraries_to_link = libraries_to_link,
user_link_flags = all_user_link_flags,
),
compilation_context = cc_common.create_compilation_context(
headers = depset(headers),
includes = depset(includes),
defines = depset(defines),
),
),
]

Expand Down

0 comments on commit e8a6593

Please sign in to comment.