Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changes/append-rc-content-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri-build": minor:feat
---

Allow users to append extra `.rc` content by `append_rc_content` in `WindowsAttributes`.
16 changes: 16 additions & 0 deletions crates/tauri-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ pub struct WindowsAttributes {
///
/// [application manifest]: https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests
app_manifest: Option<String>,
/// A series of strings containing additional .rc content to be appended to the generated resource file on Windows.
append_rc_content: Vec<String>,
}

impl Default for WindowsAttributes {
Expand All @@ -256,6 +258,7 @@ impl WindowsAttributes {
Self {
window_icon_path: Default::default(),
app_manifest: Some(include_str!("windows-app-manifest.xml").into()),
append_rc_content: Vec::new(),
}
}

Expand All @@ -265,6 +268,7 @@ impl WindowsAttributes {
Self {
app_manifest: None,
window_icon_path: Default::default(),
append_rc_content: Vec::new(),
}
}

Expand Down Expand Up @@ -334,6 +338,14 @@ impl WindowsAttributes {
self.app_manifest = Some(manifest.as_ref().to_string());
self
}

/// Append additional .rc content to the generated resource file on Windows.
/// This can be called multiple times to append multiple contents.
Comment thread
Kokoro2336 marked this conversation as resolved.
Resolved
#[must_use]
pub fn append_rc_content<S: Into<String>>(mut self, content: S) -> Self {
self.append_rc_content.push(content.into());
self
}
}

/// The attributes used on the build.
Expand Down Expand Up @@ -613,6 +625,10 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
res.set_manifest(&manifest);
}

for content in attributes.windows_attributes.append_rc_content {
res.append_rc_content(&content);
}

if let Some(version_str) = &config.version {
if let Ok(v) = Version::parse(version_str) {
let version = (v.major << 48) | (v.minor << 32) | (v.patch << 16);
Expand Down
Loading