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

feat: Make it easier to specify target architecture #869

Merged

Conversation

winksaville
Copy link
Contributor

Create aliases build-arm run-arm build-riscv and run-riscv in
.cargo/config.toml. With these defined you can now use the alias which
will be converted to the full target name:

  cargo build-arm   -> cargo build --target thumbv8m.main-none-eabihf
  cargo run-arm     -> cargo run --target thumbv8m.main-none-eabihf
  cargo build-riscv -> cargo build --target riscv32imac-unknown-none-elf
  cargo run-risv    -> cargo run --target riscv32imac-unknown-none-elf

Append --release parameter to do release builds and runs. For example:

  cargo run-riscv --release ->
         cargo run --target riscv32imac-unknown-none-elf --release

feat: Make it easier to specify target architecture

Create aliases build-arm run-arm build-riscv and run-riscv in .cargo/config.toml. With these defined you can now use the alias which will be converted to the full target name:

cargo build-arm --bin blinky ->
cargo build --bin blinky --target=thumbv8m.main-none-eabihf
cargo run-arm --bin blinky ->
cargo run --bin blinky --target=thumbv8m.main-none-eabihf
cargo build-riscv --bin blinky ->
cargo build --bin blinky --target=riscv32imac-unknown-none-elf
cargo run-risv --bin blinky ->
cargo run --bin blinky --target=riscv32imac-unknown-none-elf

Append --release parameter to do release builds and runs. For example:

cargo run-risv --bin blinky --release ->
cargo run --bin blinky --target=thumbv8m.main-none-eabihf --release

    Create aliases build-arm run-arm build-riscv and run-riscv in
    .cargo/config.toml. With these defined you can now use the alias which
    will be converted to the full target name:

      cargo build-arm   -> cargo build --target thumbv8m.main-none-eabihf
      cargo run-arm     -> cargo run --target thumbv8m.main-none-eabihf
      cargo build-riscv -> cargo build --target riscv32imac-unknown-none-elf
      cargo run-risv    -> cargo run --target riscv32imac-unknown-none-elf

    Append --release parameter to do release builds and runs. For example:

      cargo run-riscv --release ->
             cargo run --target riscv32imac-unknown-none-elf --release

feat: Make it easier to specify target architecture

Create aliases build-arm run-arm build-riscv and run-riscv in
.cargo/config.toml. With these defined you can now use the alias which
will be converted to the full target name:

  cargo build-arm --bin blinky ->
  	cargo build --bin blinky --target=thumbv8m.main-none-eabihf
  cargo run-arm --bin blinky ->
  	cargo run --bin blinky --target=thumbv8m.main-none-eabihf
  cargo build-riscv --bin blinky ->
  	cargo build --bin blinky --target=riscv32imac-unknown-none-elf
  cargo run-risv --bin blinky ->
  	cargo run --bin blinky --target=riscv32imac-unknown-none-elf

Append --release parameter to do release builds and runs. For example:

  cargo run-risv --bin blinky --release ->
  	cargo run --bin blinky --target=thumbv8m.main-none-eabihf --release
@thejpster
Copy link
Member

Nice idea. Can you put these in the README too?

Also, tweak the aliases and add dev and release modes with shorter names.
rp235x-hal-examples/README.md Outdated Show resolved Hide resolved
rp235x-hal-examples/README.md Outdated Show resolved Hide resolved
rp235x-hal-examples/README.md Outdated Show resolved Hide resolved
rp235x-hal-examples/README.md Outdated Show resolved Hide resolved
rp235x-hal-examples/README.md Outdated Show resolved Hide resolved
rp235x-hal-examples/.cargo/config.toml Outdated Show resolved Hide resolved
rp235x-hal-examples/README.md Outdated Show resolved Hide resolved
rp235x-hal-examples/README.md Outdated Show resolved Hide resolved
rp235x-hal-examples/README.md Outdated Show resolved Hide resolved
rp235x-hal-examples/README.md Outdated Show resolved Hide resolved
@thejpster
Copy link
Member

I'm not sure the extra aliases help with clarity. I was OK with the previous list of four:

build-arm = "build --target=thumbv8m.main-none-eabihf"
run-arm = "run --target=thumbv8m.main-none-eabihf"
build-riscv = "build --target=riscv32imac-unknown-none-elf"
run-riscv = "run --target=riscv32imac-unknown-none-elf"

Mainly because this saves you from typing the target name out in full.

Users are welcome to configure their personal projects however they wish. However, this is example code and a lengthy explaination of the short-form custom aliases (like rda) added here appears to me to detract from the purpose of helping them understand how to write and build code for RP2040 and RP2350.

@winksaville
Copy link
Contributor Author

I'm not sure the extra aliases help with clarity. I was OK with the previous list of four:

build-arm = "build --target=thumbv8m.main-none-eabihf"
run-arm = "run --target=thumbv8m.main-none-eabihf"
build-riscv = "build --target=riscv32imac-unknown-none-elf"
run-riscv = "run --target=riscv32imac-unknown-none-elf"

Mainly because this saves you from typing the target name out in full.

Users are welcome to configure their personal projects however they wish. However, this is example code and a lengthy explaination of the short-form custom aliases (like rda) added here appears to me to detract from the purpose of helping them understand how to write and build code for RP2040 and RP2350.

Makes sense, but how about adding rra and rrb? I think those are the most useful and provide a hint at customization a user could do.

Do you like the build-xxx or bld-xxx?

Copy link
Contributor Author

@winksaville winksaville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Txs for the feed back!

rp235x-hal-examples/README.md Outdated Show resolved Hide resolved
rp235x-hal-examples/.cargo/config.toml Outdated Show resolved Hide resolved
@thejpster
Copy link
Member

I prefer build-xxx.

I think cargo run-arm --release is fine and doesn't need a short-hand.

@winksaville
Copy link
Contributor Author

I prefer build-xxx.

SG

I think cargo run-arm --release is fine and doesn't need a short-hand.

Do you want me to keep rrr or delete that too?

@thejpster
Copy link
Member

Delete that one - cargo run-riscv --release is fine.

config.toml:
 * Use build-* rather than bld-*
 * Add a "custom" command example `rrr-blinky`

README.md:
 * Show "all" examples are created if `--bin` is not specified
 * Show the size differential between development and release profiles
 * Describe aliases at the end of Getting Started using build-riscv,
   run-riscv and rrr-blinky
rp235x-hal-examples/README.md Outdated Show resolved Hide resolved
rp235x-hal-examples/README.md Outdated Show resolved Hide resolved
rp235x-hal-examples/README.md Outdated Show resolved Hide resolved
rp235x-hal-examples/README.md Show resolved Hide resolved
rp235x-hal-examples/README.md Outdated Show resolved Hide resolved
rp235x-hal-examples/README.md Outdated Show resolved Hide resolved
@thejpster
Copy link
Member

This is definitely heading in the right direction. Made a few suggestions.

Copy link
Contributor Author

@winksaville winksaville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, txs the final tweaks!!!!

@thejpster thejpster merged commit e87e2ac into rp-rs:main Oct 31, 2024
49 checks passed
@winksaville winksaville deleted the Make-it-easier-to-specify-target-architecture branch October 31, 2024 14:58
@winksaville winksaville restored the Make-it-easier-to-specify-target-architecture branch October 31, 2024 14:58
@winksaville winksaville deleted the Make-it-easier-to-specify-target-architecture branch October 31, 2024 14:58
@winksaville
Copy link
Contributor Author

Bravo, txs @9names and @thejpster for all the help and guidance!

winksaville added a commit to winksaville/rp-hal that referenced this pull request Nov 4, 2024
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.

3 participants