From b4f725330ecf959e5a17b467e3ac65a72b5b9e33 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 4 May 2020 18:35:31 -0700 Subject: [PATCH] eden: regenerate Cargo.lock on each cargo invocation Summary: When using our vendored set of crates, cmake doesn't have any dependency information to use to invalidate the Cargo.lock file when we update crate versions. In addition, since we're vendoring from a local directory, cargo itself doesn't seem to want to re-assess the dependencies in that same situation, leading to confusing error messages like this when we want to build rust targets: ``` error: failed to select a version for the requirement `anyhow = "= 1.0.26"` candidate versions found which didn't match: 1.0.28 ``` This commit addresses this issue by removing the `Cargo.lock` that may be alongside the `Cargo.toml` prior to invoking `cargo`. `cargo` is pretty quick at recomputing the deps so this has neglible overhead. Reviewed By: xavierd Differential Revision: D21394363 fbshipit-source-id: 547db2e2395a47aed77d9597e659eb2d96e274dd --- CMake/RustStaticLibrary.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMake/RustStaticLibrary.cmake b/CMake/RustStaticLibrary.cmake index 3997573201..b19429a7ba 100644 --- a/CMake/RustStaticLibrary.cmake +++ b/CMake/RustStaticLibrary.cmake @@ -102,6 +102,8 @@ function(rust_static_library TARGET) add_custom_target( ${cargo_target} + COMMAND + "${CMAKE_COMMAND}" -E remove -f "${CMAKE_CURRENT_SOURCE_DIR}/Cargo.lock" COMMAND "${CMAKE_COMMAND}" -E env "CARGO_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR}" @@ -157,6 +159,8 @@ function(rust_executable TARGET) add_custom_target( ${cargo_target} ALL + COMMAND + "${CMAKE_COMMAND}" -E remove -f "${CMAKE_CURRENT_SOURCE_DIR}/Cargo.lock" COMMAND "${CMAKE_COMMAND}" -E env "CARGO_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR}"