diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 4a360bb..c4557b1 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -80,8 +80,13 @@ jobs: with: command: nextest args: run --all-features --no-fail-fast --no-capture - - name: Run tests (no-std) + - name: Run tests (no_std) uses: actions-rs/cargo@v1 with: command: nextest args: run --no-default-features --no-fail-fast --no-capture + - name: Check no_std compatibility + uses: actions-rs/cargo@v1 + with: + command: rustc + args: --manifest-path pbjson-no-std/Cargo.toml -- -C link-arg=-nostartfiles diff --git a/.gitignore b/.gitignore index 088ba6b..ac3f8b4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Generated by Cargo # will have compiled files and executables /target/ +/pbjson-no-std/target/ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..58b0b15 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,25 @@ +# Changelog + +## v0.6.0 + +## Breaking changes + +- The crates have been prefixed with `informalsystems-`, but the library names have been kept the same, for drop-in compatibility with former versions. + + | Former crate | New crate | Library name | + |-----------------|---------------------------------|-----------------| + | `pbjson` | `informalsystems-pbjson` | `pbjson` | + | `pbjson-types` | `informalsystems-pbjson-types` | `pbjson_types` | + | `pbjson-build` | `informalsystems-pbjson-build` | `pbjson_build` | + | `pbjson-test` | `informalsystems-pbjson-test` | `pbjson_test` | + +## Features + +- Add `no_std` support to the generated code ([#1](https://github.com/informalsystems/pbjson/pull/1)) + The `informal-pbjson-types` crate now has an `std` feature which is enabled by default. + To enable `no_std` compatibility, disable the default features on that crate. + +## Previous versions + +There was no changelog for versions prior to 0.6.0. + diff --git a/Cargo.toml b/Cargo.toml index b13ec79..7bfb4c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,3 +5,7 @@ members = [ "pbjson-test", "pbjson-types", ] + +exclude = [ + "pbjson-no-std" +] diff --git a/README.md b/README.md index 2f8750a..76afdae 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Pbjson +> This is a fork of [`influxdata/pbjson`](https://github.com/influxdata/pbjson) maintained by Informal Systems. + Pbjson is a set of crates to automatically generate [serde](https://serde.rs/) [Serialize](https://docs.rs/serde/1.0.130/serde/trait.Serialize.html) and [Deserialize](https://docs.rs/serde/1.0.130/serde/trait.Deserialize.html) implementations for auto-generated prost types. See [pbjson-build](https://docs.rs/pbjson-build) for usage instructions diff --git a/pbjson-build/Cargo.toml b/pbjson-build/Cargo.toml index 7e816e5..231daa8 100644 --- a/pbjson-build/Cargo.toml +++ b/pbjson-build/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "informalsystems-pbjson-build" -version = "0.5.1" +version = "0.6.0" authors = ["Raphael Taylor-Davies "] edition = "2021" description = "Generates Serialize and Deserialize implementations for prost message types" diff --git a/pbjson-no-std/Cargo.toml b/pbjson-no-std/Cargo.toml new file mode 100644 index 0000000..d179dc2 --- /dev/null +++ b/pbjson-no-std/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "pbjson-no-std" +version = "0.1.0" +edition = "2021" +publish = false +description = "A library for testing no_std compatibility of pbjson" + +[profile.dev] +panic = "abort" + +[profile.release] +panic = "abort" + +[dependencies] +informalsystems-pbjson = { path = "../pbjson", default-features = false } +informalsystems-pbjson-types = { path = "../pbjson-types", default-features = false } + diff --git a/pbjson-no-std/src/lib.rs b/pbjson-no-std/src/lib.rs new file mode 100644 index 0000000..e1bda95 --- /dev/null +++ b/pbjson-no-std/src/lib.rs @@ -0,0 +1,19 @@ +#![no_std] + +use core::panic::PanicInfo; + +/// This function is called on panic. +#[panic_handler] +fn panic(_info: &PanicInfo) -> ! { + loop {} +} + +#[no_mangle] +pub extern "C" fn _start() -> ! { + loop {} +} + +#[allow(unused_imports)] +use pbjson; +#[allow(unused_imports)] +use pbjson_types; diff --git a/pbjson-test/Cargo.toml b/pbjson-test/Cargo.toml index 3d7442d..f8cd58b 100644 --- a/pbjson-test/Cargo.toml +++ b/pbjson-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "informalsystems-pbjson-test" -version = "0.5.1" +version = "0.6.0" authors = ["Raphael Taylor-Davies "] edition = "2021" description = "Test resources for pbjson converion" @@ -11,7 +11,7 @@ publish = false name = "pbjson_test" [dependencies] -prost = { version = "0.11", default-features = false} +prost = { version = "0.11", default-features = false, features = ["prost-derive"] } informalsystems-pbjson = { path = "../pbjson" , default-features = false} informalsystems-pbjson-types = { path = "../pbjson-types" , default-features = false} serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } diff --git a/pbjson-types/Cargo.toml b/pbjson-types/Cargo.toml index c77e9b1..1089d80 100644 --- a/pbjson-types/Cargo.toml +++ b/pbjson-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "informalsystems-pbjson-types" -version = "0.5.1" +version = "0.6.0" authors = ["Raphael Taylor-Davies "] description = "Protobuf well known types with serde serialization support" edition = "2021" @@ -15,18 +15,19 @@ name = "pbjson_types" [features] default = ["std"] -std = ["chrono/std", "informalsystems-pbjson/std", "prost/std", "serde/std"] +std = ["bytes/std", "chrono/std", "informalsystems-pbjson/std", "prost/std", "serde/std", "serde_json/std"] [dependencies] # In alphabetical order -bytes = "1.0" +informalsystems-pbjson = { path = "../pbjson", version = "0.6.0" , default-features = false } + +bytes = { version = "1.0", default-features = false } chrono = { version = "0.4", default-features = false, features = ["alloc"] } -informalsystems-pbjson = { path = "../pbjson", version = "0.5" , default-features = false } -prost = { version = "0.11", default-features = false } +prost = { version = "0.11", default-features = false, features = ["prost-derive"] } serde = { version = "1.0", features = ["derive"], default-features = false } [dev-dependencies] -serde_json = "1.0" +serde_json = { version = "1.0", default-features = false, features = ["alloc"] } -[build-dependencies] # In alphabetical order +[build-dependencies] +informalsystems-pbjson-build = { path = "../pbjson-build", version = "0.6.0" } prost-build = "0.11" -informalsystems-pbjson-build = { path = "../pbjson-build", version = "0.5" } diff --git a/pbjson/Cargo.toml b/pbjson/Cargo.toml index 768663a..3a64845 100644 --- a/pbjson/Cargo.toml +++ b/pbjson/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "informalsystems-pbjson" -version = "0.5.1" +version = "0.6.0" authors = ["Raphael Taylor-Davies "] edition = "2021" description = "Utilities for pbjson conversion"