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

Added support for target-dir in config file. #177

Closed
wants to merge 1 commit into from

Conversation

Nils-TUD
Copy link
Contributor

@Nils-TUD Nils-TUD commented Nov 9, 2017

So far, xargo ignored the target-dir key in the config file. This caused the copy of the artifacts to the sysroot to fail if this key was used, because xargo expected them in the wrong place. This patch fixes this problem.

@homunkulus
Copy link
Contributor

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

@RalfJung
Copy link
Collaborator

This looks reasonable (and sorry that it took so long to get you any feedback). Are you still interested in landing this?

src/sysroot.rs Outdated
None => util::cp_r(
&td.join("target").join(cmode.triple()).join(profile()).join("deps"),
&dst
),
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a lot of shared code between the two branches here, could you factor that out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's true, I'll improve that.

@Nils-TUD
Copy link
Contributor Author

Yes, I will rebase it onto the current master.

@@ -153,12 +159,13 @@ version = "0.0.0"
}

// Copy artifacts to Xargo sysroot
let base_dir = match target_dir {
Some(dir) => config.unwrap().root().join(dir),
Copy link
Collaborator

@RalfJung RalfJung Sep 13, 2019

Choose a reason for hiding this comment

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

If you fold the two new matches into one here, the code becomes shorter and you avoid an unwrap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, because I want to do td.join("target") if config is None or config.target_dir()? is None. So the only way I can think of to avoid the unwrap is to have nested matches and have td.join("target") twice. Not sure if that's better.

Copy link
Collaborator

@RalfJung RalfJung Sep 14, 2019

Choose a reason for hiding this comment

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

Hm I see.
Either way please move let target_dir down to the other dir stuff here.

But then, wouldn't this work?

let target_dir = match config {
  Some(c) => c.target_dir()?.map(|d| c.root().join(d)),
  None => None,
};
let target_dir = target_dir.unwrap_or_else(|| td.join("target"));

That's equivalent to your code, right?
However, it makes me wonder if this is really what we want. This directory will be outside the tempdir, right? We'll be spilling files into the user's dir and they might get mixed up with other stuff? Shouldn't this be more like td.join(target_dir) or so?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good idea. Yes, that's equivalent and better, I'll use that.

From my point of view it's the desired behavior. Without setting the target-dir, the files are put into a temp directory. With the target-dir, the files are put into that directory, relative to the root directory of the project. So for example, you can set it to "build/sysroot" and then all files go into "<yourproject>/build/sysroot".

Copy link
Collaborator

Choose a reason for hiding this comment

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

What is target-dir usually used for? Isn't that to change target to something else? So as a user I would expect by projects stuff to be put there, but not the sysroot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm, I created the patch quite some time ago, but I remember that without target-dir, Xargo was putting all kinds of things in the usual target directory. I just tested it again and actually, using a temp directory for the sysroot and using CARGO_TARGET_DIR to store the project stuff at a different place, looks fine.

Maybe Xargo behaves differently now or I'm missing something. However, I would suggest that we close the PR for now and I report back if there still is a good reason for target-dir.

Copy link
Collaborator

Choose a reason for hiding this comment

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

All right. Thanks a lot for looking into this!

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

Successfully merging this pull request may close these issues.

3 participants