Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build.rs in project readme #49

Merged
merged 2 commits into from
Feb 22, 2023

Conversation

StefanB7
Copy link
Contributor

This morning I've been experimenting with FreeRTOS-rust on an STM32F411RE Nucleo board. When setting up my project, I ran into some issues building the project when using the build.rs example provided in the readme. This PR fixes the issues I came across.

The errors I got:

error[E0308]: mismatched types                                                                                                                                                                                              
   --> build.rs:7:21
    |
7   |     b.freertos_port("GCC/ARM_CM3"); // Port dir relativ to 'FreeRTOS-Kernel/portable' 
    |       ------------- ^^^^^^^^^^^^^- help: try using a conversion method: `.to_string()`
    |       |             |
    |       |             expected `String`, found `&str`
    |       arguments to this method are incorrect
    |

was fixed by adding .to_owned().

   --> build.rs:8:12
    |
8   |     b.heap("heap4.c");              // Set the heap_?.c allocator to use from
    |       ---- ^^^^^^^^^- help: try using a conversion method: `.to_string()`
    |       |    |
    |       |    expected `String`, found `&str`
    |       arguments to this method are incorrect
    |

was fixed by creating a String from the string literal. After doing this, I got:

error[E0282]: type annotations needed
 --> build.rs:8:7
  |
8 |     b.heap(String::from("heap4.c"));              // Set the heap_?.c allocator to use from
  |       ^^^^ cannot infer type of the type parameter `P` declared on the associated function `heap`
  |
help: consider specifying the generic argument
  |
8 |     b.heap::<P>(String::from("heap4.c"));              // Set the heap_?.c allocator to use from
  |           +++++

which was solved by b.heap::<String>(......

error: format argument must be a string literal
  --> build.rs:13:45
   |
13 |     b.compile().unwrap_or_else(|e| { panic!(e.to_string()) });
   |                                             ^^^^^^^^^^^^^
   |
help: you might be missing a string literal to format with
   |
13 |     b.compile().unwrap_or_else(|e| { panic!("{}", e.to_string()) });
   |                                             +++++

I'll try to create a PR for an example of FreeRTOS-rust on the STM32F411 Nucleo board later today.
Thanks everyone for this project.

@schteve
Copy link
Collaborator

schteve commented Feb 21, 2023

Thanks for this! The readme example should definitely be correct and easy to drop into a new project.

Some of what you're seeing may be already fixed in the latest (unreleased) trunk. I think the string conversions and the turbofish on heap() should be unnecessary since we changed these functions to take an AsRef<Path>. So I'd rather not change those lines. However the change to the panic does make sense I think.

You should be able to confirm that the latest code works by changing your Cargo.toml to point to a local clone of the repo (freertos-cargo-build = { path = "../FreeRTOS-rust/freertos-cargo-build"} or similar).

We really need to make a new release at some point to get the latest changes out there and avoid issues like this @niondir

@schteve schteve merged commit 07aae04 into lobaro:master Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants