diff --git a/vm/framework/move-stdlib/Cargo.toml b/vm/framework/move-stdlib/Cargo.toml index c67b87a4e8..16cd6d663d 100644 --- a/vm/framework/move-stdlib/Cargo.toml +++ b/vm/framework/move-stdlib/Cargo.toml @@ -21,6 +21,7 @@ sha3 = "0.9.1" smallvec = "1.6.1" include_dir = { workspace = true } once_cell = { workspace = true } +tempfile = { workspace = true } [dev-dependencies] dir-diff = "0.3.2" diff --git a/vm/framework/move-stdlib/src/lib.rs b/vm/framework/move-stdlib/src/lib.rs index a9b43ede48..bf1b6af7bd 100644 --- a/vm/framework/move-stdlib/src/lib.rs +++ b/vm/framework/move-stdlib/src/lib.rs @@ -10,6 +10,8 @@ use once_cell::sync::Lazy; pub const MOVE_STDLIB_SOURCES_DIR: Dir = include_dir!("sources"); pub static MOVE_STDLIB_SOURCE_FILES: Lazy> = Lazy::new(|| { + let tempdir = tempfile::tempdir().expect("local dir should be created"); + let sources_dir = tempdir.path().join("move-stdlib").join("sources"); MOVE_STDLIB_SOURCES_DIR .files() .iter() @@ -17,7 +19,7 @@ pub static MOVE_STDLIB_SOURCE_FILES: Lazy> = Lazy::new(|| { let ext = file.path().extension(); if let Some(ext) = ext { if ext == "move" { - Some(file.path().display().to_string()) + Some(sources_dir.join(file.path()).display().to_string()) } else { None } @@ -31,6 +33,8 @@ pub static MOVE_STDLIB_SOURCE_FILES: Lazy> = Lazy::new(|| { pub const STARCOIN_STDLIB_SOURCES_DIR: Dir = include_dir!("../starcoin-stdlib/sources"); pub static STARCOIN_STDLIB_SOURCE_FILES: Lazy> = Lazy::new(|| { + let tempdir = tempfile::tempdir().expect("local dir should be created"); + let sources_dir = tempdir.path().join("move-stdlib").join("sources"); STARCOIN_STDLIB_SOURCES_DIR .files() .iter() @@ -38,7 +42,7 @@ pub static STARCOIN_STDLIB_SOURCE_FILES: Lazy> = Lazy::new(|| { let ext = file.path().extension(); if let Some(ext) = ext { if ext == "move" { - Some(file.path().display().to_string()) + Some(sources_dir.join(file.path()).display().to_string()) } else { None }