New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add target directory parameter --target-dir #5393

Merged
merged 2 commits into from Apr 24, 2018

Conversation

Projects
None yet
7 participants
@smithsps
Contributor

smithsps commented Apr 19, 2018

Implements: #5308

Adds a target directory parameter, that acts in the same manner as the environment variable CARGO_TARGET_DIR, to the following subcommands:

  • bench
  • build
  • check
  • clean
  • doc
  • package
  • publish
  • run
  • rustc
  • rustdoc
  • test
@alexcrichton

This comment has been minimized.

Member

alexcrichton commented Apr 20, 2018

@@ -70,6 +70,8 @@ pub struct Config {
cache_rustc_info: bool,
/// Creation time of this config, used to output the total build time
creation_time: Instant,
/// Target Directory via resolved Cli parameter
cli_target_dir: Option<Filesystem>,

This comment has been minimized.

@matklad

matklad Apr 21, 2018

Member

I think that instead of cli_target_dir, we can store computed target_dir. That is, we can change fn target_dir() to

fn target_dir(&self) -> Option<FileSystem> { self.target_dir.clone() }

and instead move all logic from it to configure method. I think that would be slightly more clear, because we'll only store something, instead of both storing and computing on the fly. What do you think?

This comment has been minimized.

@smithsps

smithsps Apr 24, 2018

Contributor

Agreed!

I had some problems having the logic in configure as it would change some error messages with bad configs. But I was able to minimize it to just a bad_config::invalid_global_config situation, so it should be good.

let exe_name = format!("foo{}", env::consts::EXE_SUFFIX);
assert_that(
p.cargo("build").arg("--target-dir").arg("foo/target"),

This comment has been minimized.

@matklad

matklad Apr 21, 2018

Member

We've recently added a nicer API for this: p.cargo("build --target-dir foo/target").

@matklad matklad self-assigned this Apr 21, 2018

@matklad matklad added the relnotes label Apr 21, 2018

@bors

This comment has been minimized.

Contributor

bors commented Apr 22, 2018

☔️ The latest upstream changes (presumably #5404) made this pull request unmergeable. Please resolve the merge conflicts.

@matklad

This comment has been minimized.

Member

matklad commented Apr 24, 2018

@bors r+

Thanks!

@bors

This comment has been minimized.

Contributor

bors commented Apr 24, 2018

📌 Commit 0b530c3 has been approved by matklad

@bors

This comment has been minimized.

Contributor

bors commented Apr 24, 2018

⌛️ Testing commit 0b530c3 with merge 7debd81...

bors added a commit that referenced this pull request Apr 24, 2018

Auto merge of #5393 - smithsps:master, r=matklad
Add target directory parameter --target-dir

Implements: #5308

Adds a target directory parameter, that acts in the same manner as the environment variable `CARGO_TARGET_DIR`, to the following subcommands:
- `bench`
- `build`
- `check`
- `clean`
- `doc`
- `package`
- `publish`
- `run`
- `rustc`
- `rustdoc`
- `test`
@bors

This comment has been minimized.

Contributor

bors commented Apr 24, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: matklad
Pushing 7debd81 to master...

@bors bors merged commit 0b530c3 into rust-lang:master Apr 24, 2018

2 of 3 checks passed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
@smithsps

This comment has been minimized.

Contributor

smithsps commented Apr 24, 2018

@matklad Thanks for the mentoring, it was a great learning experience!

nrc added a commit to nrc/cargo that referenced this pull request May 3, 2018

Revert part to rust-lang#5393
Commit 0b530c3 (which this commit mostly reverts) did some refactoring around the `target_dir` function. However, it introduced a bug because it meant that where `CARGO_TARGET_DIR` was specified but `--target-dir` was not, the value from `CARGO_TARGET_DIR` was ignored.

bors added a commit that referenced this pull request May 3, 2018

Auto merge of #5465 - nrc:rls-cargo, r=matklad
Revert part of #5393

Commit 0b530c3 (which this commit mostly reverts) did some refactoring around the `target_dir` function. However, it introduced a bug because it meant that where `CARGO_TARGET_DIR` was specified but `--target-dir` was not, the value from `CARGO_TARGET_DIR` was ignored.

r? @matklad

This bug is causing RLS tests to fail in the Rust repo (see rust-lang/rust#50379 (comment)) because on Linux, the src directory is write-protected. This bug causes Rust build's `CARGO_TARGET_DIR` to be ignored by the RLS tests so that they write files into the src directory (CWD) rather than the target directory.
@PSeitz

This comment has been minimized.

PSeitz commented Jun 22, 2018

was install left out intentionally?

@ignatenkobrain

This comment has been minimized.

Contributor

ignatenkobrain commented Jun 22, 2018

I miss commandline option for cargo too.

@cuviper

This comment has been minimized.

Member

cuviper commented Jun 22, 2018

I think install deserves an option too, but it could be confusing that install --target-dir DIR would specify the build target path, versus the installation path (which is --root).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment