Skip to content

Commit

Permalink
use relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg committed Dec 9, 2024
1 parent a9189f1 commit ef40ab1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 29 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions vm/framework/move-stdlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ sha3 = "0.9.1"
smallvec = "1.6.1"
include_dir = { workspace = true }
once_cell = { workspace = true }
tempfile = { workspace = true }
starcoin-logger = { workspace = true }

[dev-dependencies]
dir-diff = "0.3.2"
Expand Down
33 changes: 7 additions & 26 deletions vm/framework/move-stdlib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,29 @@

use include_dir::{include_dir, Dir};
use once_cell::sync::Lazy;
use starcoin_logger::prelude::*;
use std::env;
pub const MOVE_STDLIB_SOURCES_DIR: Dir = include_dir!("sources");

pub static MOVE_STDLIB_SOURCE_FILES: Lazy<Vec<String>> = Lazy::new(|| {
let tempdir = tempfile::tempdir().expect("local dir should be created");
let sources_dir = tempdir.path().join("move-stdlib").join("sources");
std::fs::create_dir_all(sources_dir.as_path()).expect("create dir should success");

let current_dir = env::current_dir().expect("Failed to get current directory");
MOVE_STDLIB_SOURCES_DIR
.extract(sources_dir.as_path())
.expect("extract should success");
info!("restore move-stdlib sources in: {:?}", sources_dir);
let files: Vec<String> = MOVE_STDLIB_SOURCES_DIR
.files()
.iter()
.filter_map(|file| {
let ext = file.path().extension();
if let Some(ext) = ext {
if ext == "move" {
Some(sources_dir.join(file.path()).display().to_string())
Some(current_dir.join(file.path()).display().to_string())
} else {
None
}
} else {
None
}
})
.collect();
files
.iter()
.filter_map(|file| {
if !file.ends_with("spec.move") {
Some(file.clone())
Some(file)
} else {
None
}
Expand All @@ -50,34 +40,25 @@ pub static MOVE_STDLIB_SOURCE_FILES: Lazy<Vec<String>> = Lazy::new(|| {
pub const STARCOIN_STDLIB_SOURCES_DIR: Dir = include_dir!("../starcoin-stdlib/sources");

pub static STARCOIN_STDLIB_SOURCE_FILES: Lazy<Vec<String>> = Lazy::new(|| {
let tempdir = tempfile::tempdir().expect("local dir should be created");
let sources_dir = tempdir.path().join("starcoin-stdlib").join("sources");
std::fs::create_dir_all(sources_dir.as_path()).expect("create dir should success");
let current_dir = env::current_dir().expect("Failed to get current directory");
STARCOIN_STDLIB_SOURCES_DIR
.extract(sources_dir.as_path())
.expect("extract should success");
info!("restore starcoin-stdlib sources in: {:?}", sources_dir);
let files: Vec<String> = STARCOIN_STDLIB_SOURCES_DIR
.files()
.iter()
.filter_map(|file| {
let ext = file.path().extension();
if let Some(ext) = ext {
if ext == "move" {
Some(sources_dir.join(file.path()).display().to_string())
Some(current_dir.join(file.path()).display().to_string())
} else {
None
}
} else {
None
}
})
.collect();
files
.iter()
.filter_map(|file| {
if !file.ends_with("spec.move") {
Some(file.clone())
Some(file)
} else {
None
}
Expand Down

0 comments on commit ef40ab1

Please sign in to comment.