|
1 |
| -use anyhow::Context; |
2 |
| -use cargo_remark::RustcSourceRoot; |
3 | 1 | use std::path::{Path, PathBuf};
|
4 | 2 | use std::process::{Command, Stdio};
|
5 | 3 |
|
6 |
| -use cargo_remark::utils::io::ensure_directory; |
| 4 | +use anyhow::Context; |
7 | 5 |
|
8 | 6 | use cargo_remark::utils::cli::cli_format_path;
|
| 7 | +use cargo_remark::utils::io::ensure_directory; |
| 8 | +use cargo_remark::RustcSourceRoot; |
9 | 9 |
|
10 | 10 | pub mod version;
|
11 | 11 |
|
@@ -53,8 +53,9 @@ pub fn run_cargo(subcmd: CargoSubcommand, cargo_args: Vec<String>) -> anyhow::Re
|
53 | 53 | }
|
54 | 54 | };
|
55 | 55 |
|
| 56 | + // Use CARGO_ENCODED_RUSTFLAGS to make sure that paths with spaces work. |
56 | 57 | let flags = format!(
|
57 |
| - "-Cremark=all -Zremark-dir={} -Cdebuginfo=1", |
| 58 | + "-Cremark=all\u{001f}-Zremark-dir={}\u{001f}-Cdebuginfo=1", |
58 | 59 | yaml_dir.display()
|
59 | 60 | );
|
60 | 61 | set_cargo_env(&mut cmd, &flags);
|
@@ -92,12 +93,13 @@ pub fn get_rustc_source_root() -> anyhow::Result<RustcSourceRoot> {
|
92 | 93 | }
|
93 | 94 |
|
94 | 95 | fn set_cargo_env(command: &mut Command, flags: &str) {
|
95 |
| - use std::fmt::Write; |
96 |
| - |
97 |
| - let mut rustflags = std::env::var("RUSTFLAGS").unwrap_or_default(); |
98 |
| - write!(&mut rustflags, " {}", flags).unwrap(); |
| 96 | + let mut rustflags = std::env::var("CARGO_ENCODED_RUSTFLAGS").unwrap_or_default(); |
| 97 | + if !rustflags.is_empty() { |
| 98 | + rustflags.push('\u{001f}'); |
| 99 | + } |
| 100 | + rustflags.push_str(flags); |
99 | 101 |
|
100 |
| - command.env("RUSTFLAGS", rustflags); |
| 102 | + command.env("CARGO_ENCODED_RUSTFLAGS", rustflags); |
101 | 103 | }
|
102 | 104 |
|
103 | 105 | #[derive(Debug, Default)]
|
|
0 commit comments