-
Notifications
You must be signed in to change notification settings - Fork 190
build: adopt current best practices for installation #1212
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
Open
compnerd
wants to merge
2
commits into
swiftlang:main
Choose a base branch
from
compnerd:nesting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
##===----------------------------------------------------------------------===## | ||
## | ||
## This source file is part of the Swift open source project | ||
## | ||
## Copyright (c) 2024 Apple Inc. and the Swift project authors | ||
## Licensed under Apache License v2.0 | ||
## | ||
## See LICENSE.txt for license information | ||
## See CONTRIBUTORS.md for the list of Swift project authors | ||
## | ||
## SPDX-License-Identifier: Apache-2.0 | ||
## | ||
##===----------------------------------------------------------------------===## | ||
|
||
set(print_target_info_invocation "${CMAKE_Swift_COMPILER}" -print-target-info) | ||
if(CMAKE_Swift_COMPILER_TARGET) | ||
list(APPEND print_target_info_invocation -target ${CMAKE_Swift_COMPILER_TARGET}) | ||
endif() | ||
execute_process(COMMAND ${print_target_info_invocation} OUTPUT_VARIABLE target_info_json) | ||
message(CONFIGURE_LOG "Swift Target Info: ${print_target_info_invocation}\n" | ||
"${target_info_json}") | ||
|
||
if(NOT SwiftFoundation_MODULE_TRIPLE) | ||
string(JSON module_triple GET "${target_info_json}" "target" "moduleTriple") | ||
set(SwiftFoundation_MODULE_TRIPLE "${module_triple}" CACHE STRING "Triple used for installed swift{doc,module,interface} files") | ||
mark_as_advanced(SwiftFoundation_MODULE_TRIPLE) | ||
|
||
message(CONFIGURE_LOG "Swift Module Triple: ${module_triple}") | ||
endif() | ||
|
||
if(NOT SwiftFoundation_PLATFORM_SUBDIR) | ||
string(JSON platform GET "${target_info_json}" "target" "platform") | ||
if(NOT platform) | ||
if(NOT SWIFT_SYSTEM_NAME) | ||
if(CMAKE_SYSTEM_NAME STREQUAL Darwin) | ||
set(platform macosx) | ||
else() | ||
set(platform $<LOWER_CASE:${CMAKE_SYSTEM_NAME}>) | ||
endif() | ||
endif() | ||
endif() | ||
set(SwiftFoundation_PLATFORM_SUBDIR "${platform}" CACHE STRING "Platform name used for installed swift{doc,module,interface} files") | ||
mark_as_advanced(SwiftFoundation_PLATFORM_SUBDIR) | ||
|
||
message(CONFIGURE_LOG "Swift Platform: ${platform}") | ||
endif() | ||
|
||
if(NOT SwiftFoundation_ARCH_SUBDIR) | ||
string(JSON arch GET "${target_info_json}" "target" "arch") | ||
set(SwiftFoundation_ARCH_SUBDIR "${arch}" CACHE STRING "Architecture used for setting the architecture subdirectory") | ||
mark_as_advanced(SwiftFoundation_ARCH_SUBDIR) | ||
|
||
message(CONFIGURE_LOG "Swift Architecture: ${arch}") | ||
endif() |
This file contains hidden or 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,54 +1,21 @@ | ||
# Returns the os name in a variable | ||
# | ||
# Usage: | ||
# get_swift_host_os(result_var_name) | ||
# | ||
# | ||
# Sets ${result_var_name} with the converted OS name derived from | ||
# CMAKE_SYSTEM_NAME. | ||
function(get_swift_host_os result_var_name) | ||
set(${result_var_name} ${SWIFT_SYSTEM_NAME} PARENT_SCOPE) | ||
endfunction() | ||
|
||
function(_swift_foundation_install_target module) | ||
get_swift_host_os(swift_os) | ||
get_target_property(type ${module} TYPE) | ||
|
||
if(type STREQUAL STATIC_LIBRARY) | ||
set(swift swift_static) | ||
else() | ||
set(swift swift) | ||
endif() | ||
|
||
install(TARGETS ${module} | ||
ARCHIVE DESTINATION lib/${swift}/${swift_os} | ||
LIBRARY DESTINATION lib/${swift}/${swift_os} | ||
ARCHIVE DESTINATION ${SwiftFoundation_INSTALL_LIBDIR} | ||
LIBRARY DESTINATION ${SwiftFoundation_INSTALL_LIBDIR} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
if(type STREQUAL EXECUTABLE) | ||
jmschonfeld marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return() | ||
endif() | ||
|
||
get_target_property(module_name ${module} Swift_MODULE_NAME) | ||
if(NOT module_name) | ||
set(module_name ${module}) | ||
endif() | ||
|
||
if(NOT SwiftFoundation_MODULE_TRIPLE) | ||
set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info) | ||
if(CMAKE_Swift_COMPILER_TARGET) | ||
list(APPEND module_triple_command -target ${CMAKE_Swift_COMPILER_TARGET}) | ||
endif() | ||
execute_process(COMMAND ${module_triple_command} OUTPUT_VARIABLE target_info_json) | ||
string(JSON module_triple GET "${target_info_json}" "target" "moduleTriple") | ||
set(SwiftFoundation_MODULE_TRIPLE "${module_triple}" CACHE STRING "swift module triple used for installed swiftmodule and swiftinterface files") | ||
mark_as_advanced(SwiftFoundation_MODULE_TRIPLE) | ||
endif() | ||
|
||
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftdoc | ||
DESTINATION lib/${swift}/${swift_os}/${module_name}.swiftmodule | ||
DESTINATION ${SwiftFoundation_INSTALL_SWIFTMODULEDIR}/${module_name}.swiftmodule | ||
RENAME ${SwiftFoundation_MODULE_TRIPLE}.swiftdoc) | ||
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftmodule | ||
DESTINATION lib/${swift}/${swift_os}/${module_name}.swiftmodule | ||
DESTINATION ${SwiftFoundation_INSTALL_SWIFTMODULEDIR}/${module_name}.swiftmodule | ||
jmschonfeld marked this conversation as resolved.
Show resolved
Hide resolved
|
||
RENAME ${SwiftFoundation_MODULE_TRIPLE}.swiftmodule) | ||
|
||
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftsourceinfo | ||
DESTINATION ${SwiftFoundation_INSTALL_SWIFTMODULEDIR}/${module_name}.swiftmodule | ||
RENAME ${SwiftFoundation_MODULE_TRIPLE}.swiftsourceinfo) | ||
endfunction() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.