Skip to content

Commit

Permalink
Auto merge of #6812 - ehuss:wasm-example, r=alexcrichton
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
bors committed Apr 2, 2019
2 parents 025b01e + 5d09137 commit 95f9423
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/context/compilation_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ fn compute_metadata<'a, 'cfg>(
if !(unit.mode.is_any_test() || unit.mode.is_check())
&& (unit.target.is_dylib()
|| unit.target.is_cdylib()
|| (unit.target.is_bin() && bcx.target_triple().starts_with("wasm32-")))
|| (unit.target.is_executable() && bcx.target_triple().starts_with("wasm32-")))
&& unit.pkg.package_id().source_id().is_path()
&& __cargo_default_lib_metadata.is_err()
{
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/core/compiler/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
unit.target.clone(),
output.path.clone(),
));
} else if unit.target.is_bin() || unit.target.is_bin_example() {
} else if unit.target.is_executable() {
self.compilation.binaries.push(bindst.clone());
}
}
Expand Down Expand Up @@ -276,7 +276,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
continue;
}

let is_binary = unit.target.is_bin() || unit.target.is_bin_example();
let is_binary = unit.target.is_executable();
let is_test = unit.mode.is_any_test() && !unit.mode.is_check();

if is_binary || is_test {
Expand Down
9 changes: 8 additions & 1 deletion src/cargo/core/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,14 @@ impl Target {
}
}

pub fn is_bin_example(&self) -> bool {
/// Returns `true` if it is a binary or executable example.
/// NOTE: Tests are `false`!
pub fn is_executable(&self) -> bool {
self.is_bin() || self.is_exe_example()
}

/// Returns `true` if it is an executable example.
pub fn is_exe_example(&self) -> bool {
// Needed for --all-examples in contexts where only runnable examples make sense
match self.kind {
TargetKind::ExampleBin => true,
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ fn find_duplicates(
let all_examples: Vec<String> = examples.try_collect().unwrap_or_else(|| {
pkg.targets()
.iter()
.filter(|t| t.is_bin_example())
.filter(|t| t.is_exe_example())
.map(|t| t.name().to_string())
.collect()
});
Expand Down

0 comments on commit 95f9423

Please sign in to comment.