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: 297752932
  • Loading branch information
Googler authored and swiple-rules-gardener committed Feb 28, 2020
1 parent e99db2e commit 7a1420a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions apple/internal/apple_framework_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ load(
"@bazel_skylib//lib:paths.bzl",
"paths",
)
load(
"@bazel_skylib//lib:sets.bzl",
"sets",
)
load(
"@build_bazel_rules_apple//apple/internal:resources.bzl",
"resources",
Expand Down Expand Up @@ -195,6 +199,18 @@ def _framework_objc_provider_fields(

return objc_provider_fields

def _framework_search_paths(header_imports):
"""Return the list framework search paths for the headers_imports."""
if header_imports:
header_groups = _grouped_framework_files(header_imports)

search_paths = sets.make()
for path in header_groups.keys():
sets.insert(search_paths, paths.dirname(path))
return sets.to_list(search_paths)
else:
return []

def _apple_dynamic_framework_import_impl(ctx):
"""Implementation for the apple_dynamic_framework_import rule."""
providers = []
Expand All @@ -220,6 +236,14 @@ def _apple_dynamic_framework_import_impl(ctx):

objc_provider = _objc_provider_with_dependencies(ctx, objc_provider_fields)
providers.append(objc_provider)
providers.append(
CcInfo(
compilation_context = cc_common.create_compilation_context(
headers = depset(header_imports),
framework_includes = depset(_framework_search_paths(header_imports)),
),
),
)
providers.append(apple_common.new_dynamic_framework_provider(
objc = objc_provider,
framework_dirs = framework_dirs_set,
Expand Down Expand Up @@ -277,6 +301,14 @@ def _apple_static_framework_import_impl(ctx):
objc_provider_fields.update(_ensure_swiftmodule_is_embedded(swiftmodule))

providers.append(_objc_provider_with_dependencies(ctx, objc_provider_fields))
providers.append(
CcInfo(
compilation_context = cc_common.create_compilation_context(
headers = depset(header_imports),
framework_includes = depset(_framework_search_paths(header_imports)),
),
),
)

bundle_files = [x for x in framework_imports if ".bundle/" in x.short_path]
if bundle_files:
Expand Down

0 comments on commit 7a1420a

Please sign in to comment.