-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,73 @@ | ||
# This source file is part of the Swift.org open source project | ||
# | ||
# Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors | ||
# Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors | ||
# Licensed under Apache License v2.0 with Runtime Library Exception | ||
# | ||
# See http://swift.org/LICENSE.txt for license information | ||
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
|
||
foreach(PACKAGE_DESCRIPTION_VERSION 4 4_2) | ||
add_library(PD${PACKAGE_DESCRIPTION_VERSION} | ||
BuildSettings.swift | ||
LanguageStandardSettings.swift | ||
PackageDescription.swift | ||
PackageDependency.swift | ||
PackageRequirement.swift | ||
Product.swift | ||
Resource.swift | ||
SupportedPlatforms.swift | ||
Target.swift | ||
Version.swift | ||
Version+StringLiteralConvertible.swift) | ||
add_library(PackageDescription | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
BuildSettings.swift | ||
LanguageStandardSettings.swift | ||
PackageDescription.swift | ||
PackageDependency.swift | ||
PackageRequirement.swift | ||
Product.swift | ||
Resource.swift | ||
SupportedPlatforms.swift | ||
Target.swift | ||
Version.swift | ||
Version+StringLiteralConvertible.swift) | ||
|
||
target_compile_definitions(PD${PACKAGE_DESCRIPTION_VERSION} PRIVATE | ||
PACKAGE_DESCRIPTION_${PACKAGE_DESCRIPTION_VERSION}) | ||
target_compile_options(PackageDescription PUBLIC | ||
$<$<COMPILE_LANGUAGE:Swift>:-package-description-version$<SEMICOLON>999.0>) | ||
target_compile_options(PackageDescription PUBLIC | ||
$<$<COMPILE_LANGUAGE:Swift>:-enable-library-evolution>) | ||
|
||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin) | ||
set(SWIFT_INTERFACE_PATH ${CMAKE_BINARY_DIR}/pm/${PACKAGE_DESCRIPTION_VERSION}/PackageDescription.swiftinterface) | ||
target_compile_options(PD${PACKAGE_DESCRIPTION_VERSION} PUBLIC | ||
$<$<COMPILE_LANGUAGE:Swift>:-enable-library-evolution>) | ||
target_compile_options(PD${PACKAGE_DESCRIPTION_VERSION} PUBLIC | ||
$<$<COMPILE_LANGUAGE:Swift>:-emit-module-interface-path$<SEMICOLON>${SWIFT_INTERFACE_PATH}>) | ||
target_link_options(PD${PACKAGE_DESCRIPTION_VERSION} PRIVATE | ||
"SHELL:-Xlinker -install_name -Xlinker @rpath/libPackageDescription.dylib") | ||
endif() | ||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin) | ||
set(SWIFT_INTERFACE_PATH ${CMAKE_BINARY_DIR}/pm/ManifestAPI/PackageDescription.swiftinterface) | ||
target_compile_options(PackageDescription PUBLIC | ||
$<$<COMPILE_LANGUAGE:Swift>:-emit-module-interface-path$<SEMICOLON>${SWIFT_INTERFACE_PATH}>) | ||
target_link_options(PackageDescription PRIVATE | ||
"SHELL:-Xlinker -install_name -Xlinker @rpath/libPackageDescription.dylib") | ||
endif() | ||
|
||
set_target_properties(PD${PACKAGE_DESCRIPTION_VERSION} PROPERTIES | ||
Swift_MODULE_NAME PackageDescription | ||
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/pm/${PACKAGE_DESCRIPTION_VERSION} | ||
INSTALL_NAME_DIR \\@rpath | ||
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/${PACKAGE_DESCRIPTION_VERSION} | ||
OUTPUT_NAME PackageDescription | ||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/${PACKAGE_DESCRIPTION_VERSION} | ||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/${PACKAGE_DESCRIPTION_VERSION} | ||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/${PACKAGE_DESCRIPTION_VERSION} | ||
) | ||
set_target_properties(PackageDescription PROPERTIES | ||
Swift_MODULE_NAME PackageDescription | ||
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI | ||
INSTALL_NAME_DIR \\@rpath | ||
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI | ||
OUTPUT_NAME PackageDescription | ||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI | ||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI | ||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI | ||
) | ||
|
||
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) | ||
if(Foundation_FOUND) | ||
target_link_libraries(PD${PACKAGE_DESCRIPTION_VERSION} PRIVATE | ||
Foundation) | ||
endif() | ||
target_link_options(PD${PACKAGE_DESCRIPTION_VERSION} PRIVATE | ||
"SHELL:-no-toolchain-stdlib-rpath") | ||
set_target_properties(PD${PACKAGE_DESCRIPTION_VERSION} PROPERTIES | ||
BUILD_WITH_INSTALL_RPATH TRUE | ||
INSTALL_RPATH "$ORIGIN/../../$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>") | ||
endif() | ||
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) | ||
if(Foundation_FOUND) | ||
target_link_libraries(PackageDescription PRIVATE | ||
Foundation) | ||
endif() | ||
target_link_options(PackageDescription PRIVATE | ||
"SHELL:-no-toolchain-stdlib-rpath") | ||
set_target_properties(PackageDescription PROPERTIES | ||
BUILD_WITH_INSTALL_RPATH TRUE | ||
INSTALL_RPATH "$ORIGIN/../../$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>") | ||
endif() | ||
|
||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin) | ||
install(FILES | ||
${CMAKE_BINARY_DIR}/pm/${PACKAGE_DESCRIPTION_VERSION}/PackageDescription.swiftinterface | ||
${CMAKE_BINARY_DIR}/pm/${PACKAGE_DESCRIPTION_VERSION}/PackageDescription.swiftdoc | ||
DESTINATION lib/swift/pm/${PACKAGE_DESCRIPTION_VERSION} | ||
) | ||
else() | ||
install(FILES | ||
${CMAKE_BINARY_DIR}/pm/${PACKAGE_DESCRIPTION_VERSION}/PackageDescription.swiftmodule | ||
${CMAKE_BINARY_DIR}/pm/${PACKAGE_DESCRIPTION_VERSION}/PackageDescription.swiftdoc | ||
DESTINATION lib/swift/pm/${PACKAGE_DESCRIPTION_VERSION} | ||
) | ||
endif() | ||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin) | ||
install(FILES | ||
${CMAKE_BINARY_DIR}/pm/ManifestAPI/PackageDescription.swiftinterface | ||
${CMAKE_BINARY_DIR}/pm/ManifestAPI/PackageDescription.swiftdoc | ||
DESTINATION lib/swift/pm/ManifestAPI | ||
) | ||
else() | ||
install(FILES | ||
${CMAKE_BINARY_DIR}/pm/ManifestAPI/PackageDescription.swiftmodule | ||
${CMAKE_BINARY_DIR}/pm/ManifestAPI/PackageDescription.swiftdoc | ||
DESTINATION lib/swift/pm/ManifestAPI | ||
) | ||
endif() | ||
|
||
install(TARGETS PD${PACKAGE_DESCRIPTION_VERSION} | ||
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 commentThe 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 |
Uh oh!
There was an error while loading. Please reload this page.