Skip to content

Commit f35f630

Browse files
committed
fix(embedded): Don't append hash to bin names
This reduces the chance of hitting file length issues on Windows. The hash existed for sharing a target directory. That code isn't implemented yet and a per-user build cache might remove the need for it, so let's remove it for now and more carefully weigh adding it back in.
1 parent 72c897d commit f35f630

File tree

5 files changed

+20
-68
lines changed

5 files changed

+20
-68
lines changed

Cargo.lock

+1-34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ exclude = [
1313
[workspace.dependencies]
1414
anyhow = "1.0.47"
1515
base64 = "0.21.0"
16-
blake3 = "1.3.3"
1716
bytesize = "1.0"
1817
cargo = { path = "" }
1918
cargo-credential = { version = "0.2.0", path = "credential/cargo-credential" }
@@ -115,7 +114,6 @@ path = "src/cargo/lib.rs"
115114
[dependencies]
116115
anyhow.workspace = true
117116
base64.workspace = true
118-
blake3.workspace = true
119117
bytesize.workspace = true
120118
cargo-platform.workspace = true
121119
cargo-util.workspace = true

deny.toml

-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ allow = [
106106
"MIT-0",
107107
"Apache-2.0",
108108
"BSD-3-Clause",
109-
"BSD-2-Clause",
110109
"MPL-2.0",
111110
"Unicode-DFS-2016",
112111
"CC0-1.0",

src/cargo/util/toml/embedded.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@ pub fn expand_manifest(
2929
}
3030
}
3131
.unwrap_or_default();
32-
let manifest = expand_manifest_(content, &manifest, path, config)
32+
let manifest = expand_manifest_(&manifest, path, config)
3333
.with_context(|| format!("failed to parse manifest at {}", path.display()))?;
3434
let manifest = toml::to_string_pretty(&manifest)?;
3535
Ok(manifest)
3636
}
3737

