Skip to content

Commit

Permalink
Support override vcpkg installed dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielmelody committed Feb 1, 2023
1 parent 71da69e commit 1607ba8
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ pub struct Config {
/// should DLLs be copied to OUT_DIR?
copy_dlls: bool,

/// override vcpkg installed path instead of using VCPKG_ROOT/installed
vcpkg_installed_dir: Option<PathBuf>,

/// override VCPKG_ROOT environment variable
vcpkg_root: Option<PathBuf>,

Expand Down Expand Up @@ -390,8 +393,11 @@ 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 mut base = cfg
.vcpkg_installed_dir
.clone()
.unwrap_or(vcpkg_root.join("installed"));

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

base.push(&target_triplet.triplet);
Expand Down Expand Up @@ -721,12 +727,13 @@ fn load_ports(target: &VcpkgTarget) -> Result<BTreeMap<String, Port>, Error> {
// load updates to the status file that have yet to be normalized
let status_update_dir = target.status_path.join("updates");

let paths = try!(
fs::read_dir(status_update_dir).map_err(|e| Error::VcpkgInstallation(format!(
"could not read status file updates dir: {}",
let paths = try!(fs::read_dir(status_update_dir.clone()).map_err(
|e| Error::VcpkgInstallation(format!(
"could not read status file updates dir ({}): {}",
status_update_dir.display(),
e
)))
);
))
));

// get all of the paths of the update files into a Vec<PathBuf>
let mut paths = try!(paths
Expand Down Expand Up @@ -1056,6 +1063,12 @@ impl Config {
self
}

/// Specify vcpkg installed directory. This is useful for manifest mode and custom vcpkg installation.
pub fn vcpkg_installed_dir(&mut self, vcpkg_installed_dir: PathBuf) -> &mut Config {
self.vcpkg_installed_dir = Some(vcpkg_installed_dir);
self
}

/// Define which path to use as vcpkg root overriding the VCPKG_ROOT environment variable
/// Default to `None`, which means use VCPKG_ROOT or try to find out automatically
pub fn vcpkg_root(&mut self, vcpkg_root: PathBuf) -> &mut Config {
Expand Down

0 comments on commit 1607ba8

Please sign in to comment.