Skip to content

Commit b7a0ff0

Browse files
feat(windows): append .rc content support. (#15263)
* feat(windows): append .rc content support. * chore: update api comments. * chore: add change file. * Update crates/tauri-build/src/lib.rs Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com> * fix: appending logic. * chore: update comments. --------- Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com>
1 parent 5ec1d5a commit b7a0ff0

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-build": minor:feat
3+
---
4+
5+
Allow users to append extra `.rc` content by `append_rc_content` in `WindowsAttributes`.

crates/tauri-build/src/lib.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ pub struct WindowsAttributes {
242242
///
243243
/// [application manifest]: https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests
244244
app_manifest: Option<String>,
245+
/// A series of strings containing additional .rc content to be appended to the generated resource file on Windows.
246+
append_rc_content: Vec<String>,
245247
}
246248

247249
impl Default for WindowsAttributes {
@@ -256,6 +258,7 @@ impl WindowsAttributes {
256258
Self {
257259
window_icon_path: Default::default(),
258260
app_manifest: Some(include_str!("windows-app-manifest.xml").into()),
261+
append_rc_content: Vec::new(),
259262
}
260263
}
261264

@@ -265,6 +268,7 @@ impl WindowsAttributes {
265268
Self {
266269
app_manifest: None,
267270
window_icon_path: Default::default(),
271+
append_rc_content: Vec::new(),
268272
}
269273
}
270274

@@ -334,6 +338,14 @@ impl WindowsAttributes {
334338
self.app_manifest = Some(manifest.as_ref().to_string());
335339
self
336340
}
341+
342+
/// Append additional .rc content to the generated resource file on Windows.
343+
/// This can be called multiple times to append multiple contents.
344+
#[must_use]
345+
pub fn append_rc_content<S: Into<String>>(mut self, content: S) -> Self {
346+
self.append_rc_content.push(content.into());
347+
self
348+
}
337349
}
338350

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

628+
for content in attributes.windows_attributes.append_rc_content {
629+
res.append_rc_content(&content);
630+
}
631+
616632
if let Some(version_str) = &config.version {
617633
if let Ok(v) = Version::parse(version_str) {
618634
let version = (v.major << 48) | (v.minor << 32) | (v.patch << 16);

0 commit comments

Comments
 (0)