File tree Expand file tree Collapse file tree 11 files changed +141
-18
lines changed Expand file tree Collapse file tree 11 files changed +141
-18
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ on: [pull_request]
33name : Continuous Integration
44
55jobs :
6- test :
6+ Test :
77 name : Test Suite
88 runs-on : ubuntu-latest
99 strategy :
@@ -13,16 +13,17 @@ jobs:
1313 - stable
1414 - nightly
1515 steps :
16+ - name : Checkout Crate
1617 - uses : actions/checkout@v2
18+ - name : Checkout Toolchain
1719 - uses : actions-rs/toolchain@v1
1820 with :
1921 profile : minimal
2022 toolchain : ${{ matrix.rust }}
2123 override : true
22- - uses : actions-rs/cargo@v1
23- with :
24- command : test
25- args : --verbose --features strict
24+ - name : Run Test Script
25+ env : ${{ matrix.rust }}
26+ run : ./contrib/test.sh
2627
2728 fmt :
2829 name : Rustfmt
6061 command : clippy
6162 args : -- -D warnings
6263
63- Embedded :
64+ EmbeddedWithAlloc :
65+ name : no_std with alloc
6466 runs-on : ubuntu-latest
6567 steps :
6668 - name : Checkout
7981 env :
8082 RUSTFLAGS : " -C link-arg=-Tlink.x"
8183 CARGO_TARGET_THUMBV7M_NONE_EABI_RUNNER : " qemu-system-arm -cpu cortex-m3 -machine mps2-an385 -nographic -semihosting-config enable=on,target=native -kernel"
82- run : cd embedded && cargo run --target thumbv7m-none-eabi
84+ run : cd embedded/with-allocator && cargo run --target thumbv7m-none-eabi
85+
86+ EmbeddedNoAlloc :
87+ name : no_std no alloc
88+ runs-on : ubuntu-latest
89+ strategy :
90+ steps :
91+ - uses : actions/checkout@v2
92+ - uses : actions-rs/toolchain@v1
93+ with :
94+ profile : minimal
95+ toolchain : stable
96+ override : true
97+ - uses : actions-rs/cargo@v1
98+ with :
99+ command : rustc
100+ args : -- -C link-arg=-nostartfiles
Original file line number Diff line number Diff line change 22* .o
33/Cargo.lock
44
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 @@ -13,7 +13,9 @@ edition = "2018"
1313
1414[features ]
1515default = [" std" ]
16- std = []
16+ std = [" alloc" ]
17+ alloc = []
18+
1719# Only for CI to make all warnings errors, do not activate otherwise (may break forward compatibility)
1820strict = []
1921
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+ # Check without features ("strict" is a CI feature only, see above).
14+ cargo build --no-default-features --features=" strict"
15+ cargo test --no-default-features --features=" strict"
16+
17+ # Check "std" feature (implies "alloc").
18+ cargo build --no-default-features --features=" strict std"
19+ cargo test --no-default-features --features=" strict std"
20+
21+ # Check "alloc" feature alone.
22+ cargo build --no-default-features --features=" strict alloc"
23+ cargo test --no-default-features --features=" strict alloc"
24+
25+ exit 0
Original file line number Diff line number Diff line change 1+ [package ]
2+ authors = [" Tobin C. Harding <me@tobin.cc>" ]
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 22authors = [" Riccardo Casatta <riccardo@casatta.it>" ]
33edition = " 2018"
44readme = " README.md"
5- name = " embedded "
5+ name = " with-allocator "
66version = " 0.1.0"
77
88[dependencies ]
@@ -11,10 +11,10 @@ cortex-m-rt = "0.6.10"
1111cortex-m-semihosting = " 0.3.3"
1212panic-halt = " 0.2.0"
1313alloc-cortex-m = " 0.4.1"
14- bech32 = { path =" ../" , default-features = false }
14+ bech32 = { path =" ../../ " , default-features = false }
1515
1616[[bin ]]
17- name = " embedded "
17+ name = " with-allocator "
1818test = false
1919bench = false
2020
File renamed without changes.
File renamed without changes.
You can’t perform that action at this time.
0 commit comments