Skip to content

Commit

Permalink
Merge #348
Browse files Browse the repository at this point in the history
348: Allow writing `Cargo.toml` in project directory. r=therealprof a=reitermarkus

The project directory was previously deliberately mounted as read-only since “well behaved crates should only ever write to `$OUT_DIR` and never modify `$CARGO_MANIFEST_DIR`”.  That however, breaks the `--locked` flag and is not worth the additional complexity.

Fixes #346.

Co-authored-by: Markus Reiter <me@reitermark.us>
  • Loading branch information
bors[bot] and reitermarkus committed Nov 21, 2019
2 parents 7676a62 + 83778cb commit 9687401
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,6 @@ $ QEMU_STRACE=1 cross run --target aarch64-unknown-linux-gnu
work because `cross` use docker containers only mounts the Cargo project so
the container doesn't have access to the rest of the filesystem.

- `cross` will mount the Cargo project as READ ONLY. Thus, if any crate attempts
to modify its “source”, the build will fail. Well behaved crates should only
ever write to `$OUT_DIR` and never modify `$CARGO_MANIFEST_DIR` though.

## License

Licensed under either of
Expand Down
12 changes: 1 addition & 11 deletions src/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,8 @@ pub fn run(target: &Target,
};
cmd.args(args);

// We create/regenerate the lockfile on the host system because the Docker
// container doesn't have write access to the root of the Cargo project
let cargo_toml = root.join("Cargo.toml");

let runner = None;

Command::new("cargo").args(&["fetch",
"--manifest-path",
&cargo_toml.display().to_string()])
.run(verbose)
.chain_err(|| "couldn't generate Cargo.lock")?;

let mut docker = docker_command("run")?;

if let Some(toml) = toml {
Expand Down Expand Up @@ -144,7 +134,7 @@ pub fn run(target: &Target,
.args(&["-v", &format!("{}:/cargo:Z", cargo_dir.display())])
// Prevent `bin` from being mounted inside the Docker container.
.args(&["-v", "/cargo/bin"])
.args(&["-v", &format!("{}:/project:Z,ro", root.display())])
.args(&["-v", &format!("{}:/project:Z", root.display())])
.args(&["-v", &format!("{}:/rust:Z,ro", sysroot.display())])
.args(&["-v", &format!("{}:/target:Z", target_dir.display())])
.args(&["-w", "/project"]);
Expand Down

0 comments on commit 9687401

Please sign in to comment.