mirror of
https://github.com/yuzu-emu/liftinstall.git
synced 2024-11-22 16:15:40 +01:00
Feed winres data from the bootstrap config file
This commit is contained in:
parent
d2cd856bb3
commit
b6fba61080
@ -7,10 +7,6 @@ documentation = "https://liftinstall.jselby.net"
|
|||||||
description = "An adaptable installer for your application."
|
description = "An adaptable installer for your application."
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[package.metadata.winres]
|
|
||||||
ProductName = "yuzu Installer"
|
|
||||||
FileDescription = "An interactive installer for yuzu"
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
web-view = {git = "https://github.com/Boscop/web-view.git", rev = "555f422d09cbb94e82a728d47e9e07ca91963f6e"}
|
web-view = {git = "https://github.com/Boscop/web-view.git", rev = "555f422d09cbb94e82a728d47e9e07ca91963f6e"}
|
||||||
|
|
||||||
@ -53,3 +49,7 @@ nfd = "0.0.4"
|
|||||||
winres = "0.1"
|
winres = "0.1"
|
||||||
bindgen = "0.26.3"
|
bindgen = "0.26.3"
|
||||||
cc = "1.0"
|
cc = "1.0"
|
||||||
|
|
||||||
|
serde = "1.0.27"
|
||||||
|
serde_derive = "1.0.27"
|
||||||
|
toml = "0.4"
|
||||||
|
@ -36,7 +36,6 @@ In order to build yourself an installer, as a bare minimum, you need to:
|
|||||||
- Add your favicon to `static/favicon.ico`
|
- Add your favicon to `static/favicon.ico`
|
||||||
- Modify the bootstrap configuration file as needed (`config.PLATFORM.toml`).
|
- Modify the bootstrap configuration file as needed (`config.PLATFORM.toml`).
|
||||||
- Have the main configuration file somewhere useful, reachable over HTTP.
|
- Have the main configuration file somewhere useful, reachable over HTTP.
|
||||||
- Tweak `package.metadata.winres` metadata in `Cargo.toml`
|
|
||||||
- Run:
|
- Run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
45
build.rs
45
build.rs
@ -1,4 +1,5 @@
|
|||||||
extern crate walkdir;
|
extern crate walkdir;
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
extern crate winres;
|
extern crate winres;
|
||||||
|
|
||||||
@ -8,6 +9,11 @@ extern crate bindgen;
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
extern crate cc;
|
extern crate cc;
|
||||||
|
|
||||||
|
extern crate serde;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate serde_derive;
|
||||||
|
extern crate toml;
|
||||||
|
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
@ -19,16 +25,33 @@ use std::fs::File;
|
|||||||
|
|
||||||
use std::io::BufRead;
|
use std::io::BufRead;
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
|
use std::io::Read;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
use std::env::consts::OS;
|
use std::env::consts::OS;
|
||||||
|
|
||||||
const FILES_TO_PREPROCESS: &'static [&'static str] = &["helpers.js", "views.js"];
|
const FILES_TO_PREPROCESS: &'static [&'static str] = &["helpers.js", "views.js"];
|
||||||
|
|
||||||
|
/// Describes the application itself.
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct BaseAttributes {
|
||||||
|
pub name: String,
|
||||||
|
pub target_url: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn handle_binary() {
|
fn handle_binary(config: &BaseAttributes) {
|
||||||
let mut res = winres::WindowsResource::new();
|
let mut res = winres::WindowsResource::new();
|
||||||
res.set_icon("static/favicon.ico");
|
res.set_icon("static/favicon.ico");
|
||||||
|
res.set(
|
||||||
|
"FileDescription",
|
||||||
|
&format!("Interactive installer for {}", config.name),
|
||||||
|
);
|
||||||
|
res.set("ProductName", &format!("{} installer", config.name));
|
||||||
|
res.set(
|
||||||
|
"OriginalFilename",
|
||||||
|
&format!("{}_installer.exe", config.name),
|
||||||
|
);
|
||||||
res.compile().expect("Failed to generate metadata");
|
res.compile().expect("Failed to generate metadata");
|
||||||
|
|
||||||
let bindings = bindgen::Builder::default()
|
let bindings = bindgen::Builder::default()
|
||||||
@ -48,11 +71,9 @@ fn handle_binary() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
fn handle_binary() {}
|
fn handle_binary(config: &BaseAttributes) {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
handle_binary();
|
|
||||||
|
|
||||||
let output_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
let output_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||||
|
|
||||||
let os = OS.to_lowercase();
|
let os = OS.to_lowercase();
|
||||||
@ -68,7 +89,21 @@ fn main() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
copy(target_config, output_dir.join("config.toml")).expect("Unable to copy config file");
|
// Read in the config for our own purposes
|
||||||
|
let file_contents = {
|
||||||
|
let mut file = File::open(&target_config).expect("Unable to open config file");
|
||||||
|
let mut buf = Vec::new();
|
||||||
|
file.read_to_end(&mut buf)
|
||||||
|
.expect("Unable to read config file contents");
|
||||||
|
buf
|
||||||
|
};
|
||||||
|
|
||||||
|
let config: BaseAttributes =
|
||||||
|
toml::from_slice(&file_contents).expect("Unable to parse config file");
|
||||||
|
handle_binary(&config);
|
||||||
|
|
||||||
|
// Copy for the main build
|
||||||
|
copy(&target_config, output_dir.join("config.toml")).expect("Unable to copy config file");
|
||||||
|
|
||||||
// Copy files from static/ to build dir
|
// Copy files from static/ to build dir
|
||||||
for entry in WalkDir::new("static") {
|
for entry in WalkDir::new("static") {
|
||||||
|
Loading…
Reference in New Issue
Block a user