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

Some examples can't be run from the root directory #8

Open
mjhouse opened this issue Aug 29, 2022 · 3 comments
Open

Some examples can't be run from the root directory #8

mjhouse opened this issue Aug 29, 2022 · 3 comments

Comments

@mjhouse
Copy link
Owner

mjhouse commented Aug 29, 2022

Normally, you can run examples with-

cargo run --example <example name>
@vcrn
Copy link
Contributor

vcrn commented Aug 30, 2022

I've started looking into this, and if I understand it correctly, in order to let an example be runnable with this command the following things need to be fixed (let's say in the case of nano/blink, to get it to run with cargo run --example nano-blink):

In the root/Cargo.toml, this needs to be added:
[[example]]
name = "nano-blink"
path = "examples/nano/blink/src/main.rs"

Then, since "https://github.com/rahix/avr-hal" is used in all our examples, this dependency seems needed in the root/Cargo.toml, with 'features = ["arduino-nano"]'. (To get the uno-examples to work, I assume 'features = ["arduino-uno"]' needs to be added too.)

After this, cargo complains about this:

`#![feature]` may not be used on the stable release channel
  --> [redacted]/avr-device-0.3.4/src/lib.rs:65:35
   |
65 | #![cfg_attr(avr_device_asm_macro, feature(asm_experimental_arch))]

I saw your Issue "Switch to stable rust #11", so I paused here, since it seemed to add up to a bit too much for these additions to be reasonable. I think we should at least wait until Issue #11 is worked out (either confirming that it can be built using stable and implemented, or that it is not possible), and then considering if it's worth adding dependencies to this crate in the form of avr-hal.

What do you think?

@mjhouse
Copy link
Owner Author

mjhouse commented Aug 30, 2022

Sounds good. I took a stab at building with stable this morning, but didn't get it to work.

@vcrn
Copy link
Contributor

vcrn commented Sep 6, 2022

I started looking into this again, and made some progress I believe. A smoother way forward might be to add this to the root/Cargo.toml (in this case, only regarding the Uno example):

[workspace]
resolver = "2"
members = [
    "examples/uno/*"
]

Then, running from root:
cargo +nightly run -p ag-lcd-print (or whatever name is listed under [package], name.

After fighting a bit to get it to compile without running into error: ran out of registers during register allocation (actually not sure how I got past this), I eventually ran into this issue:

warning: profiles for the non root package will be ignored, specify profiles at the workspace root.
...
...
error: Ensure that you are using an AVR target! You may need to change directories or pass a --target flag to cargo. See
              https://github.com/Rahix/avr-device/pull/41 for more details.

This is something I haven't been able to get by, and not sure if it will be possible in this case.

I wanted to leave a comment about it here anyway, because this seems to be a better way of running examples in some cases from root instead of the way I started with and outlined in the comments above, and was educational for at least me to look into. This way, we don't seem to any longer have an issue of setting it to nightly or using dependencies in the examples which are not present in the root/Cargo.toml

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

No branches or pull requests

2 participants