Skip to content

Commit 310fb8c

Browse files
authored
Merge pull request #70282 from apple/es-b2
Update Driver to generate package interface only if package-name is p…
2 parents ad585b3 + 3f71ebb commit 310fb8c

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

lib/Driver/Driver.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,7 +2348,8 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
23482348
C.createAction<VerifyModuleInterfaceJobAction>(MergeModuleAction,
23492349
file_types::TY_PrivateSwiftModuleInterfaceFile));
23502350
}
2351-
if (Args.hasArgNoClaim(options::OPT_emit_package_module_interface_path)) {
2351+
if (Args.hasArg(options::OPT_package_name) &&
2352+
Args.hasArgNoClaim(options::OPT_emit_package_module_interface_path)) {
23522353
TopLevelActions.push_back(
23532354
C.createAction<VerifyModuleInterfaceJobAction>(MergeModuleAction,
23542355
file_types::TY_PackageSwiftModuleInterfaceFile));
@@ -2995,7 +2996,8 @@ Job *Driver::buildJobsForAction(Compilation &C, const JobAction *JA,
29952996
chooseModuleInterfacePath(C, JA, workingDirectory, Buf,
29962997
file_types::TY_PrivateSwiftModuleInterfaceFile, Output.get());
29972998

2998-
if (C.getArgs().hasArg(options::OPT_emit_package_module_interface_path))
2999+
if (C.getArgs().hasArg(options::OPT_package_name) &&
3000+
C.getArgs().hasArg(options::OPT_emit_package_module_interface_path))
29993001
chooseModuleInterfacePath(C, JA, workingDirectory, Buf,
30003002
file_types::TY_PackageSwiftModuleInterfaceFile, Output.get());
30013003

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
4+
/// A package swiftinterface should be generated only if -package-name is passed.
5+
// RUN: %target-build-swift -emit-module %t/Bar.swift -I %t \
6+
// RUN: -module-name Bar -package-name foopkg \
7+
// RUN: -enable-library-evolution -swift-version 5 \
8+
// RUN: -emit-module-interface-path %t/Bar.swiftinterface \
9+
// RUN: -emit-package-module-interface-path %t/Bar.package.swiftinterface
10+
11+
// RUN: %FileCheck %s < %t/Bar.package.swiftinterface
12+
// CHECK: -package-name foopkg
13+
// CHECK: public struct PubStruct
14+
// CHECK: package struct PkgStruct
15+
16+
/// If -package-name is not passed, a package interface should not be generated even if
17+
/// `-emit-package-module-interface-path` is passed.
18+
// RUN: %target-build-swift -emit-module %t/Baz.swift -I %t \
19+
// RUN: -module-name Baz \
20+
// RUN: -enable-library-evolution -swift-version 5 \
21+
// RUN: -emit-module-interface-path %t/Baz.swiftinterface \
22+
// RUN: -emit-package-module-interface-path %t/Baz.package.swiftinterface
23+
24+
// RUN: ls %t | not grep "Baz.package.swiftinterface"
25+
26+
//--- Bar.swift
27+
public struct PubStruct {
28+
29+
}
30+
31+
package struct PkgStruct {
32+
33+
}
34+
35+
//--- Baz.swift
36+
public struct PubStruct {
37+
38+
}

0 commit comments

Comments
 (0)