Skip to content
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

Pass cargo configuration flags to docker. #869

Merged
merged 1 commit into from
Jun 26, 2022
Merged

Conversation

Alexhuszagh
Copy link
Contributor

@Alexhuszagh Alexhuszagh commented Jun 26, 2022

Pass cargo configuration flags to docker.

Ensures the following flags are passed to docker:

  • BROWSER
  • CARGO_BUILD_DEP_INFO_BASEDIR
  • CARGO_BUILD_INCREMENTAL
  • CARGO_BUILD_JOBS
  • CARGO_BUILD_RUSTDOCFLAGS
  • CARGO_BUILD_RUSTFLAGS
  • CARGO_CACHE_RUSTC_INFO
  • CARGO_FUTURE_INCOMPAT_REPORT_FREQUENCY
  • CARGO_HTTP_CAINFO
  • CARGO_HTTP_CHECK_REVOKE
  • CARGO_HTTP_DEBUG
  • CARGO_HTTP_LOW_SPEED_LIMIT
  • CARGO_HTTP_MULTIPLEXING
  • CARGO_HTTP_PROXY
  • CARGO_HTTP_SSL_VERSION
  • CARGO_HTTP_TIMEOUT
  • CARGO_HTTP_USER_AGENT
  • CARGO_INCREMENTAL
  • CARGO_NET_GIT_FETCH_WITH_CLI
  • CARGO_NET_OFFLINE
  • CARGO_NET_RETRY
  • HTTP_TIMEOUT
  • HTTPS_PROXY
  • RUSTDOCFLAGS
  • RUSTFLAGS
  • TERM

These are always correct, since these configure how cargo behavior is
supposed to work, but don't rely on any paths on the host filesystem. We also have some future-proofing, since we accept anything starting with CARGO_ except the following variables:

It also ensures the following overridden environment variables are not passed:

  • CARGO_HOME
  • CARGO_TARGET_DIR
  • CARGO_BUILD_TARGET_DIR

And it ensures the following not-yet-supported environment variables are not passed:

  • CARGO_BUILD_RUSTC
  • CARGO_BUILD_RUSTC_WRAPPER
  • CARGO_BUILD_RUSTC_WORKSPACE_WRAPPER
  • CARGO_BUILD_RUSTDOC

@Alexhuszagh
Copy link
Contributor Author

Setting RUSTFLAGS locally on the host should be expected to passthrough to the container, since it's a configuration for cargo itself, and I believe those (and only those) should be passed to the container by default.

@Alexhuszagh Alexhuszagh marked this pull request as draft June 26, 2022 17:12
@Alexhuszagh
Copy link
Contributor Author

Alexhuszagh commented Jun 26, 2022

This actually still needs a few more environment variables to be passed through such as CARGO_BUILD_JOBS.

This is ready for review. The only envvars that might not work are the proxy ones, but it's better to fail hard with these than accept inaccurate configurations.

@Alexhuszagh Alexhuszagh marked this pull request as ready for review June 26, 2022 17:38
CHANGELOG.md Show resolved Hide resolved
Ensures the following flags are passed to docker:
- BROWSER
- CARGO_BUILD_DEP_INFO_BASEDIR
- CARGO_BUILD_INCREMENTAL
- CARGO_BUILD_JOBS
- CARGO_BUILD_RUSTDOCFLAGS
- CARGO_BUILD_RUSTFLAGS
- CARGO_CACHE_RUSTC_INFO
- CARGO_CACHE_RUSTC_INFO
- CARGO_FUTURE_INCOMPAT_REPORT_FREQUENCY
- CARGO_HTTP_CAINFO
- CARGO_HTTP_CHECK_REVOKE
- CARGO_HTTP_DEBUG
- CARGO_HTTP_LOW_SPEED_LIMIT
- CARGO_HTTP_MULTIPLEXING
- CARGO_HTTP_PROXY
- CARGO_HTTP_SSL_VERSION
- CARGO_HTTP_TIMEOUT
- CARGO_HTTP_USER_AGENT
- CARGO_INCREMENTAL
- CARGO_INCREMENTAL
- CARGO_NET_GIT_FETCH_WITH_CLI
- CARGO_NET_OFFLINE
- CARGO_NET_RETRY
- HTTP_TIMEOUT
- HTTPS_PROXY
- RUSTDOCFLAGS
- RUSTFLAGS
- TERM

These are always correct, since these configure how `cargo` behavior is
supposed to work, but don't rely on any paths on the host filesystem. We also have some future-proofing, since we accept anything starting with `CARGO_` except the following variables:

It also ensures the following overridden environment variables are not passed:
- CARGO_HOME
- CARGO_TARGET_DIR
- CARGO_BUILD_TARGET_DIR

And it ensures the following not-yet-supported environment variables are not passed:
- CARGO_BUILD_RUSTC
- CARGO_BUILD_RUSTC_WRAPPER
- CARGO_BUILD_RUSTC_WORKSPACE_WRAPPER
- CARGO_BUILD_RUSTDOC
@Alexhuszagh
Copy link
Contributor Author

bors r=Emilgardis

@Alexhuszagh Alexhuszagh added this to the v0.2.3 milestone Jun 26, 2022
@bors
Copy link
Contributor

bors bot commented Jun 26, 2022

Build succeeded:

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

Successfully merging this pull request may close these issues.

2 participants