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

Allow users to ignore config files in the package. #936

Closed
wants to merge 1 commit into from

Conversation

Alexhuszagh
Copy link
Contributor

Adds the CROSS_IGNORE_CARGO_CONFIG environment variable, which if set will mount an anoymous data volume for each .cargo subdirectory for the current directory and any parent directories up to the workspace root. If the build is called outside the workspace root or at the workspace root, only mount at the $PWD/.cargo.

Partially addresses #621.

@Alexhuszagh Alexhuszagh requested a review from a team as a code owner July 11, 2022 15:41
@Alexhuszagh Alexhuszagh changed the title All users to ignore config files in the package. Allow users to ignore config files in the package. Jul 11, 2022
src/config.rs Outdated Show resolved Hide resolved
src/docker/shared.rs Outdated Show resolved Hide resolved
@Alexhuszagh Alexhuszagh marked this pull request as draft July 11, 2022 18:10
@Alexhuszagh Alexhuszagh force-pushed the ignore_config branch 2 times, most recently from bb1f3d7 to 87d650b Compare July 11, 2022 21:00
@Alexhuszagh
Copy link
Contributor Author

Alexhuszagh commented Jul 11, 2022

I've moved the configuration to Cross.toml, but this still needs to create the .cargo directories before being mounted by Docker (since Docker creates them even for anonymous data volumes), or better yet, check if they exist and only mount them if they do.

@Alexhuszagh Alexhuszagh marked this pull request as ready for review July 11, 2022 22:15
paths: &DockerPaths,
ignore_cargo_config: bool,
) -> Result<()> {
let check_mount =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This checks if the path exists on the host (canonicalized), and only if it does, mounts it. This avoids any permission issues or creating undesired directories.

src/docker/shared.rs Outdated Show resolved Hide resolved
let mount_root = Path::new(paths.mount_root());
let mount_cwd = Path::new(paths.mount_cwd());
check_mount(docker, &paths.cwd, mount_cwd, Path::new(""))?;
// CWD isn't guaranteed to be a subdirectory of the mount root.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we've removed /project, this changes the logic here, so we don't necessarily have a relpath to the workspace root.

Adds the `CROSS_BUILD_ENV_IGNORE_CARGO_CONFIG` environment variable, which if set
will mount an anoymous data volume for each `.cargo` subdirectory for
the current directory and any parent directories up to the workspace
root. If the build is called outside the workspace root or at the
workspace root, only mount at the `$PWD/.cargo`.
@Alexhuszagh
Copy link
Contributor Author

I'm likely going to merge this into a PR with #931, since the two are complimentary and I also need that to support allowing full passing of Cargo configuration files to cross. So, we can therefore have the default behavior (CARGO_HOME and the project config files are passed), the behavior where everything except CARGO_HOME is skipped, and allowing everything to be included.

@Alexhuszagh
Copy link
Contributor Author

Superseded by #931, which now includes this functionality.

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