Skip to content

Commit 6d07bcd

Browse files
WIP
Signed-off-by: Francesco Guardiani <[email protected]>
1 parent 94c3f12 commit 6d07bcd

File tree

5 files changed

+79
-25
lines changed

5 files changed

+79
-25
lines changed

.github/workflows/rust_tests.yml

+30-18
Original file line numberDiff line numberDiff line change
@@ -53,36 +53,20 @@ jobs:
5353

5454
# If glibc, compile and test all
5555
- uses: actions-rs/cargo@v1
56-
name: "Build"
56+
name: "Build glibc"
5757
if: matrix.target == 'x86_64-unknown-linux-gnu'
5858
with:
5959
command: build
6060
toolchain: ${{ matrix.toolchain }}
6161
args: --target ${{ matrix.target }} --all-features
6262
- uses: actions-rs/cargo@v1
63-
name: "Test"
63+
name: "Test glibc"
6464
if: matrix.target == 'x86_64-unknown-linux-gnu'
6565
with:
6666
command: test
6767
toolchain: ${{ matrix.toolchain }}
6868
args: --target ${{ matrix.target }} --all-features
6969

70-
# If glibc, compile and test only the core module with no_std
71-
- uses: actions-rs/cargo@v1
72-
name: "Build"
73-
if: matrix.target == 'x86_64-unknown-linux-gnu'
74-
with:
75-
command: build
76-
toolchain: ${{ matrix.toolchain }}
77-
args: --target ${{ matrix.target }} --package cloudevents-sdk --workspace --no-default-features
78-
- uses: actions-rs/cargo@v1
79-
name: "Test"
80-
if: matrix.target == 'x86_64-unknown-linux-gnu'
81-
with:
82-
command: test
83-
toolchain: ${{ matrix.toolchain }}
84-
args: --target ${{ matrix.target }} --package cloudevents-sdk --workspace --no-default-features
85-
8670
# If musl, compile and test all
8771
- uses: actions-rs/cargo@v1
8872
name: "Build"
@@ -145,3 +129,31 @@ jobs:
145129
command: build
146130
toolchain: ${{ matrix.toolchain }}
147131
args: --target ${{ matrix.target }} --manifest-path ./example-projects/warp-example/Cargo.toml
132+
133+
check_no_std:
134+
name: Check no_std
135+
runs-on: ubuntu-latest
136+
steps:
137+
- uses: actions/checkout@v1
138+
- uses: actions-rs/toolchain@v1
139+
with:
140+
toolchain: stable
141+
override: true
142+
# Caching stuff
143+
- uses: actions/cache@v2
144+
with:
145+
path: |
146+
~/.cargo/bin/
147+
~/.cargo/registry/index/
148+
~/.cargo/registry/cache/
149+
~/.cargo/git/db/
150+
key: ${{ runner.os }}-cargo-no-std-deps-${{ hashFiles('**/Cargo.toml') }}
151+
- uses: actions/cache@v2
152+
with:
153+
path: |
154+
target/
155+
key: ${{ runner.os }}-cargo-no-std-build-${{ hashFiles('**/Cargo.toml') }}
156+
- name: Download cargo-nono
157+
run: curl -LSfs https://japaric.github.io/trust/install.sh | sh -s -- --git hobofan/cargo-nono
158+
- name: Run check
159+
run: ./cargo-nono check

Cargo.toml

+6-7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ categories = ["web-programming", "encoding", "data-structures", "no_std"]
1717
name = "cloudevents"
1818

1919
[features]
20+
# Without default features, the package acts as no_std
21+
default = ["std"]
22+
23+
std = ["snafu/std", "url"]
24+
2025
actix = ["actix-web", "async-trait", "lazy_static", "bytes", "futures"]
2126
reqwest = ["reqwest-lib", "async-trait", "lazy_static", "bytes"]
2227
rdkafka = ["rdkafka-lib", "lazy_static", "bytes", "futures"]
@@ -28,16 +33,10 @@ serde_json = "^1.0"
2833
chrono = { version = "^0.4", features = ["serde"] }
2934
delegate-attr = "^0.2"
3035
base64 = "^0.12"
31-
snafu = { version = "^0.6", default-features = false}
36+
snafu = { version = "^0.6", default-features = false }
3237
bitflags = "^1.2"
3338
url = { version = "^2.1", features = ["serde"], optional = true }
3439

35-
[features]
36-
# Without default features, the package acts as no_std
37-
default = ["std"]
38-
39-
std = ["snafu/std", "url"]
40-
4140
# runtime optional deps
4241
actix-web = { version = "^3", default-features = false, optional = true }
4342
reqwest-lib = { version = "^0.11", default-features = false, features = ["rustls-tls"], optional = true, package = "reqwest" }
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "no-std-example"
3+
version = "0.1.0"
4+
edition = "2018"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
cloudevents-sdk = { path = "../..", default-features = false }
10+
11+
[profile.dev]
12+
panic = "abort"
13+
14+
[profile.release]
15+
panic = "abort"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#![no_std]
2+
#![no_main]
3+
4+
use core::panic::PanicInfo;
5+
6+
use cloudevents;
7+
use cloudevents::EventBuilder;
8+
9+
#[panic_handler]
10+
fn panic(_info: &PanicInfo) -> ! {
11+
loop {}
12+
}
13+
14+
#[no_mangle]
15+
pub extern "C" fn _start() -> ! {
16+
loop {
17+
#[allow(dead_code)]
18+
let event = cloudevents::EventBuilderV10::new()
19+
.id("my_id")
20+
.source("my_source")
21+
.subject("some_subject")
22+
.build()
23+
.unwrap();
24+
}
25+
}

src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
//! [Responders]: https://actix.rs/docs/handlers/
5454
5555
#![deny(broken_intra_doc_links)]
56+
5657
#![cfg_attr(not(any(feature = "std", test)), no_std)]
5758

5859
#[cfg(feature = "alloc")]
@@ -62,7 +63,9 @@ extern crate std as alloc;
6263
#[cfg(any(feature = "std", test))]
6364
extern crate std as core;
6465

66+
#[cfg(feature = "std")]
6567
pub mod binding;
68+
6669
pub mod event;
6770
pub mod message;
6871

0 commit comments

Comments
 (0)