Skip to content

Commit

Permalink
Fix explosive memory use of inefficient _process_dependencies()
Browse files Browse the repository at this point in the history
This is why `depset` exists.

This also fixes the extra configured targets in `//examples/command_line` for some reason 🤷‍♂️.
  • Loading branch information
brentleyjones committed Apr 16, 2022
1 parent d7b20ec commit b9275fb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions test/fixtures/cc/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@
"configuration": "darwin_x86_64-fastbuild-ST-d53d69b6b8c1",
"dependencies": [
"//examples/cc/lib:lib_impl darwin_x86_64-fastbuild-ST-d53d69b6b8c1",
"//examples/cc/lib2:lib_impl darwin_x86_64-fastbuild-ST-d53d69b6b8c1",
"@examples_cc_external//:lib_impl darwin_x86_64-fastbuild-ST-d53d69b6b8c1"
"@examples_cc_external//:lib_impl darwin_x86_64-fastbuild-ST-d53d69b6b8c1",
"//examples/cc/lib2:lib_impl darwin_x86_64-fastbuild-ST-d53d69b6b8c1"
],
"frameworks": [],
"info_plist": null,
Expand Down
29 changes: 18 additions & 11 deletions xcodeproj/internal/target.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ def _xcode_target(
links: A `list` of file paths for libraries that the target links
against.
info_plist: A value as returned by `files.file_path()` or `None`.
dependencies: A `list` of `id`s of targets that this target depends on.
dependencies: A `depset` of `id`s of targets that this target depends
on.
outputs: The value returned from `targets.get_outputs()`.
Returns:
Expand Down Expand Up @@ -303,7 +304,7 @@ def _xcode_target(
),
links = [file_path_to_dto(fp) for fp in links],
info_plist = file_path_to_dto(info_plist),
dependencies = dependencies,
dependencies = dependencies.to_list(),
outputs = outputs,
))

Expand Down Expand Up @@ -1174,17 +1175,23 @@ def _skip_target(*, target, transitive_infos):
)

def _process_dependencies(*, attrs_info, transitive_infos):
return [
dependency
for dependency in flatten([
direct_dependencies = []
transitive_dependencies = []
for attr, info in transitive_infos:
if not (not attrs_info or
info.target_type in attrs_info.xcode_targets.get(attr, [None])):
continue
if info.target:
direct_dependencies.append(info.target.id)
else:
# We pass on the next level of dependencies if the previous target
# didn't create an Xcode target.
[info.target.id] if info.target else info.dependencies
for attr, info in transitive_infos
if (not attrs_info or
info.target_type in attrs_info.xcode_targets.get(attr, [None]))
])
]
transitive_dependencies.append(info.dependencies)

return depset(
direct_dependencies,
transitive = transitive_dependencies,
)

def _process_defines(*, cc_info, build_settings):
if cc_info and build_settings != None:
Expand Down

0 comments on commit b9275fb

Please sign in to comment.