(cargo: &Build, options: &CargoCompilerOptions)
| 8 | impl Cargo { |
| 9 | #[tracing::instrument(target = "cargo_lambda")] |
| 10 | pub(crate) async fn command(cargo: &Build, options: &CargoCompilerOptions) -> Result<Command> { |
| 11 | tracing::debug!("compiling with Cargo"); |
| 12 | |
| 13 | let (subcommand, extra_args) = cargo_subcommand(options); |
| 14 | |
| 15 | let mut cmd = if let Some(subcommand) = subcommand { |
| 16 | let cmd = cargo.command(); |
| 17 | let mut args = cmd.get_args().collect::<VecDeque<&OsStr>>(); |
| 18 | // remove the `build` subcommand from the front. |
| 19 | let _ = args.pop_front(); |
| 20 | |
| 21 | let mut cmd = Command::new("cargo"); |
| 22 | cmd.args(subcommand); |
| 23 | cmd.args(args); |
| 24 | |
| 25 | cmd |
| 26 | } else { |
| 27 | cargo.command() |
| 28 | }; |
| 29 | |
| 30 | if let Some(extra) = extra_args { |
| 31 | cmd.args(extra); |
| 32 | } |
| 33 | Ok(cmd) |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | fn cargo_subcommand(options: &CargoCompilerOptions) -> (Option<Vec<String>>, Option<Vec<String>>) { |
no test coverage detected