-
Notifications
You must be signed in to change notification settings - Fork 36
build: add support for installing the image #124
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 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
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,51 @@ | ||
##===----------------------------------------------------------------------===## | ||
## | ||
## This source file is part of the Swift.org open source project | ||
## | ||
## Copyright (c) 2025 Apple Inc. and the Swift project authors | ||
## Licensed under Apache License v2.0 with Runtime Library Exception | ||
## | ||
## See https://swift.org/LICENSE.txt for license information | ||
## | ||
##===----------------------------------------------------------------------===## | ||
|
||
function(emit_swift_interface target) | ||
# Generate the target-variant binary swift module when performing zippered | ||
# build | ||
# | ||
# Clean this up once CMake has nested swiftmodules in the build directory: | ||
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/10664 | ||
# https://cmake.org/cmake/help/git-stage/policy/CMP0195.html | ||
|
||
# We can't expand the Swift_MODULE_NAME target property in a generator | ||
# expression or it will fail saying that the target doesn't exist. | ||
get_target_property(module_name ${target} Swift_MODULE_NAME) | ||
if(NOT module_name) | ||
set(module_name ${target}) | ||
endif() | ||
|
||
# Account for an existing swiftmodule file generated with the previous logic | ||
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule" | ||
AND NOT IS_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule") | ||
message(STATUS "Removing regular file ${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule to support nested swiftmodule generation") | ||
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule") | ||
endif() | ||
|
||
target_compile_options(${target} PRIVATE | ||
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-emit-module-path ${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule/${${PROJECT_NAME}_MODULE_TRIPLE}.swiftmodule>") | ||
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule/${${PROJECT_NAME}_MODULE_TRIPLE}.swiftmodule" | ||
DEPENDS ${target}) | ||
target_sources(${target} | ||
INTERFACE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule/${${PROJECT_NAME}_MODULE_TRIPLE}.swiftmodule>) | ||
|
||
# Generate textual swift interfaces is library-evolution is enabled | ||
if(${PROJECT_NAME}_ENABLE_LIBRARY_EVOLUTION) | ||
target_compile_options(${target} PRIVATE | ||
$<$<COMPILE_LANGUAGE:Swift>:-emit-module-interface-path$<SEMICOLON>${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule/${${PROJECT_NAME}_MODULE_TRIPLE}.swiftinterface> | ||
$<$<COMPILE_LANGUAGE:Swift>:-emit-private-module-interface-path$<SEMICOLON>${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule/${${PROJECT_NAME}_MODULE_TRIPLE}.private.swiftinterface>) | ||
target_compile_options(${target} PRIVATE | ||
$<$<COMPILE_LANGUAGE:Swift>:-library-level$<SEMICOLON>api> | ||
$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend$<SEMICOLON>-require-explicit-availability=ignore>) | ||
endif() | ||
endfunction() |
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,23 @@ | ||
##===----------------------------------------------------------------------===## | ||
## | ||
## This source file is part of the Swift.org open source project | ||
## | ||
## Copyright (c) 2025 Apple Inc. and the Swift project authors | ||
## Licensed under Apache License v2.0 with Runtime Library Exception | ||
## | ||
## See https://swift.org/LICENSE.txt for license information | ||
## | ||
##===----------------------------------------------------------------------===## | ||
|
||
# Install the generated swift interface files for the target. | ||
function(install_swift_interface target) | ||
# Swiftmodules are already in the directory structure | ||
get_target_property(module_name ${target} Swift_MODULE_NAME) | ||
if(NOT module_name) | ||
set(module_name ${target}) | ||
endif() | ||
|
||
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule" | ||
DESTINATION "${${PROJECT_NAME}_INSTALL_SWIFTMODULEDIR}" | ||
COMPONENT SwiftSubprocess_development) | ||
endfunction() |
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,43 @@ | ||
##===----------------------------------------------------------------------===## | ||
## | ||
## This source file is part of the Swift.org open source project | ||
## | ||
## Copyright (c) 2025 Apple Inc. and the Swift project authors | ||
## Licensed under Apache License v2.0 with Runtime Library Exception | ||
## | ||
## See https://swift.org/LICENSE.txt for license information | ||
## | ||
##===----------------------------------------------------------------------===## | ||
|
||
# TODO: This logic should migrate to CMake once CMake supports installing swiftmodules | ||
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) | ||
message(CONFIGURE_LOG "Swift target info: ${module_triple_command}\n" | ||
"${target_info_json}") | ||
|
||
if(NOT ${PROJECT_NAME}_MODULE_TRIPLE) | ||
string(JSON module_triple GET "${target_info_json}" "target" "moduleTriple") | ||
set(${PROJECT_NAME}_MODULE_TRIPLE "${module_triple}" CACHE STRING "Triple used for installed swift{doc,module,interface} files") | ||
mark_as_advanced(${PROJECT_NAME}_MODULE_TRIPLE) | ||
|
||
message(CONFIGURE_LOG "Swift module triple: ${module_triple}") | ||
endif() | ||
|
||
if(NOT ${PROJECT_NAME}_PLATFORM_SUBDIR) | ||
string(JSON platform GET "${target_info_json}" "target" "platform") | ||
set(${PROJECT_NAME}_PLATFORM_SUBDIR "${platform}" CACHE STRING "Platform name used for installed swift{doc,module,interface} files") | ||
mark_as_advanced(${PROJECT_NAME}_PLATFORM_SUBDIR) | ||
|
||
message(CONFIGURE_LOG "Swift platform: ${platform}") | ||
endif() | ||
|
||
if(NOT ${PROJECT_NAME}_ARCH_SUBDIR) | ||
string(JSON arch GET "${target_info_json}" "target" "arch") | ||
set(${PROJECT_NAME}_ARCH_SUBDIR "${arch}" CACHE STRING "Architecture used for setting the architecture subdirectory") | ||
mark_as_advanced(${PROJECT_NAME}_ARCH_SUBDIR) | ||
|
||
message(CONFIGURE_LOG "Swift Arch: ${arch}") | ||
endif() |
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.
Was this bump intentional? I had used 6.1 to keep it in sync with the required version in
Package.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.
and it would require more effort to make this compatible with 6.1; no reason to add support for something we will never use
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.
oh, this was for the
platform
andarch
subdirectories wasn't it?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.
It isn't though. I have projects that are non-SwiftPM that use this build today.
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.
We could set
Subprocess_INSTALL_NESTED_SUBDIR
toOFF
when using something earlier than 6.2 and the arch and platform subdirs aren't set. Then we wouldn't need to request that info from the compiler.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.
Windows will want that, so we will need to set that to true for CI
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.
Ah, that's unfortunate...