cross icon indicating copy to clipboard operation
cross copied to clipboard

cargo alias doesn't work on cross

Open XyLyXyRR opened this issue 3 years ago • 2 comments

Environment

  • Rust toolchain version: rustc 1.52.1 (9bc8c42bb 2021-05-09)
  • IDE name and version: intellij-idea-community-edition 4:2021.1.1-1
  • Operating system: arch linux

Problem description

Cargo alias doesn't work on cross.

~/.cargo/config.toml

[alias]
dbr = "build --target aarch64-linux-android --release"

cross dbr complie failed, but cross build --target aarch64-linux-android --release worked.

Steps to reproduce

  • cargo new one && cd one
  • add rustls to Cargo.toml
  • execute cross dbr
rustls = "0.19"

XyLyXyRR avatar Jun 02 '21 11:06 XyLyXyRR

see this relevant comment

https://github.com/rust-embedded/cross/pull/445#issuecomment-659931086

Emilgardis avatar Jun 02 '21 11:06 Emilgardis

This might be somewhat difficult, due to the number of config options and paths we'd need to support, ensuring we merge to options.

For example:

Cargo allows local configuration for a particular package as well as global configuration. It looks for configuration files in the current directory and all parent directories. If, for example, Cargo were invoked in /projects/foo/bar/baz, then the following configuration files would be probed for and unified in this order:

  • /projects/foo/bar/baz/.cargo/config.toml
  • /projects/foo/bar/.cargo/config.toml
  • /projects/foo/.cargo/config.toml
  • /projects/.cargo/config.toml
  • /.cargo/config.toml
  • $CARGO_HOME/config.toml which defaults to:
    • Windows: %USERPROFILE%.cargo\config.toml
    • Unix: $HOME/.cargo/config.toml

We would then need to recursively merge them, and make them available inside the container. It's quite possible we could merge them and then make them available to the container in a custom directory. The issue is we can't overwrite any mount points, so it would have to be the /.cargo/config.toml directory. We also need to process any aliases, parse them along with our CLI flags, determine if the alias is a supported command, and if so run it in the container. We could probably write this directory to our target directory and then make it available at that mount point.

It's definitely doable, just work.

Also, all of these need to support with or without the .toml extension.

Alexhuszagh avatar Jul 02 '22 17:07 Alexhuszagh