Skip to content

Commit

Permalink
Feature to configure dalek backend (#27)
Browse files Browse the repository at this point in the history
* Add feature to configure the dalek backend.

* Prepare for release

* Fix no_std builds and features.
  • Loading branch information
pietgeursen authored Feb 8, 2021
1 parent 1079bdf commit dadd148
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Build
run: cargo build
- name: Build no_std
run: cd bamboo-rs-core && cargo build --no-default-features
run: cd bamboo-rs-core && cargo build --no-default-features --features u64_backend
- name: Run tests
run: cargo test
- name: Run benches
Expand Down
6 changes: 4 additions & 2 deletions bamboo-c/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ name = "bamboo_c"
crate-type = ["cdylib", "staticlib"]

[features]
default = ["std"]
default = ["std", "u64_backend"]
std = ["ed25519-dalek/std"]
u32_backend = ["bamboo-rs-core/u32_backend", "ed25519-dalek/u32_backend"]
u64_backend = ["bamboo-rs-core/u64_backend", "ed25519-dalek/u64_backend"]

[dependencies]
bamboo-rs-core = {path = "../bamboo-rs-core", default_features = false}
ed25519-dalek = { version = "1.0.1", default-features = false, features = ["u64_backend"] }
ed25519-dalek = { version = "1.0.1", default-features = false}
4 changes: 4 additions & 0 deletions bamboo-rs-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.1.0-pre-31] - 2021-2-8
### Added
- Features `u32_backend` and `u64_backend` that configures `ed25519-dalek`.

## [0.1.0-pre-30] - 2021-1-17
### Changed
- change api of publish to take &Keypair, not Option<&Keypair>
Expand Down
8 changes: 5 additions & 3 deletions bamboo-rs-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
[package]
name = "bamboo-rs-core"
version = "0.1.0-pre-29"
version = "0.1.0-pre-31"
authors = ["Piet Geursen <[email protected]>"]
edition = "2018"
license = "AGPL-3.0"
repository = "https://github.com/pietgeursen/bamboo-rs"
description = "Publish and verify signed hash chains of bamboo messages."

[features]
default = ["std"]
default = ["std", "u64_backend"]
std = ["varu64/std", "hex/std", "rayon", "snafu/std", "ed25519-dalek/serde", "ed25519-dalek/std", "ed25519-dalek/batch", "yamf-hash/std"]
u64_backend = ["ed25519-dalek/u64_backend"]
u32_backend = ["ed25519-dalek/u32_backend"]

[dependencies]
arrayvec = { version = "0.5.1", default-features = false}
blake2b_simd = { version = "0.5", default-features = false }
ed25519-dalek = { version = "1.0.1", default-features = false, features = ["u64_backend"] }
ed25519-dalek = { version = "1.0.1", default-features = false }
hex = { version = "0.4", default-features = false }
lipmaa-link = "0.1"
rayon = { version = "1.5", optional = true }
Expand Down
11 changes: 8 additions & 3 deletions bamboo-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ wasm-opt = false
crate-type = ["cdylib", "rlib"]

[features]
default = ["wee_alloc", "console_error_panic_hook"]

# I'd rather set the default to be u32_backend but if we do that then building from the workspace level breaks.
# Use the u32_backend feature when actually building for wasm.
default = ["u64_backend"]
u32_backend = ["base", "bamboo-rs-core/u32_backend", "ed25519-dalek/u32_backend"]
u64_backend = ["base", "bamboo-rs-core/u64_backend", "ed25519-dalek/u64_backend"]
base = ["wee_alloc", "console_error_panic_hook"]

[dependencies]
arrayvec = { version = "0.5", default-features = false}
wasm-bindgen = { version = "0.2.69"}
bamboo-rs-core = {path = "../bamboo-rs-core"}
ed25519-dalek = { version = "1.0.1", default-features = false, features = ["u64_backend", "alloc", "serde"] }
bamboo-rs-core = {path = "../bamboo-rs-core", default-features = false, features = ["std"]}
ed25519-dalek = { version = "1.0.1", default-features = false, features = ["alloc", "serde"] }
rand = { version = "0.7.3", features = ["wasm-bindgen"] }

# The `console_error_panic_hook` crate provides better debugging of panics by
Expand Down
3 changes: 2 additions & 1 deletion bamboo-wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ See the Typescript types in `index.d.ts`
### 🛠️ Build with `wasm-pack build`

```
wasm-pack build -t nodejs --scope bamboo-logs --release --out-name index
wasm-pack build -t nodejs --scope bamboo-logs --release --out-name index -- --no-default-features --features u32_backend
wasm-opt index_bg.wasm --enable-mutable-globals -O4 -o ./index_bg.wasm
```

### 🔬 Test in Headless Browsers with `wasm-pack test`
Expand Down
4 changes: 2 additions & 2 deletions ci/build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ if [ -z "$RELEASE_BUILD" ]; then
$CROSS build --target $TARGET_TRIPLE
$CROSS build --target $TARGET_TRIPLE --all-features
else
$CROSS build -p bamboo-c --target $TARGET_TRIPLE --no-default-features --manifest-path=bamboo-c/Cargo.toml
$CROSS build -p bamboo-c --target $TARGET_TRIPLE --no-default-features --features u32_backend --manifest-path=bamboo-c/Cargo.toml
fi
else
if [ -z $NO_STD ]
then
$CROSS build --target $TARGET_TRIPLE --all-features --release
else
$CROSS build -p bamboo-c --target $TARGET_TRIPLE --no-default-features --manifest-path=bamboo-c/Cargo.toml --release
$CROSS build -p bamboo-c --target $TARGET_TRIPLE --no-default-features --features u32_backend --manifest-path=bamboo-c/Cargo.toml --release
fi
fi

0 comments on commit dadd148

Please sign in to comment.