Skip to content

[6.2] [SymbolGraphGen] add flags to filter platforms out of availability metadata #80806

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

Merged
merged 3 commits into from
Apr 21, 2025

Conversation

QuietMisdreavus
Copy link
Contributor

  • Explanation: Adds platform filtering options to SymbolGraphGen so that the at-desk standard library documentation can be built without Apple-specific platform information.
  • Scope: Small build-script change plus new code paths in SymbolGraphGen.
  • Issues: rdar://144379124
  • Original PRs: [SymbolGraphGen] add flags to filter platforms out of availability metadata #80778
  • Risk: Low. This code only adds a code path during symbol graph generation when new CLI arguments are provided; default behavior and regular compilation are unaffected.
  • Testing: An automated test has been added. The --preview-stdlib-docs functionality was tested at-desk.
  • Reviewers: @d-ronnqvist @anferbui

…tadata (#80778)

* add option to filter availability metadata in symbol graphs

* filter out platform-specific availability in the stdlib docs

rdar://144379124
@QuietMisdreavus QuietMisdreavus requested a review from a team as a code owner April 14, 2025 22:33
@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please test

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please test macOS

Comment on lines 206 to 215
if (auto *A = ParsedArgs.getLastArg(OPT_allow_availability_platforms)) {
llvm::SmallVector<StringRef> AvailabilityPlatforms;
StringRef(A->getValue())
.split(AvailabilityPlatforms, ',', /*MaxSplits*/ -1,
/*KeepEmpty*/ false);
Options.AvailabilityPlatforms = llvm::DenseSet<StringRef>(
AvailabilityPlatforms.begin(), AvailabilityPlatforms.end());
Options.AvailabilityIsBlockList = false;
} else if (auto *A =
ParsedArgs.getLastArg(OPT_block_availability_platforms)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way this is written, it will take any "allow" even if there is a "block" coming later, which is unexpected. I'd recommend using the getLastArg form that takes both option names, so you get the last of either, and then set the Boolean based on which flag you got.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if there was a better way to go about it. Thanks for the suggestion! I can apply this here and forward-port it back to main afterward if that's okay.

@@ -2221,6 +2221,25 @@ static void ParseSymbolGraphArgs(symbolgraphgen::SymbolGraphOptions &Opts,
Opts.MinimumAccessLevel = AccessLevel::Public;
}

if (auto *A = Args.getLastArg(OPT_symbol_graph_allow_availability_platforms)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment for this copy of the code.

# FIXME: swiftDarwin currently trips an assertion in SymbolGraphGen
if (SWIFTLIB_IS_STDLIB AND SWIFT_STDLIB_BUILD_SYMBOL_GRAPHS AND NOT ${name} STREQUAL "swiftDarwin")
# FIXME: swiftDarwin and swiftDifferentiationUnittest currently trip an assertion in SymbolGraphGen
if (SWIFTLIB_IS_STDLIB AND SWIFT_STDLIB_BUILD_SYMBOL_GRAPHS AND NOT ${name} STREQUAL "swiftDarwin"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes. I'm okay with extending this existing hack, but do we know what's going on here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't had the opportunity to look into this. I assume there's some kind of construction that we're trying to handle incorrectly, but i have dug into what and why.

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please test

@QuietMisdreavus QuietMisdreavus merged commit 61c4a03 into release/6.2 Apr 21, 2025
5 checks passed
@QuietMisdreavus QuietMisdreavus deleted the vgm/6.2/sgf-platform-filter branch April 21, 2025 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants