Skip to content

Add target directory parameter --target-dir#5393

Merged
bors merged 2 commits intorust-lang:masterfrom
smithsps:master
Apr 24, 2018
Merged

Add target directory parameter --target-dir#5393
bors merged 2 commits intorust-lang:masterfrom
smithsps:master

Conversation

@smithsps
Copy link
Copy Markdown
Contributor

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
Copy link
Copy Markdown
Member

r? @matklad

Comment thread src/cargo/util/config.rs Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/testsuite/build.rs Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Release-note worthy label Apr 21, 2018
@bors
Copy link
Copy Markdown
Contributor

bors commented Apr 22, 2018

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

@matklad
Copy link
Copy Markdown
Contributor

matklad commented Apr 24, 2018

@bors r+

Thanks!

@bors
Copy link
Copy Markdown
Contributor

bors commented Apr 24, 2018

📌 Commit 0b530c3 has been approved by matklad

@bors
Copy link
Copy Markdown
Contributor

bors commented Apr 24, 2018

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

bors added a commit that referenced this pull request Apr 24, 2018
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
Copy link
Copy Markdown
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
@smithsps
Copy link
Copy Markdown
Contributor Author

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

nrc pushed a commit to nrc/cargo that referenced this pull request May 3, 2018
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.
@PSeitz
Copy link
Copy Markdown
Contributor

PSeitz commented Jun 22, 2018

was install left out intentionally?

@igor-raits
Copy link
Copy Markdown
Contributor

I miss commandline option for cargo too.

@cuviper
Copy link
Copy Markdown
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

Labels

relnotes Release-note worthy

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants