Skip to content

Commit

Permalink
Only Adding Actually Used Hidden Directories
Browse files Browse the repository at this point in the history
Summary: We're making every src directory for the dependencies as hidden, meaning we're stating that we need them symlinked for the script to work. However, we don't look at the source directories unless the module is included in the list of deps. So, this only marks actually used directories as hidden.

Reviewed By: blackm00n

Differential Revision: D58610247

fbshipit-source-id: 4ee6be7576b1d34eb4fb3156ec758712638dc9d6
  • Loading branch information
Mark Bridges authored and facebook-github-bot committed Jun 20, 2024
1 parent 74a1930 commit 041c8b9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions apple/mockingbird/mockingbird_mock.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ def _impl(ctx: AnalysisContext) -> list[Provider]:

dep_names = [dep[MockingbirdLibraryInfo].name for dep in ctx.attrs.deps]

json_project_description = _get_mockingbird_json_project_description(info = mockingbird_info, included_srcs = ctx.attrs.srcs, excluded_srcs = ctx.attrs.excluded_srcs, dep_names = dep_names)
(json_project_description, src_dirs) = _get_mockingbird_json_project_description(info = mockingbird_info, included_srcs = ctx.attrs.srcs, excluded_srcs = ctx.attrs.excluded_srcs, dep_names = dep_names)
json_project_description_output = ctx.actions.declare_output("mockingbird_project.json")
ctx.actions.write_json(json_project_description_output.as_output(), json_project_description)

mockingbird_source = ctx.actions.declare_output(mockingbird_info.name + "Mocks.generated.swift", dir = False)
cmd = cmd_args(
hidden = [record.src_dir for record in mockingbird_info.tset.traverse()],
hidden = src_dirs,
)

params = [
Expand Down Expand Up @@ -47,9 +47,8 @@ def _impl(ctx: AnalysisContext) -> list[Provider]:
ctx.actions.run(
cmd,
category = "mockingbird",
local_only = True,
local_only = True, # Mockingbird creates sockets for interprocess communication, which is deliberately blocked on RE.
)
# TODO: T182716646 Remove local_only

return [
DefaultInfo(mockingbird_source),
Expand Down Expand Up @@ -119,18 +118,21 @@ registration_spec = RuleRegistrationSpec(
# }
# ]
# }
def _get_mockingbird_json_project_description(info: MockingbirdLibraryInfo, included_srcs: list[str], excluded_srcs: list[str], dep_names: list[str]) -> dict:
def _get_mockingbird_json_project_description(info: MockingbirdLibraryInfo, included_srcs: list[str], excluded_srcs: list[str], dep_names: list[str]) -> (dict, list):
targets = []
src_dirs = []
for record in info.tset.traverse():
if record.name == info.name:
targets.append(_target_dict_for_mockingbird_record(record = record, included_srcs = included_srcs, excluded_srcs = excluded_srcs, include_non_exported_deps = True))
src_dirs.append(record.src_dir)
elif record.name in dep_names:
targets.append(_target_dict_for_mockingbird_record(record = record, included_srcs = [], excluded_srcs = [], include_non_exported_deps = False))
src_dirs.append(record.src_dir)
json = {
"targets": targets,
}

return json
return (json, src_dirs)

def _target_dict_for_mockingbird_record(record: MockingbirdLibraryRecord, included_srcs: list[str], excluded_srcs: list[str], include_non_exported_deps: bool) -> dict:
srcs = []
Expand Down

0 comments on commit 041c8b9

Please sign in to comment.