Skip to content

Commit

Permalink
Add Windows Application Manifest file (#178)
Browse files Browse the repository at this point in the history
* Add Windows Application Manifest file

* Use `<winuser.h>` and add comments
  • Loading branch information
DavisVaughan authored Dec 14, 2023
1 parent d24c167 commit 3d58017
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 13 deletions.
126 changes: 113 additions & 13 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 crates/ark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ winsafe = { version = "0.0.18", features = ["kernel"] }

[build-dependencies]
chrono = "0.4.23"
embed-resource = "2.4.0"
9 changes: 9 additions & 0 deletions crates/ark/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
//
//

use std::path::Path;
use std::process::Command;
extern crate embed_resource;

fn main() {
// Attempt to use `git rev-parse HEAD` to get the current git hash. If this
Expand All @@ -32,4 +34,11 @@ fn main() {
// Get the build date as a string
let build_date = chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
println!("cargo:rustc-env=BUILD_DATE={}", build_date);

// Embed an Application Manifest file on Windows.
// Documented to do nothing on non-Windows.
let resource = Path::new("resources")
.join("manifest")
.join("ark-manifest.rc");
embed_resource::compile(resource, embed_resource::NONE);
}
11 changes: 11 additions & 0 deletions crates/ark/resources/manifest/ark-manifest.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This is a C file that embed-resource compiles for us.
// It helps embed our Windows Application Manifest file.
// https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests
// https://learn.microsoft.com/en-us/cpp/build/reference/manifest-create-side-by-side-assembly-manifest?view=msvc-170

// This defines `RT_MANIFEST` to `24`. embed-resource should know how to ensure the header is available.
// https://github.com/nabijaczleweli/rust-embed-resource/issues/11#issuecomment-779295722
#include <winuser.h>

// The `1` is a `resource_id` that specifies ark as an executable file
1 RT_MANIFEST "ark.exe.manifest"
40 changes: 40 additions & 0 deletions crates/ark/resources/manifest/ark.exe.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

<assemblyIdentity version="1.0.0.0" name="ark" type="win32"/>

<description>ark</description>

<!-- Support UTF-8 code page with R 4.2.0 and newer. -->
<application>
<windowsSettings>
<activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
</windowsSettings>
</application>

<!-- Identify the application security requirements. -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker"/>
</requestedPrivileges>
</security>
</trustInfo>

<!-- Declare compatibility with different versions of Windows. -->
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 and Windows 11 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
</application>
</compatibility>

</assembly>

0 comments on commit 3d58017

Please sign in to comment.