Skip to content

Commit 95f9423

Browse files
committed
Auto merge of #6812 - ehuss:wasm-example, r=alexcrichton
Don't include metadata in wasm binary examples. This removes the metadata hash from wasm example binaries, and consequently also includes the `.wasm` files in the artifact JSON message. Closes #6810. I renamed a method and added a new one to maybe make things a little clearer. This cannot be easily tested (see #4973).
2 parents 025b01e + 5d09137 commit 95f9423

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

src/cargo/core/compiler/context/compilation_files.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ fn compute_metadata<'a, 'cfg>(
444444
if !(unit.mode.is_any_test() || unit.mode.is_check())
445445
&& (unit.target.is_dylib()
446446
|| unit.target.is_cdylib()
447-
|| (unit.target.is_bin() && bcx.target_triple().starts_with("wasm32-")))
447+
|| (unit.target.is_executable() && bcx.target_triple().starts_with("wasm32-")))
448448
&& unit.pkg.package_id().source_id().is_path()
449449
&& __cargo_default_lib_metadata.is_err()
450450
{

src/cargo/core/compiler/context/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
170170
unit.target.clone(),
171171
output.path.clone(),
172172
));
173-
} else if unit.target.is_bin() || unit.target.is_bin_example() {
173+
} else if unit.target.is_executable() {
174174
self.compilation.binaries.push(bindst.clone());
175175
}
176176
}
@@ -276,7 +276,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
276276
continue;
277277
}
278278

279-
let is_binary = unit.target.is_bin() || unit.target.is_bin_example();
279+
let is_binary = unit.target.is_executable();
280280
let is_test = unit.mode.is_any_test() && !unit.mode.is_check();
281281

282282
if is_binary || is_test {

src/cargo/core/manifest.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,14 @@ impl Target {
814814
}
815815
}
816816

817-
pub fn is_bin_example(&self) -> bool {
817+
/// Returns `true` if it is a binary or executable example.
818+
/// NOTE: Tests are `false`!
819+
pub fn is_executable(&self) -> bool {
820+
self.is_bin() || self.is_exe_example()
821+
}
822+
823+
/// Returns `true` if it is an executable example.
824+
pub fn is_exe_example(&self) -> bool {
818825
// Needed for --all-examples in contexts where only runnable examples make sense
819826
match self.kind {
820827
TargetKind::ExampleBin => true,

src/cargo/ops/cargo_install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ fn find_duplicates(
475475
let all_examples: Vec<String> = examples.try_collect().unwrap_or_else(|| {
476476
pkg.targets()
477477
.iter()
478-
.filter(|t| t.is_bin_example())
478+
.filter(|t| t.is_exe_example())
479479
.map(|t| t.name().to_string())
480480
.collect()
481481
});

0 commit comments

Comments
 (0)