Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Commit

Permalink
Transition away from conflicting feature flags in favor of separate c…
Browse files Browse the repository at this point in the history
…rates (#417)

* Safer cursor

* Create two separate svm-sdk crates

* Remove ffi and mock features from svm-sdk-mock

* Make svm-sdk and svm-sdk-mock two separate crates

* Separate svm-sdk-storage

* Separate host and storage in separate crates as well

* Use default crate features for simplicity

* Remove commented out dependencies

* Remove some leftover dbg! calls
  • Loading branch information
neysofu authored Nov 22, 2021
1 parent e28bdb3 commit 9b6b8f8
Show file tree
Hide file tree
Showing 106 changed files with 636 additions and 387 deletions.
68 changes: 65 additions & 3 deletions 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 crates/runtime-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ wasmer = { version = "2.0.0", default-features = false }
wat = "1.0.40"
serde_json = "1.0.69"
maplit = "1.0.2"
svm-sdk = { path="../sdk", features = ["mock", "dynamic-alloc"], default-features=false }
svm-sdk-mock = { path="../sdk-mock", features = ["dynamic-alloc"], default-features=false }
svm-abi-encoder = { path="../abi-encoder", features = ["dynamic-alloc"], default-features=false }
svm-types = { path="../types", default-features=false }

Expand Down
2 changes: 2 additions & 0 deletions crates/runtime-ffi/tests/api_tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
extern crate svm_sdk_mock as svm_sdk;

use svm_codec::Codec;
use svm_layout::FixedLayout;
use svm_runtime::testing;
Expand Down
9 changes: 1 addition & 8 deletions crates/runtime-ffi/tests/wasm/counter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ incremental = false
rpath = false

[dependencies]
svm-sdk = { path = "../../../../sdk", default-features = false }

[features]
default = []
ffi = ["svm-sdk/ffi", "static-alloc"]
mock = ["svm-sdk/mock"]
static-alloc = ["svm-sdk/static-alloc"]
dynamic-alloc = ["svm-sdk/dynamic-alloc"]
svm-sdk = { path = "../../../../sdk", features = ["ffi", "static-alloc"] }

[workspace]
2 changes: 1 addition & 1 deletion crates/runtime-ffi/tests/wasm/counter/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cargo +nightly build --features=ffi,static-alloc --no-default-features --release --target wasm32-unknown-unknown
cargo +nightly build --release --target wasm32-unknown-unknown

if [ -f ./../counter.wasm ]; then
rm ./../counter.wasm
Expand Down
9 changes: 1 addition & 8 deletions crates/runtime-ffi/tests/wasm/failure/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ incremental = false
rpath = false

[dependencies]
svm-sdk = { path = "../../../../sdk", default-features = false }

[features]
default = []
ffi = ["svm-sdk/ffi", "static-alloc"]
mock = ["svm-sdk/mock"]
static-alloc = ["svm-sdk/static-alloc"]
dynamic-alloc = ["svm-sdk/dynamic-alloc"]
svm-sdk = { path = "../../../../sdk", features = ["ffi", "static-alloc"] }

[workspace]
2 changes: 1 addition & 1 deletion crates/runtime-ffi/tests/wasm/failure/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cargo +nightly build --features=ffi,static-alloc --no-default-features --release --target wasm32-unknown-unknown
cargo +nightly build --release --target wasm32-unknown-unknown

if [ -f ./../failure.wasm ]; then
rm ./../failure.wasm
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ svm-program = { path = "../program" }

[dev-dependencies]
maplit = "1.0.2"
svm-sdk = { path = "../sdk", features = ["mock", "dynamic-alloc"], default-features = false }
svm-sdk-mock = { path = "../sdk-mock", features = ["dynamic-alloc"], default-features = false }

[features]
default = []
Expand Down
2 changes: 2 additions & 0 deletions crates/runtime/tests/runtime_tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
extern crate svm_sdk_mock as svm_sdk;

use svm_sdk as sdk;

use svm_sdk::traits::Encoder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"api":[{"doc":"","is_ctor":false,"is_fundable":false,"name":"load_addr","signature":{"params":[],"returns":{"type":"Address"}},"wasm_name":"load_addr"},{"doc":"","is_ctor":true,"is_fundable":false,"name":"initialize","signature":{"params":[{"name":"init","type":"Address"},{"name":"should_store","type":"bool"}],"returns":{"type":"bool"}},"wasm_name":"initialize"},{"doc":"","is_ctor":false,"is_fundable":false,"name":"store_addr","signature":{"params":[{"name":"addr","type":"Address"}],"returns":{}},"wasm_name":"store_addr"}],"schema":[{"byte_count":20,"id":0,"name":"addr","offset":0,"type":"Address"}]}
{"api":[{"doc":"","is_ctor":false,"is_fundable":false,"name":"store_addr","signature":{"params":[{"name":"addr","type":"Address"}],"returns":{}},"wasm_name":"store_addr"},{"doc":"","is_ctor":false,"is_fundable":false,"name":"load_addr","signature":{"params":[],"returns":{"type":"Address"}},"wasm_name":"load_addr"},{"doc":"","is_ctor":true,"is_fundable":false,"name":"initialize","signature":{"params":[{"name":"init","type":"Address"},{"name":"should_store","type":"bool"}],"returns":{"type":"bool"}},"wasm_name":"initialize"}],"schema":[{"byte_count":20,"id":0,"name":"addr","offset":0,"type":"Address"}]}
73 changes: 19 additions & 54 deletions crates/runtime/tests/wasm/calldata/Cargo.lock

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

