-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbuild.rs
More file actions
69 lines (61 loc) · 2.44 KB
/
build.rs
File metadata and controls
69 lines (61 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use vergen_gix::{Emitter, GixBuilder};
fn main() {
// Windows manifest
if cfg!(target_os = "windows") {
add_manifest();
}
// Version
if let Ok(gix) = GixBuilder::default().sha(true).build()
&& Emitter::new().fail_on_error().add_instructions(&gix).and_then(|e| e.emit()).is_ok()
{
return;
}
// Fallback
println!("cargo:rustc-env=VERGEN_GIT_SHA=unknown");
}
#[cfg(not(windows))]
fn add_manifest() {
unreachable!("Only add manifest on windows");
}
#[cfg(windows)]
fn add_manifest() {
use std::{env, fs, path::PathBuf};
let version = env!("CARGO_PKG_VERSION");
let manifest = format!(
r#"<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"
xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity type="win32" name="James58899.Hath-rust" version="{version}.0" />
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 11 24H2 -->
<supportedOS Id="{{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}}" />
<maxversiontested Id="10.0.26100.0" />
</application>
</compatibility>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<asmv3:application>
<asmv3:windowsSettings>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
<activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
<heapType xmlns="http://schemas.microsoft.com/SMI/2020/WindowsSettings">SegmentHeap</heapType>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>"#
);
// write manifest
let manifest_path = PathBuf::from(env::var("OUT_DIR").unwrap_or(".".into())).join("hath-rust.exe.manifest");
fs::write(&manifest_path, &manifest).unwrap();
let mut res = tauri_winres::WindowsResource::new();
res.set("OriginalFilename", "hath-rust.exe");
res.set("FileDescription", "hath-rust - Hentai@Home but rusty");
res.set("LegalCopyright", "GPL-3.0-or-later");
res.set_manifest_file(manifest_path.to_str().unwrap());
res.compile().unwrap()
}