Skip to content

Commit

Permalink
buck2 | Filter out frameworks from apple_static_archive
Browse files Browse the repository at this point in the history
Summary:
There are a few-and-far-between targets that deliberately inject `-framework Foundation`, etc. into linker_args.

Because they take the form of an `-option` arg followed by another arg, the framework names make their way into the list of files used by `apple_static_archive()`

This diff filters these out as non-files in the  prexisting `_filter_files()` function.

Differential Revision: D68766678

fbshipit-source-id: 17b4bd52c8b023400ef4965cc7d8bb11c7ac0bb5
  • Loading branch information
benb authored and facebook-github-bot committed Jan 30, 2025
1 parent 6fffc05 commit 9b5f1e6
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions prelude/apple/tools/static_archive_linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,25 @@


def _filter_files(args):
# Filter out any arg that starts with '-'. Assumes that other args are
# files that should be passed to libtool.
# Filter out any arg that starts with '-'. Also filter out passed arg
# pairs like '-framework Cocoa'. Assumes that other args are files that
# should be passed to libtool.
# Rationale: There's no way of checking if an arg is intended to be a file.
# Having a filter that looks checks if a file with a given path exists will
# Having a filter that checks if a file with a given path exists will
# silently remove the arg in the event of an error where arg is a file and
# the file does not exist.
return [arg for arg in args if not arg.startswith("-")]
filtered_args = []
skip_next = False
for arg in args:
if skip_next:
skip_next = False
continue
if arg.startswith("-"):
if arg == "-framework":
skip_next = True
continue
filtered_args.append(arg)
return filtered_args


def _main() -> None:
Expand Down

0 comments on commit 9b5f1e6

Please sign in to comment.