Skip to content

Commit

Permalink
Fix cross-compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Jan 27, 2024
1 parent b6d9ea6 commit 695811a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

### Fixedw
### Fixed

* Passing `--target` to build command when cross-compiling.

### Changed

Expand Down
14 changes: 14 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,20 @@ fn build_command(
cmd.arg("--edition").arg(&*edition);
}

if let Some(target) = &config.target {
// Adding a `--target` arg to calls to Cargo will cause target folders
// to create a target-specific sub-folder. We can avoid that by just
// not passing a `--target` arg if its the same as the host.
if target
!= config
.host
.as_ref()
.expect("host should have been filled in")
{
cmd.arg("--target").arg(target);
}
}

// False positive in miri, our `map` uses a ref pattern to get the references to the tuple fields instead
// of a reference to a tuple
#[allow(clippy::map_identity)]
Expand Down

0 comments on commit 695811a

Please sign in to comment.