3838
fn expand_manifest_(
39-
content: &str,
4039
manifest: &str,
4140
path: &std::path::Path,
4241
config: &Config,
@@ -68,8 +67,7 @@ fn expand_manifest_(
6867
.to_string_lossy();
6968
let separator = '_';
7069
let name = sanitize_package_name(file_name.as_ref(), separator);
71-
let hash = hash(content);
72-
let bin_name = format!("{name}{separator}{hash}");
70+
let bin_name = name.clone();
7371
package
7472
.entry("name".to_owned())
7573
.or_insert(toml::Value::String(name));
@@ -141,10 +139,6 @@ fn sanitize_package_name(name: &str, placeholder: char) -> String {
141139
slug
142140
}
143141

144-
fn hash(content: &str) -> blake3::Hash {
145-
blake3::hash(content.as_bytes())
146-
}
147-
148142
/// Locates a "code block manifest" in Rust source.
149143
fn extract_comment(input: &str) -> CargoResult<String> {
150144
let re_crate_comment = regex::Regex::new(
@@ -357,7 +351,7 @@ mod test_expand {
357351
fn test_default() {
358352
snapbox::assert_eq(
359353
r#"[[bin]]
360-
name = "test_a472c7a31645d310613df407eab80844346938a3b8fe4f392cae059cb181aa85"
354+
name = "test"
361355
path = "/home/me/test.rs"
362356
363357
[package]
@@ -379,7 +373,7 @@ strip = true
379373
fn test_dependencies() {
380374
snapbox::assert_eq(
381375
r#"[[bin]]
382-
name = "test_3a1fa07700654ea2e893f70bb422efa7884eb1021ccacabc5466efe545da8a0b"
376+
name = "test"
383377
path = "/home/me/test.rs"
384378
385379
[dependencies]

tests/testsuite/script.rs

+15-21
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ args: []
3535
[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
3636
[COMPILING] echo v0.0.0 ([ROOT]/foo)
3737
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
38-
[RUNNING] `target/debug/echo_[..]`
38+
[RUNNING] `target/debug/echo`
3939
",
4040
)
4141
.run();
@@ -59,7 +59,7 @@ args: []
5959
[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
6060
[COMPILING] echo v0.0.0 ([ROOT]/foo)
6161
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
62-
[RUNNING] `target/debug/echo_[..]`
62+
[RUNNING] `target/debug/echo`
6363
",
6464
)
6565
.run();
@@ -113,7 +113,7 @@ args: []
113113
[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
114114
[COMPILING] echo v0.0.0 ([ROOT]/foo)
115115
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
116-
[RUNNING] `target/debug/echo_[..]`
116+
[RUNNING] `target/debug/echo`
117117
",
118118
)
119119
.run();
@@ -205,7 +205,7 @@ fn main() {
205205
"\
206206
[COMPILING] script v0.0.0 ([ROOT]/foo)
207207
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
208-
[RUNNING] `target/debug/script_[..]`
208+
[RUNNING] `target/debug/script`
209209
",
210210
)
211211
.run();
@@ -237,7 +237,7 @@ fn main() {
237237
[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
238238
[COMPILING] script v0.0.0 ([ROOT]/foo)
239239
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
240-
[RUNNING] `target/debug/script_[..]`
240+
[RUNNING] `target/debug/script`
241241
",
242242
)
243243
.run();
@@ -266,7 +266,7 @@ fn main() {
266266
[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
267267
[COMPILING] script v0.0.0 ([ROOT]/foo)
268268
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
269-
[RUNNING] `target/debug/script_[..]`
269+
[RUNNING] `target/debug/script`
270270
",
271271
)
272272
.run();
@@ -282,7 +282,7 @@ fn main() {
282282
"\
283283
[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
284284
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
285-
[RUNNING] `target/debug/script_[..]`
285+
[RUNNING] `target/debug/script`
286286
",
287287
)
288288
.run();
@@ -300,7 +300,7 @@ fn main() {
300300
[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
301301
[COMPILING] script v0.0.0 ([ROOT]/foo)
302302
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
303-
[RUNNING] `target/debug/script_[..]`
303+
[RUNNING] `target/debug/script`
304304
",
305305
)
306306
.run();
@@ -329,7 +329,7 @@ fn main() {
329329
[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
330330
[COMPILING] script v0.0.0 ([ROOT]/foo)
331331
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
332-
[RUNNING] `target/debug/script_[..]`
332+
[RUNNING] `target/debug/script`
333333
",
334334
)
335335
.run();
@@ -354,7 +354,7 @@ args: ["-NotAnArg"]
354354
[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
355355
[COMPILING] script v0.0.0 ([ROOT]/foo)
356356
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
357-
[RUNNING] `target/debug/script_[..] -NotAnArg`
357+
[RUNNING] `target/debug/script -NotAnArg`
358358
",
359359
)
360360
.run();
@@ -379,7 +379,7 @@ args: ["-NotAnArg"]
379379
[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
380380
[COMPILING] script v0.0.0 ([ROOT]/foo)
381381
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
382-
[RUNNING] `target/debug/script_[..] -NotAnArg`
382+
[RUNNING] `target/debug/script -NotAnArg`
383383
",
384384
)
385385
.run();
@@ -404,7 +404,7 @@ args: ["--help"]
404404
[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
405405
[COMPILING] script v0.0.0 ([ROOT]/foo)
406406
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
407-
[RUNNING] `target/debug/script_[..] --help`
407+
[RUNNING] `target/debug/script --help`
408408
",
409409
)
410410
.run();
@@ -427,14 +427,8 @@ args: []
427427
.with_stderr(
428428
r#"[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
429429
[COMPILING] s-h_w_c_ v0.0.0 ([ROOT]/foo)
430-
[WARNING] crate `s_h_w_c__[..]` should have a snake case name
431-
|
432-
= help: convert the identifier to snake case: `s_h_w_c_[..]`
433-
= note: `#[warn(non_snake_case)]` on by default
434-
435-
[WARNING] `s-h_w_c_` (bin "s-h_w_c__[..]") generated 1 warning
436430
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
437-
[RUNNING] `target/debug/s-h_w_c__[..]`
431+
[RUNNING] `target/debug/s-h_w_c_`
438432
"#,
439433
)
440434
.run();
@@ -472,7 +466,7 @@ fn main() {
472466
[COMPILING] script v1.0.0
473467
[COMPILING] script v0.0.0 ([ROOT]/foo)
474468
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
475-
[RUNNING] `target/debug/script_[..] --help`
469+
[RUNNING] `target/debug/script --help`
476470
",
477471
)
478472
.run();
@@ -509,7 +503,7 @@ fn main() {
509503
[COMPILING] bar v0.0.1 ([ROOT]/foo/bar)
510504
[COMPILING] script v0.0.0 ([ROOT]/foo)
511505
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
512-
[RUNNING] `target/debug/script_[..] --help`
506+
[RUNNING] `target/debug/script --help`
513507
",
514508
)
515509
.run();

0 commit comments

Comments
 (0)