Skip to content

Commit

Permalink
[compiler-v2 native]
Browse files Browse the repository at this point in the history
add package build
  • Loading branch information
welbon committed Sep 10, 2024
1 parent 745ad2a commit 92e124f
Show file tree
Hide file tree
Showing 35 changed files with 11,909 additions and 631 deletions.
36 changes: 36 additions & 0 deletions Cargo.lock

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

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ members = [
"vm/vm-runtime-types",
"vm/vm-runtime",
"vm/frameworks",
"vm/framework/cached-packages",
"vm/starcoin-native-interface",
"vm/stdlib",
"vm/compiler",
Expand All @@ -99,6 +100,7 @@ members = [
"vm/e2e-tests",
"vm/proptest-helpers",
"vm/starcoin-native-interface",
"vm/starcoin-sdk-builder",
"abi/types",
"abi/decoder",
"abi/resolver",
Expand Down Expand Up @@ -192,7 +194,9 @@ default-members = [
"vm/vm-runtime-types",
"vm/vm-runtime",
"vm/framework",
"vm/framework/cached-packages",
"vm/frameworks",
"vm/starcoin-sdk-builder",
"vm/starcoin-native-interface",
"vm/stdlib",
"vm/compiler",
Expand Down Expand Up @@ -526,6 +530,7 @@ starcoin-rpc-api = { path = "rpc/api" }
starcoin-rpc-client = { path = "rpc/client" }
starcoin-rpc-middleware = { path = "rpc/middleware" }
starcoin-rpc-server = { path = "rpc/server" }
starcoin-sdk-builder = {path = "vm/starcoin-sdk-builder"}
starcoin-service-registry = { path = "commons/service-registry" }
starcoin-state-api = { path = "state/api" }
starcoin-state-service = { path = "state/service" }
Expand Down Expand Up @@ -562,6 +567,8 @@ starcoin-proptest-helpers = { path = "vm/proptest-helpers" }
starcoin-dag = { path = "flexidag" }
starcoin-move-stdlib = { path = "vm/framework/move-stdlib"}
starcoin-table-natives = { path = "vm/framework/table-natives" }
starcoin-cached-packages = { path = "vm/framework/cached-packages" }


syn = { version = "1.0.107", features = [
"full",
Expand Down
34 changes: 34 additions & 0 deletions vm/framework/cached-packages/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[package]
name = "starcoin-cached-packages"
description = "Builds framework packages for caching in builds and tests"
version = "0.1.0"

# Workspace inherited keys
authors = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
publish = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }

[dependencies]
starcoin-framework = { workspace = true }
starcoin-package-builder = { workspace = true }
starcoin-vm-types = { workspace = true }
bcs = { workspace = true }
move-core-types = { workspace = true }
once_cell = { workspace = true }
proptest = { workspace = true, optional = true }
proptest-derive = { workspace = true, optional = true }

[build-dependencies]
anyhow = { workspace = true }
starcoin-framework = { workspace = true }

[features]
default = []
fuzzing = ["proptest", "proptest-derive"]

[package.metadata.cargo-machete]
ignored = ["proptest"]
86 changes: 86 additions & 0 deletions vm/framework/cached-packages/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

use anyhow::{Context, Result};
use aptos_framework::ReleaseTarget;
use std::{env::current_dir, path::PathBuf};

fn main() -> Result<()> {
// Set the below variable to skip the building step. This might be useful if the build
// is broken so it can be debugged with the old outdated artifacts.
if std::env::var("SKIP_FRAMEWORK_BUILD").is_err() {
let current_dir = current_dir().expect("Should be able to get current dir");
// Get the previous directory
let mut prev_dir = current_dir;
prev_dir.pop();
println!(
"cargo:rerun-if-changed={}",
prev_dir
.join("aptos-token-objects")
.join("Move.toml")
.display()
);
println!(
"cargo:rerun-if-changed={}",
prev_dir
.join("aptos-token-objects")
.join("sources")
.display()
);
println!(
"cargo:rerun-if-changed={}",
prev_dir.join("aptos-token").join("sources").display()
);
println!(
"cargo:rerun-if-changed={}",
prev_dir.join("aptos-token").join("Move.toml").display()
);
println!(
"cargo:rerun-if-changed={}",
prev_dir
.join("aptos-token-objects")
.join("sources")
.display()
);
println!(
"cargo:rerun-if-changed={}",
prev_dir
.join("aptos-token-objects")
.join("Move.toml")
.display()
);
println!(
"cargo:rerun-if-changed={}",
prev_dir.join("aptos-framework").join("sources").display()
);
println!(
"cargo:rerun-if-changed={}",
prev_dir.join("aptos-framework").join("Move.toml").display()
);
println!(
"cargo:rerun-if-changed={}",
prev_dir.join("aptos-stdlib").join("sources").display()
);
println!(
"cargo:rerun-if-changed={}",
prev_dir.join("aptos-stdlib").join("Move.toml").display()
);
println!(
"cargo:rerun-if-changed={}",
prev_dir.join("move-stdlib").join("sources").display()
);
println!(
"cargo:rerun-if-changed={}",
prev_dir.join("move-stdlib").join("Move.toml").display()
);

let path =
PathBuf::from(std::env::var("OUT_DIR").expect("OUT_DIR defined")).join("head.mrb");

ReleaseTarget::Head
.create_release(true, Some(path))
.context("Failed to create release")?;
}

Ok(())
}
24 changes: 24 additions & 0 deletions vm/framework/cached-packages/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

use starcoin_framework::ReleaseBundle;
use once_cell::sync::Lazy;

pub mod starcoin_framework_sdk_builder;
pub mod starcoin_stdlib;
pub mod starcoin_token_objects_sdk_builder;
pub mod starcoin_token_sdk_builder;

#[cfg(unix)]
const HEAD_RELEASE_BUNDLE_BYTES: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/head.mrb"));
#[cfg(windows)]
const HEAD_RELEASE_BUNDLE_BYTES: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "\\head.mrb"));

static HEAD_RELEASE_BUNDLE: Lazy<ReleaseBundle> = Lazy::new(|| {
bcs::from_bytes::<ReleaseBundle>(HEAD_RELEASE_BUNDLE_BYTES).expect("bcs succeeds")
});

/// Returns the release bundle for the current code.
pub fn head_release_bundle() -> &'static ReleaseBundle {
&HEAD_RELEASE_BUNDLE
}
Loading

0 comments on commit 92e124f

Please sign in to comment.