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

color option does not work #68

Open
arjanmels opened this issue May 1, 2020 · 3 comments
Open

color option does not work #68

arjanmels opened this issue May 1, 2020 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@arjanmels
Copy link

The --color (never, always) does not work on xbuild (cargo-xbuild 0.5.28)

@phil-opp phil-opp added the help wanted Extra attention is needed label May 6, 2020
@phil-opp
Copy link
Member

phil-opp commented May 6, 2020

Thanks for reporting! The reason that this doesn't properly work is that we do two cargo invocations behind the scenes. The first invocation is for building the sysroot crates (core, alloc, etc.), while the second invocation builds the actual project. We currently only pass given arguments to the second cargo invocation because you normally don't want to change the sysroot building command.

I think the best way to fix this would be to special-case the --color flag to also apply it to the sysroot build (but not other flags). We already do something similar for the --verbose flag, so it shouldn't be too difficult to add something like this. The relevant parts of the code for the --verbose flag are:

cargo-xbuild/src/sysroot.rs

Lines 121 to 123 in 10287ff

if verbose {
cmd.arg("-v");
}

let verbose = args.verbose();

cargo-xbuild/src/cli.rs

Lines 106 to 111 in 10287ff

if arg == "--verbose" || arg == "-v" || arg == "-vv" {
if let Some(Verbosity::Quiet) = verbosity {
return Err("cannot set both --verbose and --quiet".into());
}
verbosity = Some(Verbosity::Verbose)
}

cargo-xbuild/src/cli.rs

Lines 145 to 147 in 10287ff

pub fn verbose(&self) -> bool {
self.verbosity == Some(Verbosity::Verbose)
}

Handling of the color flag could be added in a similar way. I don't have the time to implement this myself right now, but pull requests are welcome!


As a side node, have you tried to directly use cargo's new -Z build-std flag instead of cargo-xbuild. A simple way to try it out is to create an alias named x in a .cargo/config:

[alias]
x = "-Z build-std=core"

Now you should be able to run cargo x build instead of cargo xbuild. This should fix your --color problem since now you're using cargo directly.

@arjanmels
Copy link
Author

arjanmels commented May 8, 2020

Thanks for the hints, will see if I find the time for a pull request.

I tried the build-std=core flag, but get an error during compile on "extern crate alloc;" in the linked_list_allocator lib.rs file.

I got the -Z option working by using -Z build-std=core,alloc.

@phil-opp
Copy link
Member

phil-opp commented May 8, 2020

I got the -Z option working by using -Z build-std=core,alloc.

Sorry, I forgot about alloc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants