Skip to content

Commit

Permalink
Add Makefile target for publishing and set versions (#380)
Browse files Browse the repository at this point in the history
Co-authored-by: Graydon Hoare <[email protected]>
  • Loading branch information
leighmcculloch and graydon authored Jul 29, 2022
1 parent a22a8e6 commit 7324008
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 70 deletions.
74 changes: 29 additions & 45 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 @@ -28,6 +28,13 @@ members = [
# https://github.com/rust-lang/cargo/issues/10827
exclude = ["macros"]

[patch.crates-io]
soroban-sdk = { path = "sdk" }
soroban-sdk-macros = { path = "macros" }
soroban-env-guest = { git = "https://github.com/stellar/rs-soroban-env", rev = "79e55e4c" }
soroban-env-host = { git = "https://github.com/stellar/rs-soroban-env", rev = "79e55e4c" }
stellar-xdr = { git = "https://github.com/stellar/rs-stellar-xdr", rev = "28a28dc0" }

[profile.dev]
overflow-checks = true
panic = "abort"
Expand Down
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,20 @@ fmt:
clean:
cargo clean
CARGO_TARGET_DIR=target-tiny cargo +nightly clean

# Build all projects as if they are being published to crates.io, and do so for
# all feature and target combinations.
publish-dry-run-sdk:
cargo +stable hack --feature-powerset publish --locked --dry-run --exclude-features docs --package soroban-sdk
cargo +stable hack --feature-powerset publish --locked --dry-run --exclude-features docs,testutils --package soroban-sdk --target wasm32-unknown-unknown

publish-dry-run-sdk-macros:
cd macros && cargo +stable hack --feature-powerset publish --locked --dry-run --package soroban-sdk-macros

# Publish publishes the crate to crates.io. The dry-run is a dependency because
# the dry-run target will verify all feature set combinations.
publish-sdk: publish-dry-run-sdk
cargo +stable publish --locked --package soroban-sdk

publish-sdk-macros: publish-dry-run-sdk-macros
cd macros && cargo +stable publish --locked --package soroban-sdk-macros
18 changes: 4 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
# rs-soroban-sdk
Rust SDK for writing contracts for [Soroban].

**This repository contains code that is in early development, incomplete, not tested, and not recommended for use. The API is unstable, experimental, and is receiving breaking changes frequently.**

[Soroban]: https://soroban.stellar.org
Soroban: https://soroban.stellar.org

## Run a contract on the Stellar-Core Soroban prototype
Docs: https://docs.rs/soroban-sdk

The Stellar-Core Soroban prototype and this SDK are not 100% compatible. Both are still in development and some features may be present in one and not the other. This may cause some example contracts to fail to run on the prototype. However, all examples and tests in this repo should function on the mock host implementation built into the SDK, which is what all tests within the SDK use.
**This repository contains code that is in early development, incomplete, not tested, and not recommended for use. The API is unstable, experimental, and is receiving breaking changes frequently.**

### Prerequisites
1. Install binaryen - https://github.com/WebAssembly/binaryen#building
2. Install wabt - https://github.com/WebAssembly/wabt#cloning
* This is optional. It contains wasm-objdump, which you can use to dump the contents of a contract. Ex. `wasm-objdump -xh ~/stellar/rs-soroban-sdk/target/wasm32-unknown-unknown/release/example_add.wasm`
3. Make sure binaries from the first two steps are available in your PATH.
4. Install Rust - https://www.rust-lang.org/learn/get-started
5. Build - https://github.com/stellar/rs-soroban-sdk
* rustup target add wasm32-unknown-unknown
* make all
[Soroban]: https://soroban.stellar.org
10 changes: 7 additions & 3 deletions macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
[package]
name = "soroban-macros"
version = "0.0.0"
name = "soroban-sdk-macros"
description = "Soroban SDK macros."
homepage = "https://github.com/stellar/rs-soroban-sdk"
repository = "https://github.com/stellar/rs-soroban-sdk"
authors = ["Stellar Development Foundation <[email protected]>"]
readme = "../README.md"
license = "Apache-2.0"
version = "0.0.2"
edition = "2021"

[lib]
proc-macro = true
doctest = false

[dependencies]
stellar-xdr = { git = "https://github.com/stellar/rs-stellar-xdr", rev = "94e01c7b", features = ["next", "std"] }
stellar-xdr = { version = "0.0.1", features = ["next", "std"] }
syn = {version="1.0",features=["full"]}
quote = "1.0"
proc-macro2 = "1.0"
Expand Down
19 changes: 12 additions & 7 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
[package]
name = "soroban-sdk"
version = "0.0.0"
description = "Soroban SDK."
homepage = "https://github.com/stellar/rs-soroban-sdk"
repository = "https://github.com/stellar/rs-soroban-sdk"
authors = ["Stellar Development Foundation <[email protected]>"]
readme = "../README.md"
license = "Apache-2.0"
version = "0.0.2"
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
soroban-macros = { path = "../macros" }
soroban-sdk-macros = { version = "0.0.2" }
ed25519-dalek = { version = "1.0.1", optional = true }

[target.'cfg(target_family="wasm")'.dependencies]
soroban-env-guest = { git = "https://github.com/stellar/rs-soroban-env", rev = "36a5007" }
# soroban-env-guest = { path = "../../rs-soroban-env/soroban-env-guest" }
soroban-env-guest = { version = "0.0.3" }

[target.'cfg(not(target_family="wasm"))'.dependencies]
soroban-env-host = { git = "https://github.com/stellar/rs-soroban-env", rev = "36a5007" }
# soroban-env-host = { path = "../../rs-soroban-env/soroban-env-host" }
soroban-env-host = { version = "0.0.3" }

[dev-dependencies]
stellar-xdr = { git = "https://github.com/stellar/rs-stellar-xdr", rev = "94e01c7b", features = ["next", "std"] }
stellar-xdr = { version = "0.0.1", features = ["next", "std"] }
trybuild = "1.0.63"
hex = "0.4.3"

[features]
testutils = ["soroban-env-host/testutils", "dep:ed25519-dalek"]
docs = []

[package.metadata.docs.rs]
all-features = true
2 changes: 1 addition & 1 deletion sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn handle_panic(_: &core::panic::PanicInfo) -> ! {
#[cfg_attr(target_family = "wasm", link_section = "contractenvmetav0")]
static ENV_META_XDR: [u8; env::meta::XDR.len()] = env::meta::XDR;

pub use soroban_macros::{contractimpl, contracttype, ContractType};
pub use soroban_sdk_macros::{contractimpl, contracttype, ContractType};

mod env;

Expand Down
1 change: 1 addition & 0 deletions tests/add_i32/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.0.0"
authors = ["Stellar Development Foundation <[email protected]>"]
license = "Apache-2.0"
edition = "2021"
publish = false

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down
1 change: 1 addition & 0 deletions tests/add_i64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.0.0"
authors = ["Stellar Development Foundation <[email protected]>"]
license = "Apache-2.0"
edition = "2021"
publish = false

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down
2 changes: 2 additions & 0 deletions tests/create_contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ version = "0.0.0"
authors = ["Stellar Development Foundation <[email protected]>"]
license = "Apache-2.0"
edition = "2021"
publish = false


[lib]
crate-type = ["cdylib", "rlib"]
Expand Down
1 change: 1 addition & 0 deletions tests/invoke_contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.0.0"
authors = ["Stellar Development Foundation <[email protected]>"]
license = "Apache-2.0"
edition = "2021"
publish = false

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down
1 change: 1 addition & 0 deletions tests/udt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.0.0"
authors = ["Stellar Development Foundation <[email protected]>"]
license = "Apache-2.0"
edition = "2021"
publish = false

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down

0 comments on commit 7324008

Please sign in to comment.