Skip to content

Commit 7a499de

Browse files
authored
Merge pull request #68499 from rintaro/cxx-apinotes-target
[CMake] Fix several issues that caused unnecessary rebuild
2 parents 3a49ee9 + a182bdf commit 7a499de

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

stdlib/cmake/modules/SwiftSource.cmake

+7-2
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,10 @@ function(_compile_swift_files
921921
string(REPLACE ";" "'\n'" source_files_quoted "${source_files}")
922922
string(SHA1 file_name "'${source_files_quoted}'")
923923
set(file_path "${CMAKE_CURRENT_BINARY_DIR}/${file_name}.txt")
924-
file(WRITE "${file_path}" "'${source_files_quoted}'")
924+
file(WRITE "${file_path}.tmp" "'${source_files_quoted}'")
925+
add_custom_command(
926+
OUTPUT "${file_path}"
927+
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${file_path}.tmp" "${file_path}")
925928

926929
# If this platform/architecture combo supports backward deployment to old
927930
# Objective-C runtimes, we need to copy a YAML file with legacy type layout
@@ -1001,7 +1004,9 @@ function(_compile_swift_files
10011004
if(SWIFTFILE_STATIC)
10021005
set(command_copy_interface_file)
10031006
if(interface_file)
1004-
set(command_copy_interface_file COMMAND "${CMAKE_COMMAND}" "-E" "copy" ${interface_file} ${interface_file_static})
1007+
set(command_copy_interface_file
1008+
COMMAND "${CMAKE_COMMAND}" "-E" "copy" ${interface_file} ${interface_file_static}
1009+
COMMAND "${CMAKE_COMMAND}" "-E" "copy" ${private_interface_file} ${private_interface_file_static})
10051010
endif()
10061011
add_custom_command_target(
10071012
module_dependency_target_static

stdlib/public/Cxx/std/CMakeLists.txt

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
# API Notes for the C++ Standard Library
33
#
44
set(output_dir "${SWIFTLIB_DIR}/apinotes")
5-
add_custom_target(CxxStdlib-apinotes
5+
add_custom_command_target(unused_var
6+
CUSTOM_TARGET_NAME CxxStdlib-apinotes
67
COMMAND ${CMAKE_COMMAND} "-E" "make_directory" "${output_dir}"
78
COMMAND ${CMAKE_COMMAND} "-E" "copy_if_different" "${CMAKE_CURRENT_SOURCE_DIR}/std.apinotes" "${output_dir}"
8-
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/std.apinotes
9-
COMMENT "Copying CxxStdlib API Notes to ${output_dir}")
9+
COMMENT "Copying CxxStdlib API Notes to ${output_dir}"
10+
OUTPUT "${output_dir}/std.apinotes"
11+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/std.apinotes")
1012

1113
swift_install_in_component(FILES std.apinotes
1214
DESTINATION "lib/swift/apinotes"

0 commit comments

Comments
 (0)