File tree 11 files changed +147
-20
lines changed
11 files changed +147
-20
lines changed Original file line number Diff line number Diff line change
1
+
1
2
on : [pull_request]
2
3
3
4
name : Continuous Integration
4
5
5
6
jobs :
6
- test :
7
+ Test :
7
8
name : Test Suite
8
9
runs-on : ubuntu-latest
9
10
strategy :
@@ -13,16 +14,17 @@ jobs:
13
14
- stable
14
15
- nightly
15
16
steps :
17
+ - name : Checkout Crate
16
18
- uses : actions/checkout@v2
19
+ - name : Checkout Toolchain
17
20
- uses : actions-rs/toolchain@v1
18
21
with :
19
22
profile : minimal
20
23
toolchain : ${{ matrix.rust }}
21
24
override : true
22
- - uses : actions-rs/cargo@v1
23
- with :
24
- command : test
25
- args : --verbose --features strict
25
+ - name : Run Test Script
26
+ env : ${{ matrix.rust }}
27
+ run : ./contrib/test.sh
26
28
27
29
fmt :
28
30
name : Rustfmt
64
66
command : clippy
65
67
args : -- -D warnings
66
68
67
- Embedded :
69
+ EmbeddedWithAlloc :
70
+ name : no_std with alloc
68
71
runs-on : ubuntu-latest
69
72
steps :
70
73
- name : Checkout
83
86
env :
84
87
RUSTFLAGS : " -C link-arg=-Tlink.x"
85
88
CARGO_TARGET_THUMBV7M_NONE_EABI_RUNNER : " qemu-system-arm -cpu cortex-m3 -machine mps2-an385 -nographic -semihosting-config enable=on,target=native -kernel"
86
- run : cd embedded && cargo run --target thumbv7m-none-eabi
89
+ run : cd embedded/with-allocator && cargo run --target thumbv7m-none-eabi
90
+
91
+ EmbeddedNoAlloc :
92
+ name : no_std no alloc
93
+ runs-on : ubuntu-latest
94
+ strategy :
95
+ steps :
96
+ - uses : actions/checkout@v2
97
+ - uses : actions-rs/toolchain@v1
98
+ with :
99
+ profile : minimal
100
+ toolchain : stable
101
+ override : true
102
+ - uses : actions-rs/cargo@v1
103
+ with :
104
+ command : rustc
105
+ args : -- -C link-arg=-nostartfiles
Original file line number Diff line number Diff line change 2
2
* .o
3
3
/Cargo.lock
4
4
5
- /embedded /Cargo.lock
6
- /embedded /.cargo
5
+ /embedded /no-allocator /Cargo.lock
6
+ /embedded /no-allocator /.cargo
7
+ /embedded /with-allocator /Cargo.lock
8
+ /embedded /with-allocator /.cargo
Original file line number Diff line number Diff line change @@ -12,7 +12,9 @@ edition = "2018"
12
12
13
13
[features ]
14
14
default = [" std" ]
15
- std = []
15
+ std = [" alloc" ]
16
+ alloc = []
17
+
16
18
# Only for CI to make all warnings errors, do not activate otherwise (may break forward compatibility)
17
19
strict = []
18
20
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+ #
3
+ # CI test script for rust-bech32.
4
+ #
5
+ # The "strict" feature is used to configure cargo to deny all warnings, always use it in test runs.
6
+
7
+ set -ex
8
+
9
+ # Sanity, check tools exist.
10
+ cargo --version
11
+ rustc --version
12
+
13
+ # Sanity, first check with default features.
14
+
15
+ cargo build
16
+ cargo test
17
+
18
+ # Sanity, build with no features.
19
+
20
+ cargo build --no-default-features --features=" strict"
21
+
22
+ # Check "alloc" feature alone.
23
+
24
+ cargo build --no-default-features --features=" strict std"
25
+ cargo test --no-default-features --features=" strict std"
26
+
27
+ # Check "std" feature (implies "alloc").
28
+
29
+ cargo build --no-default-features --features=" strict alloc"
30
+ cargo test --no-default-features --features=" strict alloc"
31
+
32
+ exit 0
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ authors = [
" Tobin C. Harding <[email protected] >" ]
3
+ edition = " 2018"
4
+ readme = " README.md"
5
+ name = " no-allocator"
6
+ version = " 0.1.0"
7
+
8
+ [profile .dev ]
9
+ panic = " abort"
10
+
11
+ [profile .release ]
12
+ panic = " abort"
13
+
14
+ [dependencies ]
15
+ bech32 = { path = " ../../" , default_features = false }
Original file line number Diff line number Diff line change
1
+ # no_std test crate without an allocator
2
+
3
+ This crate is based on the blog post found at:
4
+
5
+ https://blog.dbrgn.ch/2019/12/24/testing-for-no-std-compatibility/
6
+
7
+ Its purpose is to test that the ` rust-bech32 ` library can be built in a ` no_std ` environment without
8
+ a global allocator.
9
+
10
+ Build with: ` cargo rustc -- -C link-arg=-nostartfiles ` .
Original file line number Diff line number Diff line change
1
+ //! Test `no_std` build of `bech32`.
2
+ //!
3
+ //! Build with: `cargo rustc -- -C link-arg=-nostartfiles`.
4
+ //!
5
+
6
+ #![ no_std]
7
+ #![ no_main]
8
+
9
+ use core:: panic:: PanicInfo ;
10
+
11
+ // Note: `#[global_allocator]` is NOT set.
12
+
13
+ #[ allow( unused_imports) ]
14
+ use bech32;
15
+
16
+ /// This function is called on panic, defining this ensures build will fail if `std` is enabled
17
+ /// because `panic` will be defined twice.
18
+ #[ panic_handler]
19
+ fn panic ( _info : & PanicInfo ) -> ! {
20
+ loop { }
21
+ }
22
+
23
+ #[ no_mangle]
24
+ pub extern "C" fn _start ( ) -> ! {
25
+ loop { }
26
+ }
Original file line number Diff line number Diff line change 2
2
authors = [
" Riccardo Casatta <[email protected] >" ]
3
3
edition = " 2018"
4
4
readme = " README.md"
5
- name = " embedded "
5
+ name = " with-allocator "
6
6
version = " 0.1.0"
7
7
8
8
[dependencies ]
@@ -11,10 +11,10 @@ cortex-m-rt = "0.6.10"
11
11
cortex-m-semihosting = " 0.3.3"
12
12
panic-halt = " 0.2.0"
13
13
alloc-cortex-m = " 0.4.1"
14
- bech32 = { path =" ../" , default-features = false }
14
+ bech32 = { path =" ../../ " , default-features = false }
15
15
16
16
[[bin ]]
17
- name = " embedded "
17
+ name = " with-allocator "
18
18
test = false
19
19
bench = false
20
20
File renamed without changes.
File renamed without changes.
You can’t perform that action at this time.
0 commit comments