Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
This commit is contained in:
slinkydeveloper 2021-07-07 11:13:39 +02:00 committed by Francesco Guardiani
parent 94c3f12c57
commit 6d07bcde93
5 changed files with 79 additions and 25 deletions

View File

@ -53,36 +53,20 @@ jobs:
# If glibc, compile and test all
- uses: actions-rs/cargo@v1
name: "Build"
name: "Build glibc"
if: matrix.target == 'x86_64-unknown-linux-gnu'
with:
command: build
toolchain: ${{ matrix.toolchain }}
args: --target ${{ matrix.target }} --all-features
- uses: actions-rs/cargo@v1
name: "Test"
name: "Test glibc"
if: matrix.target == 'x86_64-unknown-linux-gnu'
with:
command: test
toolchain: ${{ matrix.toolchain }}
args: --target ${{ matrix.target }} --all-features
# If glibc, compile and test only the core module with no_std
- uses: actions-rs/cargo@v1
name: "Build"
if: matrix.target == 'x86_64-unknown-linux-gnu'
with:
command: build
toolchain: ${{ matrix.toolchain }}
args: --target ${{ matrix.target }} --package cloudevents-sdk --workspace --no-default-features
- uses: actions-rs/cargo@v1
name: "Test"
if: matrix.target == 'x86_64-unknown-linux-gnu'
with:
command: test
toolchain: ${{ matrix.toolchain }}
args: --target ${{ matrix.target }} --package cloudevents-sdk --workspace --no-default-features
# If musl, compile and test all
- uses: actions-rs/cargo@v1
name: "Build"
@ -145,3 +129,31 @@ jobs:
command: build
toolchain: ${{ matrix.toolchain }}
args: --target ${{ matrix.target }} --manifest-path ./example-projects/warp-example/Cargo.toml
check_no_std:
name: Check no_std
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
# Caching stuff
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-no-std-deps-${{ hashFiles('**/Cargo.toml') }}
- uses: actions/cache@v2
with:
path: |
target/
key: ${{ runner.os }}-cargo-no-std-build-${{ hashFiles('**/Cargo.toml') }}
- name: Download cargo-nono
run: curl -LSfs https://japaric.github.io/trust/install.sh | sh -s -- --git hobofan/cargo-nono
- name: Run check
run: ./cargo-nono check

View File

@ -17,6 +17,11 @@ categories = ["web-programming", "encoding", "data-structures", "no_std"]
name = "cloudevents"
[features]
# Without default features, the package acts as no_std
default = ["std"]
std = ["snafu/std", "url"]
actix = ["actix-web", "async-trait", "lazy_static", "bytes", "futures"]
reqwest = ["reqwest-lib", "async-trait", "lazy_static", "bytes"]
rdkafka = ["rdkafka-lib", "lazy_static", "bytes", "futures"]
@ -32,12 +37,6 @@ snafu = { version = "^0.6", default-features = false}
bitflags = "^1.2"
url = { version = "^2.1", features = ["serde"], optional = true }
[features]
# Without default features, the package acts as no_std
default = ["std"]
std = ["snafu/std", "url"]
# runtime optional deps
actix-web = { version = "^3", default-features = false, optional = true }
reqwest-lib = { version = "^0.11", default-features = false, features = ["rustls-tls"], optional = true, package = "reqwest" }

View File

@ -0,0 +1,15 @@
[package]
name = "no-std-example"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
cloudevents-sdk = { path = "../..", default-features = false }
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"

View File

@ -0,0 +1,25 @@
#![no_std]
#![no_main]
use core::panic::PanicInfo;
use cloudevents;
use cloudevents::EventBuilder;
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}
#[no_mangle]
pub extern "C" fn _start() -> ! {
loop {
#[allow(dead_code)]
let event = cloudevents::EventBuilderV10::new()
.id("my_id")
.source("my_source")
.subject("some_subject")
.build()
.unwrap();
}
}

View File

@ -53,6 +53,7 @@
//! [Responders]: https://actix.rs/docs/handlers/
#![deny(broken_intra_doc_links)]
#![cfg_attr(not(any(feature = "std", test)), no_std)]
#[cfg(feature = "alloc")]
@ -62,7 +63,9 @@ extern crate std as alloc;
#[cfg(any(feature = "std", test))]
extern crate std as core;
#[cfg(feature = "std")]
pub mod binding;
pub mod event;
pub mod message;