Skip to content

Commit 84ff57e

Browse files
authored
Merge pull request #25 from hashmismatch/beta_0.3.0
Rust stabilization
2 parents a5b296a + 0c6c5d8 commit 84ff57e

12 files changed

Lines changed: 33 additions & 54 deletions

File tree

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ dist: trusty
33

44
language: rust
55
rust:
6-
- nightly
6+
- beta
77

88
cache:
99
directories:
@@ -21,11 +21,10 @@ install:
2121
- curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $TRAVIS_RUST_VERSION
2222
- source ~/.cargo/env
2323
- export QEMU_ARCHIVE=$HOME/qemueclipse.tgz
24-
- export QEMU_URL=https://github.com/gnuarmeclipse/qemu/releases/download/gae-2.6.0-20160728/gnuarmeclipse-qemu-debian64-2.6.0-201607280535.tgz
25-
- export QEMU_DIR=$HOME/qemu/2.6.0-201607280535
24+
- export QEMU_URL=https://github.com/gnu-mcu-eclipse/qemu/releases/download/v2.8.0-6-20190517/gnu-mcu-eclipse-qemu-2.8.0-6-20190517-1329-centos64.tgz
25+
- export QEMU_DIR=$HOME/gnu-mcu-eclipse/qemu/2.8.0-6-20190517-1329
2626
- if [ ! -e $QEMU_DIR/bin/qemu-system-gnuarmeclipse ]; then wget $QEMU_URL -O $QEMU_ARCHIVE && tar xzf $QEMU_ARCHIVE -C $HOME ; fi
2727
- export PATH=$PATH:$QEMU_DIR/bin:$HOME/.cargo/bin
28-
- rustup component add rust-src
2928
- rustup target add thumbv7m-none-eabi
3029

3130
script:

qemu_runner/src/builder.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ pub fn crossbuild_rust_tests(options: &CrossbuildOptions) -> CrossbuiltTests {
101101
.expect("Can't get a current toolchain");
102102

103103
let active_toolchain = String::from_utf8_lossy(&output.stdout);
104-
active_toolchain.trim().to_owned()
104+
let mut split = active_toolchain.split_whitespace();
105+
split.next().expect("active toolchain missing").trim().to_owned()
105106
};
106107

