Skip to content

Commit f50a0b2

Browse files
authored
Merge pull request #82937 from edymtt/edymtt/account-for-incremental-builds-from-non-nested-swiftmodules
[Runtimes] handle incremental builds that have non nested swiftmodules
2 parents e34eb33 + c1d901d commit f50a0b2

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

Runtimes/Core/cmake/modules/EmitSwiftInterface.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ function(emit_swift_interface target)
1818
if(NOT module_name)
1919
set(module_name ${target})
2020
endif()
21-
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule")
21+
# Account for an existing swiftmodule file
22+
# generated with the previous logic
23+
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule"
24+
AND NOT IS_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule")
25+
message(STATUS "Removing regular file ${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule to support nested swiftmodule generation")
26+
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule")
27+
endif()
2228
target_compile_options(${target} PRIVATE
2329
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-emit-module-path ${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule/${SwiftCore_MODULE_TRIPLE}.swiftmodule>")
2430
if(SwiftCore_VARIANT_MODULE_TRIPLE)

Runtimes/Overlay/cmake/modules/EmitSwiftInterface.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ function(emit_swift_interface target)
1818
if(NOT module_name)
1919
set(module_name ${target})
2020
endif()
21-
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule")
21+
# Account for an existing swiftmodule file
22+
# generated with the previous logic
23+
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule"
24+
AND NOT IS_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule")
25+
message(STATUS "Removing regular file ${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule to support nested swiftmodule generation")
26+
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule")
27+
endif()
2228
target_compile_options(${target} PRIVATE
2329
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-emit-module-path ${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule/${SwiftOverlay_MODULE_TRIPLE}.swiftmodule>")
2430
if(SwiftOverlay_VARIANT_MODULE_TRIPLE)

Runtimes/Supplemental/cmake/modules/EmitSwiftInterface.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ function(emit_swift_interface target)
1818
if(NOT module_name)
1919
set(module_name ${target})
2020
endif()
21-
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule")
21+
# Account for an existing swiftmodule file
22+
# generated with the previous logic
23+
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule"
24+
AND NOT IS_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule")
25+
message(STATUS "Removing regular file ${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule to support nested swiftmodule generation")
26+
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule")
27+
endif()
2228
target_compile_options(${target} PRIVATE
2329
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-emit-module-path ${CMAKE_CURRENT_BINARY_DIR}/${module_name}.swiftmodule/${${PROJECT_NAME}_MODULE_TRIPLE}.swiftmodule>")
2430
if(${PROJECT_NAME}_VARIANT_MODULE_TRIPLE)

0 commit comments

Comments
 (0)