-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring no-std-check into the main workspace
- Loading branch information
Showing
6 changed files
with
65 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,7 @@ substrate-std = [ | |
"sp-runtime/std", | ||
"sp-std/std", | ||
] | ||
|
||
[[example]] | ||
name = "no_std" | ||
crate-type = ["lib"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#![no_std] | ||
#![allow(unused_imports)] | ||
|
||
extern crate alloc; | ||
|
||
// Import the crates that we want to check if they are fully no-std compliance | ||
|
||
use cometbft; | ||
use cometbft_light_client_verifier; | ||
use cometbft_proto; | ||
|
||
#[cfg(feature = "sp-core")] | ||
use sp_core; | ||
|
||
#[cfg(feature = "sp-io")] | ||
use sp_io; | ||
|
||
#[cfg(feature = "sp-runtime")] | ||
use sp_runtime; | ||
|
||
#[cfg(feature = "sp-std")] | ||
use sp_std; | ||
|
||
use core::panic::PanicInfo; | ||
|
||
/* | ||
This function definition checks for the compliance of no-std in | ||
dependencies by causing a compile error if this crate is | ||
linked with `std`. When that happens, you should see error messages | ||
such as follows: | ||
``` | ||
error[E0152]: found duplicate lang item `panic_impl` | ||
--> no-std-check/src/lib.rs | ||
| | ||
12 | fn panic(_info: &PanicInfo) -> ! { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: the lang item is first defined in crate `std` (which `offending-crate` depends on) | ||
``` | ||
*/ | ||
#[cfg(feature = "panic-handler")] | ||
#[panic_handler] | ||
#[no_mangle] | ||
fn panic(_info: &PanicInfo) -> ! { | ||
loop {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,5 @@ | ||
// ensure_no_std/src/main.rs | ||
#![no_std] | ||
#![allow(unused_imports)] | ||
|
||
extern crate alloc; | ||
|
||
// Import the crates that we want to check if they are fully no-std compliance | ||
|
||
use cometbft; | ||
use cometbft_light_client_verifier; | ||
use cometbft_proto; | ||
|
||
#[cfg(feature = "sp-core")] | ||
use sp_core; | ||
|
||
#[cfg(feature = "sp-io")] | ||
use sp_io; | ||
|
||
#[cfg(feature = "sp-runtime")] | ||
use sp_runtime; | ||
|
||
#[cfg(feature = "sp-std")] | ||
use sp_std; | ||
|
||
use core::panic::PanicInfo; | ||
|
||
/* | ||
This function definition checks for the compliance of no-std in | ||
dependencies by causing a compile error if this crate is | ||
linked with `std`. When that happens, you should see error messages | ||
such as follows: | ||
``` | ||
error[E0152]: found duplicate lang item `panic_impl` | ||
--> no-std-check/src/lib.rs | ||
| | ||
12 | fn panic(_info: &PanicInfo) -> ! { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: the lang item is first defined in crate `std` (which `offending-crate` depends on) | ||
``` | ||
*/ | ||
#[cfg(feature = "panic-handler")] | ||
#[panic_handler] | ||
#[no_mangle] | ||
fn panic(_info: &PanicInfo) -> ! { | ||
loop {} | ||
} | ||
// This is a dummy library source. | ||
// | ||
// The check against linkage with std is performed in an example target. | ||
// This allows us to include this crate in the main workspace and have | ||
// `cargo test` build the example without the test harness, which requires std. |