forked from ROMEO/obsw
added freeRTOS on linux build
This commit is contained in:
@ -1,5 +0,0 @@
|
||||
[build]
|
||||
target = "armv7a-none-eabihf"
|
||||
|
||||
[unstable]
|
||||
build-std = ["core"]
|
@ -1,13 +1,33 @@
|
||||
#TODO can we get CMake to configure cmake --build --clean to run cargo clean?
|
||||
#TODO look into corrosion cmake plugin
|
||||
|
||||
add_custom_target(
|
||||
mission_rust_internal
|
||||
COMMAND cargo build $<$<CONFIG:Release>:--release>
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
if (${CMAKE_CROSSCOMPILING})
|
||||
|
||||
add_library(mission_rust INTERFACE)
|
||||
add_custom_target(
|
||||
mission_rust_internal
|
||||
COMMAND cargo build -Zbuild-std=core --target=${CMAKE_SYSTEM_PROCESSOR} $<$<CONFIG:Release>:--release>
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
add_dependencies(mission_rust mission_rust_internal)
|
||||
add_library(mission_rust INTERFACE)
|
||||
|
||||
target_link_libraries(mission_rust INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/target/armv7a-none-eabihf/$<IF:$<CONFIG:Release>,release,debug>/libmission_rust.a)
|
||||
add_dependencies(mission_rust mission_rust_internal)
|
||||
|
||||
target_link_libraries(mission_rust INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/target/${CMAKE_SYSTEM_PROCESSOR}/$<IF:$<CONFIG:Release>,release,debug>/libmission_rust.a)
|
||||
|
||||
else()
|
||||
|
||||
add_custom_target(
|
||||
mission_rust_internal
|
||||
COMMAND cargo build $<$<CONFIG:Release>:--release>
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
add_library(mission_rust INTERFACE)
|
||||
|
||||
add_dependencies(mission_rust mission_rust_internal)
|
||||
|
||||
target_link_libraries(mission_rust INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/target/$<IF:$<CONFIG:Release>,release,debug>/libmission_rust.a)
|
||||
|
||||
|
||||
endif()
|
@ -6,6 +6,12 @@ edition = "2021"
|
||||
[lib]
|
||||
crate-type = ["staticlib"]
|
||||
|
||||
[profile.dev]
|
||||
panic = 'abort'
|
||||
|
||||
[profile.release]
|
||||
panic = 'abort'
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
@ -24,7 +24,7 @@ fn panic(panic: &PanicInfo<'_>) -> ! {
|
||||
sifln!("");
|
||||
sif!("in task \"");
|
||||
unsafe {
|
||||
//TODO is from_ptr safe enough?
|
||||
//osal::get_task_name is implemented safely in C, so we trust it
|
||||
let task_name = core::ffi::CStr::from_ptr(osal::get_task_name());
|
||||
let task_name_utf8 = core::str::from_utf8(task_name.to_bytes());
|
||||
match task_name_utf8 {
|
||||
@ -62,6 +62,11 @@ extern "C" fn rust_assert_called(ptr: *const core::ffi::c_char, line: core::ffi:
|
||||
panic!("assertion failed at {file_name}:{}", line);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn rust_alloc_failed(){
|
||||
panic!("allocation failed!");
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn rust_main() {
|
||||
sifln!("Rust startup 🚀");
|
||||
|
Reference in New Issue
Block a user