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

Use cross in cargo subcommand if called from cross #704

Open
somehowchris opened this issue May 1, 2022 · 4 comments
Open

Use cross in cargo subcommand if called from cross #704

somehowchris opened this issue May 1, 2022 · 4 comments

Comments

@somehowchris
Copy link

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🦄

@reitermarkus
Copy link
Member

Depends on how you want this to work.

  • Either cargo-test-all-features will have to be installed in the Docker image, in which case cross needs to be made aware that this command should run inside Docker, see Subcommand in cargo.rs.

  • Or cargo-test-all-features can be made aware of some environment variable, i.e. CARGO_WRAPPER=cross. In this case, every cross test will spawn a new container, which may not be preferable from a performance perspective.

@somehowchris
Copy link
Author

So the simple answer is: no there is no way to "magically" detect this!?!?

  • Would this mean Subcommand needs to have an additonal entry as Subcommand::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

@Alexhuszagh
Copy link
Contributor

I'm working on adding some passthrough variables to Cross.toml so you can specify additional subcommands to run inside cross. See #716.

@Alexhuszagh
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants