Skip to content

[Dependency Scanning] Inherit target SDK name and version for textual interface build recipes #76465

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
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
13 changes: 13 additions & 0 deletions lib/Frontend/ModuleInterfaceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,19 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
GenericArgs.push_back(triple);
}

// Inherit the target SDK name and version
if (!LangOpts.SDKName.empty()) {
genericSubInvocation.getLangOptions().SDKName = LangOpts.SDKName;
GenericArgs.push_back("-target-sdk-name");
GenericArgs.push_back(ArgSaver.save(LangOpts.SDKName));
}
if (LangOpts.SDKVersion.has_value()) {
genericSubInvocation.getLangOptions().SDKVersion = LangOpts.SDKVersion;
GenericArgs.push_back("-target-sdk-version");
GenericArgs.push_back(ArgSaver.save(LangOpts.SDKVersion.value()
.getAsString()));
}

// Inherit the Swift language version
genericSubInvocation.getLangOptions().EffectiveLanguageVersion =
LangOpts.EffectiveLanguageVersion;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface %s -o %t/deps.json -target-sdk-version 15.0 -target-sdk-name macosx15.0.test_name

// Check the contents of the JSON output
// RUN: %validate-json %t/deps.json | %FileCheck %s

func foo() { print(1) }

// CHECK: "-target-sdk-name",
// CHECK-NEXT: "macosx15.0.test_name"
// CHECK: "-target-sdk-version",
// CHECK-NEXT: "15.0"