Skip to content
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

Properly detect changes in Rust code and recompile Rust libraries #45981

Merged
merged 2 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion rust/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,20 @@ file(COPY ".cargo" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
function(add_rust_subdirectory src)
set(dst "${CMAKE_CURRENT_BINARY_DIR}/${src}")
message(STATUS "Copy ${src} to ${dst}")
file(COPY "${src}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY "${src}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}"
PATTERN target EXCLUDE)
add_subdirectory("${dst}" "${dst}")

# cmake -E copy* do now know how to exclude files
# but we need to exclude "target" folder from copying, if someone or semantic
# completion created it.
add_custom_target(${src}-update ALL
COMMAND ${CMAKE_COMMAND}
-DFROM=${src}
-DTO=${CMAKE_CURRENT_BINARY_DIR}
-P "${CMAKE_CURRENT_SOURCE_DIR}/copy_exclude.cmake"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
VERBATIM)
endfunction()

add_rust_subdirectory (BLAKE3)
Expand Down
2 changes: 2 additions & 0 deletions rust/copy_exclude.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
file(COPY "${FROM}" DESTINATION "${TO}"
PATTERN target EXCLUDE)