mirror of https://github.com/Tim-Paik/neutauri.git
Ready to integrate rcedit on windows
This commit is contained in:
parent
9117dc841f
commit
d31ddba08a
|
@ -1176,6 +1176,7 @@ dependencies = [
|
||||||
"gumdrop",
|
"gumdrop",
|
||||||
"image",
|
"image",
|
||||||
"new_mime_guess",
|
"new_mime_guess",
|
||||||
|
"rcedit",
|
||||||
"serde",
|
"serde",
|
||||||
"toml",
|
"toml",
|
||||||
"wry",
|
"wry",
|
||||||
|
@ -1518,6 +1519,24 @@ dependencies = [
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rcedit"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/Tim-Paik/rcedit-rs.git#8d323d1015ad6ff2c111d902e9d60b75668fa781"
|
||||||
|
dependencies = [
|
||||||
|
"rcedit-sys",
|
||||||
|
"thiserror",
|
||||||
|
"widestring",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rcedit-sys"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/Tim-Paik/rcedit-rs.git#8d323d1015ad6ff2c111d902e9d60b75668fa781"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.2.10"
|
version = "0.2.10"
|
||||||
|
@ -2093,6 +2112,12 @@ version = "0.1.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d8b77fdfd5a253be4ab714e4ffa3c49caf146b4de743e97510c0656cf90f1e8e"
|
checksum = "d8b77fdfd5a253be4ab714e4ffa3c49caf146b4de743e97510c0656cf90f1e8e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "widestring"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
|
|
|
@ -12,3 +12,6 @@ new_mime_guess = "4.0"
|
||||||
serde = {version = "1.0", features = ["derive"]}
|
serde = {version = "1.0", features = ["derive"]}
|
||||||
toml = "0.5"
|
toml = "0.5"
|
||||||
wry = {version = "0.15", features = ["devtools"]}
|
wry = {version = "0.15", features = ["devtools"]}
|
||||||
|
|
||||||
|
[target.'cfg(windows)'.dependencies]
|
||||||
|
rcedit = {git = "https://github.com/Tim-Paik/rcedit-rs.git"}
|
|
@ -1,10 +1,9 @@
|
||||||
use crate::data;
|
use crate::data;
|
||||||
use std::{fs, io::Write};
|
use std::{
|
||||||
|
env, fs,
|
||||||
#[cfg(windows)]
|
hash::{Hash, Hasher},
|
||||||
const RUNTIME_DATA: &[u8] = include_bytes!("../../target/release/neutauri_runtime.exe");
|
io::{self, Write},
|
||||||
#[cfg(not(windows))]
|
};
|
||||||
const RUNTIME_DATA: &[u8] = include_bytes!("../../target/release/neutauri_runtime");
|
|
||||||
|
|
||||||
fn options() -> fs::OpenOptions {
|
fn options() -> fs::OpenOptions {
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
|
@ -18,10 +17,31 @@ fn options() -> fs::OpenOptions {
|
||||||
options
|
options
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bundle(config_path: String) -> std::io::Result<()> {
|
#[cfg(not(windows))]
|
||||||
|
fn get_runtime_data() -> io::Result<Vec<u8>> {
|
||||||
|
Ok(include_bytes!("../../target/release/neutauri_runtime").to_vec())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
fn get_runtime_data() -> io::Result<Vec<u8>> {
|
||||||
|
let mut hasher = std::collections::hash_map::DefaultHasher::new();
|
||||||
|
hasher.write(b"neutauri_runtime");
|
||||||
|
std::time::SystemTime::now().hash(&mut hasher);
|
||||||
|
println!("Hash is {:x}!", hasher.finish());
|
||||||
|
let temp_path = env::temp_dir().join(format!("{:x}.exe", hasher.finish()));
|
||||||
|
fs::write(
|
||||||
|
&temp_path,
|
||||||
|
include_bytes!("../../target/release/neutauri_runtime.exe"),
|
||||||
|
)?;
|
||||||
|
// let mut updater = rcedit::ResourceUpdater::new();
|
||||||
|
// updater.load(&temp_path).unwrap(); // TODO: handle error
|
||||||
|
fs::read(&temp_path)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn bundle(config_path: String) -> io::Result<()> {
|
||||||
let config_path = std::path::Path::new(&config_path).canonicalize()?;
|
let config_path = std::path::Path::new(&config_path).canonicalize()?;
|
||||||
let config: data::Config = toml::from_str(fs::read_to_string(&config_path)?.as_str())
|
let config: data::Config = toml::from_str(fs::read_to_string(&config_path)?.as_str())
|
||||||
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
|
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
|
||||||
let source = match config_path.parent() {
|
let source = match config_path.parent() {
|
||||||
Some(path) => path.join(&config.source).canonicalize()?,
|
Some(path) => path.join(&config.source).canonicalize()?,
|
||||||
None => config.source.canonicalize()?,
|
None => config.source.canonicalize()?,
|
||||||
|
@ -42,7 +62,7 @@ pub fn bundle(config_path: String) -> std::io::Result<()> {
|
||||||
}
|
}
|
||||||
let data = data::Data::build_from_dir(source, config.window_attr()?, config.webview_attr()?)?;
|
let data = data::Data::build_from_dir(source, config.window_attr()?, config.webview_attr()?)?;
|
||||||
let mut f = options().open(&target)?;
|
let mut f = options().open(&target)?;
|
||||||
f.write_all(RUNTIME_DATA)?;
|
f.write_all(&get_runtime_data()?)?;
|
||||||
f.write_all(&data)?;
|
f.write_all(&data)?;
|
||||||
f.sync_all()?;
|
f.sync_all()?;
|
||||||
f.flush()?;
|
f.flush()?;
|
||||||
|
|
Loading…
Reference in New Issue