From 83e369a0bfbdbf939c0b8f90892aa6cc98d55e8c Mon Sep 17 00:00:00 2001 From: Erik Hedvall Date: Sun, 11 Aug 2019 15:14:05 +0200 Subject: [PATCH] Add a basic test crate for no_std --- .travis.yml | 5 +++++ Cargo.toml | 5 ++++- no_std_test/Cargo.toml | 13 +++++++++++++ no_std_test/LICENSE-APACHE | 1 + no_std_test/LICENSE-MIT | 1 + no_std_test/src/main.rs | 26 ++++++++++++++++++++++++++ 6 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 no_std_test/Cargo.toml create mode 120000 no_std_test/LICENSE-APACHE create mode 120000 no_std_test/LICENSE-MIT create mode 100644 no_std_test/src/main.rs diff --git a/.travis.yml b/.travis.yml index 37f729f06..8d890d0ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,11 @@ script: - cargo test -v --features strict - bash ../scripts/test_features.sh + - if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then + cd ../no_std_test; + cargo build -v; + fi + - cd .. - cargo doc after_success: diff --git a/Cargo.toml b/Cargo.toml index a42a93508..048efc53c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,8 @@ [workspace] members = [ "palette", - "palette_derive" + "palette_derive", + + # Test crates + "no_std_test" ] diff --git a/no_std_test/Cargo.toml b/no_std_test/Cargo.toml new file mode 100644 index 000000000..00e719a14 --- /dev/null +++ b/no_std_test/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "no_std_test" +version = "0.0.0" +authors = ["Erik Hedvall "] +exclude = [] +description = "Test crate for #[no_std]." +repository = "/~https://github.com/Ogeon/palette" +license = "MIT OR Apache-2.0" + +[dependencies.palette] +path = "../palette" +default-features = false +features = ["named"] diff --git a/no_std_test/LICENSE-APACHE b/no_std_test/LICENSE-APACHE new file mode 120000 index 000000000..965b606f3 --- /dev/null +++ b/no_std_test/LICENSE-APACHE @@ -0,0 +1 @@ +../LICENSE-APACHE \ No newline at end of file diff --git a/no_std_test/LICENSE-MIT b/no_std_test/LICENSE-MIT new file mode 120000 index 000000000..76219eb72 --- /dev/null +++ b/no_std_test/LICENSE-MIT @@ -0,0 +1 @@ +../LICENSE-MIT \ No newline at end of file diff --git a/no_std_test/src/main.rs b/no_std_test/src/main.rs new file mode 100644 index 000000000..001f6d218 --- /dev/null +++ b/no_std_test/src/main.rs @@ -0,0 +1,26 @@ +#![feature(lang_items, start, link_args)] +#![no_std] + +// A bit of a hack to make the linking go through. +// This binary is not meant to be used, only to be compiled. +#![allow(unused_attributes)] +#![link_args="-nostdlib"] + +extern crate palette; + +use core::panic::PanicInfo; + +#[start] +fn start(_argc: isize, _argv: *const *const u8) -> isize { + let _magenta = palette::Srgb::new(255u8, 0, 255); + + 0 +} + +#[lang = "eh_personality"] +extern fn eh_personality() {} + +#[panic_handler] +fn panic(_info: &PanicInfo) -> ! { + loop {} +}