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

Manifest mode #42

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ Cargo.lock
target/
.vscode/
vcp/

.DS_Store

.idea/
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there are okay to add, though I would prefer to see them in their own PR.

Copy link
Author

@SwishSwushPow SwishSwushPow Aug 26, 2021

Choose a reason for hiding this comment

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

Yes I can remove these changes from this PR and open a separate one.

Edit: #43

13 changes: 11 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,17 @@ fn find_vcpkg_target(cfg: &Config, target_triplet: &TargetTriplet) -> Result<Vcp
let vcpkg_root = try!(find_vcpkg_root(&cfg));
try!(validate_vcpkg_root(&vcpkg_root));

let mut base = vcpkg_root.clone();
base.push("installed");
let cargo_base_path =
PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("we use cargo, this exists"));
let is_manifest_mode = env::var_os("VCPKGRS_IGNORE_MANIFEST_MODE").is_none()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for doing this.

Thinking more about this, I think perhaps this is the wrong approach. Exposing another environment variable here to disable manifest mode in the presence of the json file seems overly complicating to add to the exposed interface, feels like a "you aren't going to need it" sort of feature.

I think perhaps a more useful approach would be to defer back to your original change without the environment variable override, but we add some sanity checks at the end here to verify that the target installed directory exists? That way, we can give a useful error message depending on whether manifest mode or not was used (telling the user to run either cargo vcpkg install for non-manifest mode, and vcpkg(.exe) install when manifest mode is detected), and otherwise we just make it silently work.

What do you think?

Copy link
Author

Choose a reason for hiding this comment

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

I initially introduced this variable because of your comment on the issue that it should do the right thing by default but could also be disabled 😅

Just to make sure I understand you correctly: You suggest to add some sanity checks together with having VCPKGRS_MANIFEST_MODE. If the user sets this variable, we check if that makes sense and, if it doesn't, we return an error. That works for me as well, but then the user would always have to set the variable.

(sry I could only reply now, I was on holiday for the past few days)

&& Path::exists(cargo_base_path.join("vcpkg.json").as_path());

let mut base = if !is_manifest_mode {
vcpkg_root.join("installed")
} else {
cargo_base_path.join("vcpkg_installed")
};

let status_path = base.join("vcpkg");

base.push(&target_triplet.triplet);
Expand Down