10 changes: 1 addition & 9 deletions crates/runtime/tests/wasm/calldata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ incremental = false
rpath = false

[dependencies]
svm-sdk = { path = "../../../../sdk", default-features = false }

[features]
default = ["mock", "static-alloc"]
meta = ["svm-sdk/meta"]
ffi = ["svm-sdk/ffi"]
mock = ["svm-sdk/mock"]
static-alloc = ["svm-sdk/static-alloc"]
dynamic-alloc = ["svm-sdk/dynamic-alloc"]
svm-sdk = { path = "../../../../sdk", features = ["static-alloc", "meta"] }

[workspace]
2 changes: 1 addition & 1 deletion crates/runtime/tests/wasm/calldata/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cargo +nightly build --features=ffi,static-alloc,meta --no-default-features --release --target wasm32-unknown-unknown
cargo +nightly build --release --target wasm32-unknown-unknown

if [ -f ./../runtime_calldata.wasm ]; then
rm ./../runtime_calldata.wasm
Expand Down
Binary file modified crates/runtime/tests/wasm/runtime_calldata.wasm
Binary file not shown.
38 changes: 38 additions & 0 deletions crates/sdk-host-ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "svm-sdk-host-ffi"
version = "0.0.0"
authors = ["Spacemesh SVM Team"]
license = "MIT"
edition = "2018"
readme = "README.md"
repository = "https://github.com/spacemeshos/svm"
homepage = "https://github.com/spacemeshos/svm"
description = "Spacemesh Virtual Machine"
publish = false

[dependencies]
svm-sdk-alloc = { path = "../sdk-alloc", default-features = false }
svm-sdk-host = { path = "../sdk-host" }
svm-sdk-types = { path = "../sdk-types", default-features = false }
svm-sdk-std = { path = "../sdk-std", default-features = false }
svm-abi-encoder = { path = "../abi-encoder", default-features = false }
svm-abi-decoder = { path = "../abi-decoder", default-features = false }

[dev-dependencies]
lazy_static = "1.4.0"

[features]
static-alloc = [
"svm-sdk-alloc/static-alloc",
"svm-sdk-types/static-alloc",
"svm-sdk-std/static-alloc",
"svm-abi-encoder/static-alloc",
"svm-abi-decoder/static-alloc",
]
dynamic-alloc = [
"svm-sdk-alloc/dynamic-alloc",
"svm-sdk-types/dynamic-alloc",
"svm-sdk-std/dynamic-alloc",
"svm-abi-encoder/dynamic-alloc",
"svm-abi-decoder/dynamic-alloc",
]
Loading

0 comments on commit 9b6b8f8

Please sign in to comment.