Closed qqwa closed 6 years ago
Thanks for the PR! Support for cargo rustc
building is something that we should definitely do.
I'm not sure if it will break anything for others who would use cargo build instead of cargo rustc
I don't know either. So how about adding a separate cargo xrustc
executable that invokes cargo rustc
? This would have the big advantage that we just need to remove an x
when cargo
becomes able to build the sysroot itself.
Fine by me. I pushed a commit which splits it in two binaries. We probably want to move more stuff from the binaries to the lib. And minimize the imports, currently it's for all the same, just that the binaries also include xargo_lib.
I left the main as it was, because its only error handling, which shouldn't change that much anyways.
And the help text for cargo xrustc
will use the same as cargo xbuild
. Should i add new one for xrustc or can we use something with !format
?
This would work to show the correct command name.
pub fn main() {
fn show_backtrace() -> bool {
env::var("RUST_BACKTRACE").as_ref().map(|s| &s[..]) == Ok("1")
}
match xargo_lib::run("xrustc", &format!(include_str!("help.txt"), "xrustc"), true) {
Or inside the run function, something like this:
pub fn run(command_name: &str, help: &str, use_rustc: bool) -> Result<Option<ExitStatus>> {
use cli::Command;
let (command, args) = cli::args(command_name)?;
match command {
Command::Build => Ok(Some(build(args, use_rustc)?)),
Command::Help => {
print!("{}", help.replace("{command_name}", command_name);
Ok(None)
}
Thanks for the update!
I would like to move the main
function to the lib too, e.g. as main_common(command_name: &str)
, because maybe we want to change the error handling. And it's an easy way to avoid the code duplication.
It would be cool to use a common help.txt
, but note that we would also need to replace the cargo build
instances in the text.
I also removed the use_rustc
bool and just pass the command name to cargo.
The help message should now also be correct for any command.
PS: I can squash the commits before you merge it.
@qqwa Could you also update the title of this PR?
You can squash it^^
Thanks a lot!
Released as version 0.4.8
Some options can only be passed to rustc with arguments e.g.
--emit=link=path/exe
. I'm not sure if it will break anything for others who would usecargo build
instead ofcargo rustc