-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify PackageDescription 4.0 and 4.2+ into a single library by using …
…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
- Loading branch information
1 parent
79152ec
commit 2d64d68
Showing
13 changed files
with
161 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.