Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions crates/sui-move-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,24 @@ impl BuildConfig {
Ok((compiled_pkg, fn_info.unwrap()))
}

pub async fn build_async(self, path: &Path) -> anyhow::Result<CompiledPackage> {
let env = find_env::<SuiFlavor>(path, &self.config)?;
let root_pkg = RootPackage::<SuiFlavor>::load(path.to_path_buf(), env).await?;

self.internal_build(&root_pkg)
}

/// Given a `path` and a `build_config`, build the package in that path, including its dependencies.
/// If we are building the Sui framework, we skip the check that the addresses should be 0
pub fn build(self, path: &Path) -> anyhow::Result<CompiledPackage> {
let env = find_env::<SuiFlavor>(path, &self.config)?;
// we need to block here to compile the package, which requires to fetch dependencies
let root_pkg = RootPackage::<SuiFlavor>::load_sync(path.to_path_buf(), env)?;

self.internal_build(&root_pkg)
}

fn internal_build(self, root_pkg: &RootPackage<SuiFlavor>) -> anyhow::Result<CompiledPackage> {
let result = if self.print_diags_to_stderr {
self.compile_package(&root_pkg, &mut std::io::stderr())
} else {
Expand Down
35 changes: 18 additions & 17 deletions crates/sui-proc-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,6 @@ pub fn init_static_initializers(_args: TokenStream, item: TokenStream) -> TokenS
let mut cache = ::sui_simulator::lru::LruCache::new(1.try_into().unwrap());
cache.put(1, 1);

{
// Initialize the static initializers here:
// https://github.com/move-language/move/blob/652badf6fd67e1d4cc2aa6dc69d63ad14083b673/language/tools/move-package/src/package_lock.rs#L12
use std::path::PathBuf;
use sui_simulator::sui_move_build::BuildConfig;
use sui_simulator::tempfile::TempDir;

let mut path = PathBuf::from(env!("SIMTEST_STATIC_INIT_MOVE"));
let mut build_config = BuildConfig::new_for_testing();

build_config.config.install_dir = Some(TempDir::new().unwrap().keep());
let _all_module_bytes = build_config
.build(&path)
.unwrap()
.get_package_bytes(/* with_unpublished_deps */ false);
}

use std::sync::Arc;

use ::sui_simulator::anemo_tower::callback::CallbackLayer;
Expand All @@ -84,6 +67,24 @@ pub fn init_static_initializers(_args: TokenStream, item: TokenStream) -> TokenS
rt.block_on(async move {
use ::sui_simulator::anemo::{Network, Request};

{
// Initialize the static initializers here:
// https://github.com/move-language/move/blob/652badf6fd67e1d4cc2aa6dc69d63ad14083b673/language/tools/move-package/src/package_lock.rs#L12
use std::path::PathBuf;
use sui_simulator::sui_move_build::BuildConfig;
use sui_simulator::tempfile::TempDir;

let mut path = PathBuf::from(env!("SIMTEST_STATIC_INIT_MOVE"));
let mut build_config = BuildConfig::new_for_testing();

build_config.config.install_dir = Some(TempDir::new().unwrap().keep());
let _all_module_bytes = build_config
.build_async(&path)
.await
.unwrap()
.get_package_bytes(/* with_unpublished_deps */ false);
}

let make_network = |port: u16| {
let registry = prometheus::Registry::new();
let inbound_network_metrics =
Expand Down
Loading