-
Notifications
You must be signed in to change notification settings - Fork 1.2k
build: Install libraries in an arch
sub-folder
#5257
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
Steelskin
wants to merge
1
commit into
swiftlang:main
Choose a base branch
from
Steelskin:fabrice/build-install-swift-libraries-arch-folder
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
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
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 |
---|---|---|
|
@@ -12,8 +12,55 @@ | |
## | ||
##===----------------------------------------------------------------------===## | ||
|
||
if(NOT SwiftFoundation_MODULE_TRIPLE OR NOT SwiftFoundation_ARCH OR NOT SwiftFoundation_PLATFORM) | ||
# Get the target information from the Swift compiler. | ||
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) | ||
endif() | ||
|
||
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 to install swiftmodule files") | ||
mark_as_advanced(SwiftFoundation_MODULE_TRIPLE) | ||
message(CONFIGURE_LOG "Swift module triple: ${module_triple}") | ||
endif() | ||
|
||
if(NOT SwiftFoundation_ARCH) | ||
if(CMAKE_Swift_COMPILER_VERSION VERSION_EQUAL 0.0.0 OR CMAKE_Swift_COMPILER_VERSION VERSION_GREATER_EQUAL 6.2) | ||
# For newer compilers, we can use the -print-target-info command to get the architecture. | ||
string(JSON module_arch GET "${target_info_json}" "target" "arch") | ||
else() | ||
# For older compilers, extract the value from `SwiftFoundation_MODULE_TRIPLE`. | ||
string(REGEX MATCH "^[^-]+" module_arch "${SwiftFoundation_MODULE_TRIPLE}") | ||
endif() | ||
|
||
set(SwiftFoundation_ARCH "${module_arch}" CACHE STRING "Arch folder name used to install libraries") | ||
mark_as_advanced(SwiftFoundation_ARCH) | ||
message(CONFIGURE_LOG "Swift arch: ${SwiftFoundation_ARCH}") | ||
endif() | ||
|
||
if(NOT SwiftFoundation_PLATFORM) | ||
if(CMAKE_Swift_COMPILER_VERSION VERSION_EQUAL 0.0.0 OR CMAKE_Swift_COMPILER_VERSION VERSION_GREATER_EQUAL 6.2) | ||
# For newer compilers, we can use the -print-target-info command to get the platform. | ||
string(JSON swift_platform GET "${target_info_json}" "target" "platform") | ||
else() | ||
# For older compilers, compile the value from `CMAKE_SYSTEM_NAME`. | ||
if(APPLE) | ||
set(swift_platform macosx) | ||
else() | ||
set(swift_platform "$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>") | ||
endif() | ||
endif() | ||
|
||
set(SwiftFoundation_PLATFORM "${swift_platform}" CACHE STRING "Platform folder name used to install libraries") | ||
mark_as_advanced(SwiftFoundation_PLATFORM) | ||
message(CONFIGURE_LOG "Swift platform: ${SwiftFoundation_PLATFORM}") | ||
endif() | ||
|
||
function(_foundation_install_target module) | ||
set(swift_os ${SWIFT_SYSTEM_NAME}) | ||
get_target_property(type ${module} TYPE) | ||
|
||
if(type STREQUAL STATIC_LIBRARY) | ||
|
@@ -23,8 +70,8 @@ function(_foundation_install_target module) | |
endif() | ||
|
||
install(TARGETS ${module} | ||
ARCHIVE DESTINATION lib/${swift}/${swift_os} | ||
LIBRARY DESTINATION lib/${swift}/${swift_os} | ||
ARCHIVE DESTINATION lib/${swift}/${SwiftFoundation_PLATFORM}$<$<BOOL:${SwiftFoundation_INSTALL_ARCH_SUBDIR}>:/${SwiftFoundation_ARCH}> | ||
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. It looks like you're only applying the arch subdirectory at install time for the swift modules. What about the other C modules for the static SDK? |
||
LIBRARY DESTINATION lib/${swift}/${SwiftFoundation_PLATFORM}$<$<BOOL:${SwiftFoundation_INSTALL_ARCH_SUBDIR}>:/${SwiftFoundation_ARCH}> | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
if(type STREQUAL EXECUTABLE) | ||
return() | ||
|
@@ -36,10 +83,10 @@ function(_foundation_install_target module) | |
endif() | ||
|
||
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftdoc | ||
DESTINATION lib/${swift}/${swift_os}/${module_name}.swiftmodule | ||
DESTINATION lib/${swift}/${SwiftFoundation_PLATFORM}/${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 lib/${swift}/${SwiftFoundation_PLATFORM}/${module_name}.swiftmodule | ||
RENAME ${SwiftFoundation_MODULE_TRIPLE}.swiftmodule) | ||
|
||
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.
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.
I don't think these version checks are necessary - the
main
branch of Foundation must be built using at least a recent nightly snapshot of themain
branch of the compiler, so this check should never fail