Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix explosive memory use of inefficient _process_dependencies() #307

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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