Skip to content

Commit

Permalink
Remove 'exported_deps' from apple_binary() rule definition.
Browse files Browse the repository at this point in the history
Summary:
## Diff Stack
This diff stack will remove the usage and definition of `exported_deps` attributes in `apple_test()` and `apple_binary` rules. This includes:
1. merging existing `exported_deps` attribute targets into `deps` attributes. Duplicates will be removed during merging.
2. removing the actual `exported_deps` fields from the rules.
 ---
## This Diff
- Remove `exported_deps` attribute definition of `apple_binary()` rule.
- Fix broken CI and unit tests:
  - return empty list when `exported_deps` attribute isn't defined.
  - remove logic that shadow injection of `exported_deps` internally in custom macros, such as `ios_binary`.

 ---
## References
- Check D65839248 for more details of the script used for this modification.

#buildall-fbobjc

Reviewed By: manicaesar

Differential Revision: D66231521

fbshipit-source-id: 406d7a2359ea1e56fb2b96972b1fb3fc3e78caa2
  • Loading branch information
Bin Yu authored and facebook-github-bot committed Nov 22, 2024
1 parent aaec7af commit e593e8a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
14 changes: 7 additions & 7 deletions apple/swift/swift_compilation.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def get_swift_anonymous_targets(ctx: AnalysisContext, get_apple_library_provider
# passing apple_library's cxx flags through that must be used for all downward PCM compilations.
pcm_targets = get_swift_pcm_anon_targets(
ctx,
ctx.attrs.deps + ctx.attrs.exported_deps,
ctx.attrs.deps + getattr(ctx.attrs, "exported_deps", []),
swift_cxx_flags,
ctx.attrs.enable_cxx_interop,
)
Expand Down Expand Up @@ -820,7 +820,7 @@ def _add_swift_module_map_args(
sdk_swiftmodule_deps_tset = [sdk_swiftmodule_deps_tset] if sdk_swiftmodule_deps_tset else []
all_deps_tset = ctx.actions.tset(
SwiftCompiledModuleTset,
children = _get_swift_paths_tsets(ctx.attrs.deps + ctx.attrs.exported_deps) + [pcm_deps_tset, sdk_deps_tset] + sdk_swiftmodule_deps_tset,
children = _get_swift_paths_tsets(ctx.attrs.deps + getattr(ctx.attrs, "exported_deps", [])) + [pcm_deps_tset, sdk_deps_tset] + sdk_swiftmodule_deps_tset,
)
swift_module_map_artifact = write_swift_module_map_with_deps(
ctx,
Expand All @@ -847,7 +847,7 @@ def _add_swift_deps_flags(
"-disable-implicit-swift-modules",
])
else:
depset = ctx.actions.tset(SwiftCompiledModuleTset, children = _get_swift_paths_tsets(ctx.attrs.deps + ctx.attrs.exported_deps))
depset = ctx.actions.tset(SwiftCompiledModuleTset, children = _get_swift_paths_tsets(ctx.attrs.deps + getattr(ctx.attrs, "exported_deps", [])))
cmd.add(depset.project_as_args("module_search_path"))

implicit_search_path_tset = get_implicit_framework_search_path_providers(
Expand All @@ -864,7 +864,7 @@ def _add_clang_deps_flags(
if uses_explicit_modules(ctx):
cmd.add(pcm_deps_tset.project_as_args("clang_importer_flags"))
else:
inherited_preprocessor_infos = cxx_inherited_preprocessor_infos(ctx.attrs.deps + ctx.attrs.exported_deps)
inherited_preprocessor_infos = cxx_inherited_preprocessor_infos(ctx.attrs.deps + getattr(ctx.attrs, "exported_deps", []))
preprocessors = cxx_merge_cpreprocessors(ctx, [], inherited_preprocessor_infos)
cmd.add(cmd_args(preprocessors.set.project_as_args("args"), prepend = "-Xcc"))
cmd.add(cmd_args(preprocessors.set.project_as_args("modular_args"), prepend = "-Xcc"))
Expand Down Expand Up @@ -977,7 +977,7 @@ def get_swift_dependency_info(
debug_info_tset = make_artifact_tset(
actions = ctx.actions,
artifacts = [output_module] if output_module != None else [],
children = get_external_debug_info_tsets(ctx.attrs.deps + ctx.attrs.exported_deps),
children = get_external_debug_info_tsets(ctx.attrs.deps + getattr(ctx.attrs, "exported_deps", [])),
label = ctx.label,
tags = [ArtifactInfoTag("swiftmodule")],
)
Expand Down Expand Up @@ -1126,9 +1126,9 @@ def _create_swift_interface(ctx: AnalysisContext, shared_flags: cmd_args, module

def _exported_deps(ctx) -> list[Dependency]:
if ctx.attrs.reexport_all_header_dependencies:
return ctx.attrs.exported_deps + ctx.attrs.deps
return getattr(ctx.attrs, "exported_deps", []) + ctx.attrs.deps
else:
return ctx.attrs.exported_deps
return getattr(ctx.attrs, "exported_deps", [])

def _should_compile_with_evolution(ctx) -> bool:
if ctx.attrs.enable_library_evolution != None:
Expand Down
2 changes: 1 addition & 1 deletion cxx/cxx_library_utility.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def cxx_attr_deps(ctx: AnalysisContext) -> list[Dependency]:
)

def cxx_attr_exported_deps(ctx: AnalysisContext) -> list[Dependency]:
return ctx.attrs.exported_deps + flatten(cxx_by_platform(ctx, ctx.attrs.exported_platform_deps))
return getattr(ctx.attrs, "exported_deps", []) + flatten(cxx_by_platform(ctx, ctx.attrs.exported_platform_deps))

def cxx_attr_linker_flags_all(ctx: AnalysisContext) -> LinkerFlags:
flags = cxx_attr_linker_flags(ctx)
Expand Down
1 change: 0 additions & 1 deletion decls/apple_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ apple_binary = prelude_rule(
"diagnostics": attrs.dict(key = attrs.string(), value = attrs.source(), sorted = False, default = {}),
"enable_cxx_interop": attrs.bool(default = False),
"executable_name": attrs.option(attrs.string(), default = None),
"exported_deps": attrs.list(attrs.dep(), default = []),
"exported_header_style": attrs.enum(IncludeType, default = "local"),
"exported_lang_platform_preprocessor_flags": attrs.dict(key = attrs.enum(CxxSourceType), value = attrs.list(attrs.tuple(attrs.regex(), attrs.list(attrs.arg()))), sorted = False, default = {}),
"exported_lang_preprocessor_flags": attrs.dict(key = attrs.enum(CxxSourceType), value = attrs.list(attrs.arg()), sorted = False, default = {}),
Expand Down

0 comments on commit e593e8a

Please sign in to comment.