Skip to content
Open
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
28 changes: 22 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tugger-wix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ anyhow = "1.0.68"
duct = "0.13.6"
log = "0.4.17"
once_cell = "1.17.0"
regex = "1.8.4"
simple-file-manifest = "0.11.0"
url = "2.3.1"
uuid = { version = "1.2.2", features = ["v4", "v5"] }
Expand Down
26 changes: 9 additions & 17 deletions tugger-wix/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use {
duct::cmd,
log::warn,
once_cell::sync::Lazy,
regex::Regex,
simple_file_manifest::FileManifest,
std::{
io::{BufRead, BufReader, Write},
Expand All @@ -30,16 +31,15 @@ static WIX_TOOLSET: Lazy<RemoteContent> = Lazy::new(|| RemoteContent {
sha256: "2c1888d5d1dba377fc7fa14444cf556963747ff9a0a289a3599cf09da03b9e2e".to_string(),
});

pub fn path_id(path: &Path) -> String {
// Identifiers may contain ASCII characters A-Z, a-z, digits, underscores (_), or periods (.)
let re = Regex::new(r"[^A-Za-z0-9_\.]").unwrap();
re.replace_all(&path.to_string_lossy().replace('\\', ".").replace('/', "."), "_").to_string()
}

/// Compute the `Id` of a directory.
pub fn directory_to_id(prefix: &str, path: &Path) -> String {
format!(
"{}.dir.{}",
prefix,
path.to_string_lossy()
.replace('\\', "/")
.replace('/', ".")
.replace('-', "_")
)
format!("{}.dir.{}", prefix, path_id(path))
}

const GUID_NAMESPACE: &str = "https://github.com/indygreg/PyOxidizer/tugger/wix";
Expand Down Expand Up @@ -88,15 +88,7 @@ pub fn file_id(prefix: &str, path: &Path) -> String {
}

pub fn component_group_id(prefix: &str, path: &Path) -> String {
format!(
"{}.group.{}",
prefix,
path.display()
.to_string()
.replace('\\', "/")
.replace('/', ".")
.replace('-', "_")
)
format!("{}.group.{}", prefix, path_id(path))
}

/// Convert a `FileManifest` to WiX XML defining those files.
Expand Down