mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-25 08:15:44 +00:00
add no-std-build for thumbv7em-none-eabi target
This commit is contained in:
@@ -437,13 +437,19 @@ jobs:
|
|||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
override: true
|
override: true
|
||||||
|
|
||||||
|
- name: Add the `thumbv7em-none-eabi` target
|
||||||
|
run: |
|
||||||
|
rustup target add `thumbv7em-none-eabi`
|
||||||
|
|
||||||
- name: Rust Cache
|
- name: Rust Cache
|
||||||
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
|
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
|
||||||
|
|
||||||
# Note: in `no_std` no real tests are possible, we just run a binary with some tests in it which panic upon failure.
|
# Note: We currently do not have a way to run real tests in a `no_std` environment.
|
||||||
- name: Run no_std tests
|
# We can only make sure that they compile to ARM thumb ISA.
|
||||||
|
# Running the binary and inspecting the output would require an actual machine with matching ISA or some sort of emulator.
|
||||||
|
- name: Compile `no-std-tests` crate to `thumbv7em-none-eabi` target.
|
||||||
run: |
|
run: |
|
||||||
cargo run
|
cargo build --target thumbv7em-none-eabi
|
||||||
working-directory: testing/no-std-tests
|
working-directory: testing/no-std-tests
|
||||||
|
|
||||||
- if: "failure()"
|
- if: "failure()"
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#[start]
|
#[start]
|
||||||
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
||||||
run_tests();
|
compile_test();
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,9 +19,7 @@ pub extern "C" fn rust_eh_personality() {}
|
|||||||
|
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||||
unsafe {
|
loop {}
|
||||||
libc::abort();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
use libc_alloc::LibcAlloc;
|
use libc_alloc::LibcAlloc;
|
||||||
@@ -33,13 +31,13 @@ static ALLOCATOR: LibcAlloc = LibcAlloc;
|
|||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
// Note: Panics in this function will lead to `Aborted (core dumped)` and a non-zero exit status => suitable for CI tests.
|
/// Including code here makes sure it is not pruned.
|
||||||
fn run_tests() {
|
/// We want all code included to compile fine for the `thumbv7em-none-eabi` target.
|
||||||
subxt_metadata_test();
|
fn compile_test() {
|
||||||
|
subxt_metadata_compiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Makes sure, subxt-metadata works in a no-std-context:
|
fn subxt_metadata_compiles() {
|
||||||
fn subxt_metadata_test() {
|
|
||||||
use codec::Decode;
|
use codec::Decode;
|
||||||
let bytes: alloc::vec::Vec<u8> = alloc::vec![0, 1, 2, 3, 4];
|
let bytes: alloc::vec::Vec<u8> = alloc::vec![0, 1, 2, 3, 4];
|
||||||
subxt_metadata::Metadata::decode(&mut &bytes[..]).expect_err("invalid byte sequence");
|
subxt_metadata::Metadata::decode(&mut &bytes[..]).expect_err("invalid byte sequence");
|
||||||
|
|||||||
Reference in New Issue
Block a user