Skip to content

Commit

Permalink
move: build writes toolchain version into to Move.lock
Browse files Browse the repository at this point in the history
  • Loading branch information
rvantonder committed Dec 3, 2023
1 parent 1265c0a commit bdc5127
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ members = [
]

[workspace.package]
# This version string will be inherited by sui-core, sui-faucet, sui-node, sui-tools, sui-sdk, and sui crates.
# This version string will be inherited by sui-core, sui-faucet, sui-node, sui-tools, sui-sdk, sui-move-build, and sui crates.
version = "1.16.0"

[profile.release]
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-move-build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sui-move-build"
version = "0.0.0"
version.workspace = true
edition = "2021"
authors = ["Mysten Labs <eng@mystenlabs.com>"]
description = "Logic for building Sui Move Packages"
Expand Down
17 changes: 14 additions & 3 deletions crates/sui-move-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,24 @@ impl BuildConfig {
let print_diags_to_stderr = self.print_diags_to_stderr;
let run_bytecode_verifier = self.run_bytecode_verifier;
let resolution_graph = self.resolution_graph(&path)?;
build_from_resolution_graph(
path,
let result = build_from_resolution_graph(
path.clone(),
resolution_graph,
run_bytecode_verifier,
print_diags_to_stderr,
lint,
)
);
if let Ok(ref compiled) = result {
compiled
.package
.compiled_package_info
.build_flags
.update_lock_file_toolchain_version(&path, env!("CARGO_PKG_VERSION").into())
.map_err(|e| SuiError::ModuleBuildFailure {
error: format!("Failed to update Move.lock toolchain version: {e}"),
})?;
}
result
}

pub fn resolution_graph(mut self, path: &Path) -> SuiResult<ResolvedGraph> {
Expand Down
12 changes: 7 additions & 5 deletions external-crates/move/crates/move-package/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,16 @@ impl BuildConfig {
.set_silence_warnings(self.silence_warnings)
}

pub fn update_lock_file_toolchain_version(&self, compiler_version: String) -> Result<()> {
pub fn update_lock_file_toolchain_version(
&self,
path: &PathBuf,
compiler_version: String,
) -> Result<()> {
let Some(lock_file) = self.lock_file.as_ref() else {
return Ok(());
};
let install_dir = self
.install_dir
.clone()
.unwrap_or_else(|| PathBuf::from("."));
let install_dir = self.install_dir.as_ref().unwrap_or(path).to_owned();

let mut lock = LockFile::from(install_dir, lock_file)?;
lock.seek(SeekFrom::Start(0))?;
update_compiler_toolchain(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ fn update_lock_file_toolchain_version() {
build_config.default_flavor = Some(Flavor::Sui);
build_config.default_edition = Some(Edition::E2024_ALPHA);
build_config.lock_file = Some(lock_path.clone());
let _ = build_config.update_lock_file_toolchain_version("0.0.1".into());
let _ =
build_config.update_lock_file_toolchain_version(pkg.path().to_path_buf(), "0.0.1".into());

let mut lock_file = File::open(lock_path).unwrap();
let toolchain_version =
Expand Down

0 comments on commit bdc5127

Please sign in to comment.