107108
let rustup_sysroot = {
@@ -120,9 +121,21 @@ pub fn crossbuild_rust_tests(options: &CrossbuildOptions) -> CrossbuiltTests {
120121
copy(sysroot_rlib.absolute_path, format!("{}/{}.o", tests_deps_dir, sysroot_rlib.name.trim_right_matches(".rlib")));
121122
}
122123

123-
let mut test_objects: Vec<String> = find_files(&tests_deps_dir, |n| {
124+
let mut test_objects: Vec<_> = find_files(&tests_deps_dir, |n| {
124125
n.ends_with(".o")
125-
}).iter().cloned().map(|f| f.absolute_path).collect();
126+
}).iter().cloned().collect();
127+
128+
test_objects.sort_by_key(|f| {
129+
if f.name.contains("freertos_rs") { 0 }
130+
else if f.name.contains("lazy_static") { 1 }
131+
else if f.name.contains("liballoc") { 2 }
132+
else if f.name.contains("libcompiler_builtins") { 3 }
133+
else if f.name.contains("libcore") { 4 }
134+
else if f.name.contains("librustc_std_workspace_core") { 5 }
135+
else { 6 }
136+
});
137+
138+
let mut test_objects: Vec<_> = test_objects.into_iter().map(|f| f.absolute_path).collect();
126139

127140
let mut objects = vec![];
128141
objects.append(&mut test_objects);

qemu_stm32_tests/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ crate-type = ["lib"]
1111
freertos_rs = { path = "../" }
1212

1313
[dependencies.lazy_static]
14-
version = "0.2.1"
15-
features = ["nightly", "spin_no_std"]
14+
version = "1.3.0"
15+
features = ["spin_no_std"]

qemu_stm32_tests/src/lib.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
#![no_std]
2-
#![feature(lang_items)]
3-
4-
#![feature(alloc)]
5-
#![feature(fnbox)]
62

73
use core::panic::PanicInfo;
84

9-
#[lang = "eh_unwind_resume"] extern fn eh_unwind_resume() {}
10-
115
#[panic_handler]
126
#[inline(never)]
137
fn panic(info: &PanicInfo) -> ! {
@@ -89,6 +83,3 @@ pub mod test_stats;
8983
pub mod test_processor;
9084
pub mod test_timers;
9185

92-
93-
94-

qemu_stm32_tests/src/prelude/no_std.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub use core::ops::{Deref, DerefMut};
1212
pub use core::cell::UnsafeCell;
1313

1414
pub use alloc::rc::Rc;
15-
pub use alloc::boxed::{Box, FnBox};
15+
pub use alloc::boxed::Box;
1616
pub use alloc::sync::Arc;
1717
pub use alloc::vec::Vec;
1818
pub use alloc::string::*;

qemu_stm32_tests/src/test_mem_leaks1.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,19 @@ pub fn test_mem_leaks1() -> i8 {
1717
// simple task spawn
1818
for i in 0..100 {
1919
Task::new().name(&format!("t_{}", i)).stack_size(256).start(move || {
20-
let a = i;
21-
let s: String = "Hello world".into();
20+
let s = format!("Hello world {}", i);
2221
}).unwrap();
2322

24-
CurrentTask::delay(Duration::ms(1));
23+
CurrentTask::delay(Duration::ms(2));
2524
}
2625

27-
2826
// simple mutexes
2927
for i in 0..100 {
3028
let m = Mutex::new(0).unwrap();
3129
let mut v = m.lock(Duration::ms(50)).unwrap();
3230
*v += 1;
3331
}
34-
32+
3533
// recursive mutexes
3634
for i in 0..100 {
3735
let m = RecursiveMutex::new(0).unwrap();
@@ -75,7 +73,7 @@ pub fn test_mem_leaks1() -> i8 {
7573
q.send(10, Duration::ms(5)).unwrap();
7674
q.receive(Duration::ms(100)).unwrap();
7775
}
78-
76+
7977
end_memory_usage = heap_allocated_memory();
8078
assert_eq!(start_memory_usage, end_memory_usage, "Mem usage #1");
8179

src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
//! your firmware's sources directory and modify it to include the appropriate headers for
1010
//! target your system.
1111
//!
12-
//! For a complete example, check the enclosed GCC ARM/Rust/QEMU based unit tests. The Rust
13-
//! cargo crate [xargo](https://crates.io/crates/xargo) is used for cross-compilation. The project
12+
//! For a complete example, check the enclosed GCC ARM/Rust/QEMU based unit tests. The project
1413
//! ``qemu_runner`` cross-compiles this library, compiles the main firmware using GCC ARM and links
1514
//! in the appropriate entry points for unit tests. [GNU ARM Eclipse QEMU](http://gnuarmeclipse.github.io/qemu/)
1615
//! is used to run the test binaries.
@@ -53,13 +52,9 @@
5352
5453
#![no_std]
5554

56-
#![feature(alloc)]
57-
#![feature(fnbox)]
58-
5955
#[macro_use]
6056
extern crate alloc;
6157

62-
6358
mod prelude;
6459
mod shim;
6560

src/patterns/compute_task.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ impl ComputeTaskBuilder for TaskBuilder {
8383
/// let result = task.into_result(Duration::ms(1000)).unwrap();
8484
/// # println!("{}", result);
8585
/// ```
86+
8687
pub struct ComputeTask<R> {
8788
task: Task,
8889
result: Arc<Mutex<Option<R>>>,

src/prelude/no_std.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub use core::cell::UnsafeCell;
1313
pub use core::ptr;
1414

1515
pub use alloc::rc::Rc;
16-
pub use alloc::boxed::{Box, FnBox};
16+
pub use alloc::boxed::Box;
1717
pub use alloc::sync::{Arc, Weak};
1818
pub use alloc::vec::Vec;
1919
pub use alloc::string::*;

src/semaphore.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,7 @@ impl Semaphore {
3232
Ok(Semaphore { semaphore: s })
3333
}
3434
}
35-
36-
// pub fn get_count(&self) -> u32 {
37-
// unsafe {
38-
// freertos_rs_get_semaphore_count(self.semaphore)
39-
// }
40-
// }
41-
//
42-
35+
4336
/// Lock this semaphore in a RAII fashion
4437
pub fn lock<D: DurationTicks>(&self, max_wait: D) -> Result<SemaphoreGuard, FreeRtosError> {
4538
unsafe {

0 commit comments

Comments
 (0)