cross
cross copied to clipboard
Use cross in cargo subcommand if called from cross
Hey :)
So I like cross and I'm trying to add some functionallity to cargo-all-features
to use cross.
Now with the current setup the cargo subcommand can be used like cargo test-all-features
. This will execute cargo
which will run the cargo-test-all-features
binary, this will do its thing and call cargo test
. Nice, now I can check if all feature combinations are valid.
Since the introduction of things like aarch64
and the lack of gh-actions of these platform I got to use cross
as its easy to setup, easy to use. Now with the current setup cross test-all-features
would look something like this: cross
-> cargo
-> cargo test-all-features
-> cargo test
. This is due as neither the CARGO
env variable is set to the toolchain provided to the cross
and I do not see a way to detect if the original caller was cross
. (Couldn't find the statement but something along the lines of "no additional flags are set" was in the readme some time ago)
Now is there or could there be a way to detect this? So instead of calling cargo test
I could call cross test
without any added flags
Verry much apprichiate comments, help and guidance🦄
Depends on how you want this to work.
-
Either
cargo-test-all-features
will have to be installed in the Docker image, in which casecross
needs to be made aware that this command should run inside Docker, seeSubcommand
incargo.rs
. -
Or
cargo-test-all-features
can be made aware of some environment variable, i.e.CARGO_WRAPPER=cross
. In this case, everycross test
will spawn a new container, which may not be preferable from a performance perspective.
So the simple answer is: no there is no way to "magically" detect this!?!?
- Would this mean
Subcommand
needs to have an additonal entry asSubcommand::Others
doesn't run inside a container, so I would guess its not the solution as any third party subcommands could be in there and there would be no guarantee to the user that it would be actually available - This goes along the lines of what my current PR at
cargo-all-features
does, instead of an env variable it uses a flag
I'm working on adding some passthrough variables to Cross.toml
so you can specify additional subcommands to run inside cross. See #716.
So for adding for very partial support of this (setting CARGO
to cross
isn't a great idea, since cargo
will override and ignore that environment variable), we're going to be adding the ability to use Cargo aliases and other configuration settings, so if your subcommand is an alias rather than a binary, this would be supported. I'm still working on actual subcommand support.