Skip to content

Commit

Permalink
place this line with a title. Use 1 line only, 67 chars or less>
Browse files Browse the repository at this point in the history
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
  • Loading branch information
Tim Zakian committed Jan 8, 2022
1 parent 98ed299 commit fb2880f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions language/tools/move-package/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ tempfile = "3.2.0"
sha2 = "0.9.3"
regex = "1.1.9"
ptree = "0.4.0"
once_cell = "1.7.2"

move-binary-format = { path = "../../move-binary-format" }
move-compiler = { path = "../../move-compiler" }
Expand Down
15 changes: 15 additions & 0 deletions language/tools/move-package/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ use std::{
collections::BTreeMap,
io::Write,
path::{Path, PathBuf},
sync::Mutex,
};
use structopt::*;
use once_cell::sync::Lazy;

use crate::{
compilation::{
Expand All @@ -26,6 +28,19 @@ use crate::{
source_package::{layout, manifest_parser},
};

pub(crate) static PACKAGE_MUTEX: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(()));

#[macro_export]
macro_rules! critical_section {
($($code:stmt);*$(;)?) => {
{
let x = $crate::PACKAGE_MUTEX.lock().unwrap();
$($code);*
drop(x)
}
}
}

#[derive(Debug, StructOpt, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd)]
#[structopt(
name = "Move Package",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use crate::{
critical_section,
resolution::digest::compute_digest,
source_package::{
layout::SourcePackageLayout,
Expand Down Expand Up @@ -352,7 +353,9 @@ impl ResolvingGraph {
dep: Dependency,
root_path: PathBuf,
) -> Result<(Renaming, ResolvingTable)> {
Self::download_and_update_if_repo(dep_name_in_pkg, &dep)?;
critical_section! {
Self::download_and_update_if_repo(dep_name_in_pkg, &dep)?;
}
let (dep_package, dep_package_dir) =
Self::parse_package_manifest(&dep, &dep_name_in_pkg, root_path)
.with_context(|| format!("While processing dependency '{}'", dep_name_in_pkg))?;
Expand Down

0 comments on commit fb2880f

Please sign in to comment.