-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Unify the two versions of PackageDescription into a single one using availability annotations instead of compile conditionals #3464
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
Conversation
@@ -98,7 +98,7 @@ class PackageDescription4_2LoadingTests: PackageDescriptionLoadingTests { | |||
guard case let ManifestParseError.invalidManifestFormat(output, _) = error else { | |||
return XCTFail() | |||
} | |||
XCTAssertMatch(output, .and(.or(.contains("expected argument type"), .contains("expected element type")), .contains("SwiftVersion"))) | |||
XCTAssertMatch(output, .and(.contains("'init(name:pkgConfig:providers:products:dependencies:targets:swiftLanguageVersions:cLanguageStandard:cxxLanguageStandard:)' is unavailable"), .contains("was obsoleted in PackageDescription 4.2"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This accounts for the difference in error message. The "is unavailable" is arguably a more accurate one anyway.
@swift-ci please smoke test |
e1adf20
to
7fde8bc
Compare
7fde8bc
to
3b4a6ce
Compare
@swift-ci please smoke test |
3b4a6ce
to
7c78ff9
Compare
@swift-ci please smoke test |
Target.swift | ||
Version.swift | ||
Version+StringLiteralConvertible.swift) | ||
add_library(PackageDescription |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While unwinding the loop I also made this conform to the 2-space indentation that we seem to be using for CMakefiles.
@@ -397,22 +397,21 @@ def install_swiftpm(prefix, args): | |||
runtime_lib_dest = os.path.join(prefix, "lib", "swift", "pm") | |||
runtime_lib_src = os.path.join(args.bootstrap_dir, "pm") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that for now we’re still installing the bootstrap-built PackageDescription. This will change in the follow-on PR.
7c78ff9
to
f157789
Compare
@swift-ci please smoke test |
@@ -7,60 +7,63 @@ | |||
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors | |||
|
|||
add_library(PackagePlugin | |||
PublicAPI/CommandConstructor.swift |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While modifying the CMakefile I made it conform to the 2-space indentation that we seem to be using for CMakefiles.
DESTINATION lib/swift/pm/${PACKAGE_DESCRIPTION_VERSION}) | ||
endforeach() | ||
install(TARGETS PackageDescription | ||
DESTINATION lib/swift/pm/ManifestAPI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than relying on a directory named after the version number to keep the library apart from the PackagePlugin library, I added a subdirectory here named after the subsystem for which this is an API. The plugin one is called PluginAPI
, and I can imagine that we'd have additional ones as needed.
endif() | ||
|
||
install(TARGETS PackagePlugin | ||
DESTINATION lib/swift/pm) | ||
DESTINATION lib/swift/pm/PluginAPI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With PackageDescription no longer living in a directory named after the version number to keep the library apart from the PackagePlugin library, I put each subsystem's API into a separate subdirectory here named after the subsystem for which this is an API. The plugin one is called PluginAPI
, and I can imagine that we'd have additional ones as needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
would like to see what @neonichu thinks before we merge
…availability annotations instead of #if Replace the compile-time conditionals in PackageDescription with availability annotations. This lets us build a single PackageDescription, which will make the build scripts easier (with the goal of being able to build it entirely from the package itself). As part of this we also clean up the runtime library subdirectories. Until now we've had PackagePlugin directly in the runtime library directory, and PackageDescription under subdirectories called "4" and "4_2". This has sufficed in keeping PackageDescription and PackagePlugin in separate directories (so that a manifest or plugin script can't import both). This needs to be changed now that there is only one version of a PackageDescription, and anyway it's time to clean this up. So as part of this we also establish two subdirectories for the runtime APIs: "ManifestAPI" and "PluginAPI". If we add more kinds of scripts, we can then add new subdirectories here. rdar://77441062
f157789
to
2d64d68
Compare
@swift-ci please smoke test |
Error doesn't look related. Rerunning. |
@swift-ci please smoke test linux |
@neonichu Do you have any concerns about this change? |
@@ -203,27 +189,21 @@ public final class Package { | |||
/// The list of package dependencies. | |||
public var dependencies: [Dependency] | |||
|
|||
#if PACKAGE_DESCRIPTION_4 | |||
/// The list of Swift versions that this package is compatible with. | |||
public var swiftLanguageVersions: [Int]? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change, right? In the past, we went through the trouble creating two versions because we didn't want to break this part of the API but I doubt that there are a lot of packages that will actually get affected by this..
This updates the devtools packaging to account for the unified module layout that SPM adopted in swiftlang/swift-package-manager#3464.
This updates the devtools packaging to account for the unified module layout that SPM adopted in swiftlang/swift-package-manager#3464.
This updates the devtools packaging to account for the unified module layout that SPM adopted in swiftlang/swift-package-manager#3464.
This updates the devtools packaging to account for the unified module layout that SPM adopted in swiftlang/swift-package-manager#3464.
Replace the compile-time conditionals in PackageDescription with availability annotations, and build a single runtime library that can be used for all package tools versions.
Motivation:
This is preparatory work for #3431 and will also make it easier for clients of libSwiftPM, since only one version of PackageDescription needs to be built.
Background:
The runtime support library for PackageDescription is currently built twice: once for SwiftPM 4.0 and another time for 4.2 and later. This is done using compile-time conditionals, producing two separate binaries in the file system. Code in the manifest loader chooses between them based on the declared tools version of the package.
Having two versions of the library has several problems:
We can unify the two versions using @Availability annotations, so that we only need one PackageDescription library. We should still keep it in a separate subdirectory from the PackagePlugins runtime support library. Instead of using the names “4” and “4_2” as the subdirectory names, we should take this opportunity to separate them based on something more meaningful, such as “ManifestAPI” and “PluginAPI”.
Modifications:
-package-description-version 5.5
and-enable-library-evolution
Result:
This builds PackageDescription libraries that aren't dependent on the compile time condition.
rdar://77441062