0cce5a47ab
In the build.rs we're looking for the FRACTAL_LOCALEDIR env variable that is written by the cargo.sh script ran by meson but if we want to run this for development we can't use cargo run because that env doesn't exists so we'll use fractal-gtk/po as default.
28 lines
782 B
Rust
28 lines
782 B
Rust
use std::process::Command;
|
|
use std::env;
|
|
use std::fs::File;
|
|
use std::path::Path;
|
|
use std::io::Write;
|
|
|
|
fn main() {
|
|
// Compile Gresource
|
|
Command::new("glib-compile-resources")
|
|
.args(&["--generate", "resources.xml"])
|
|
.current_dir("res")
|
|
.status()
|
|
.unwrap();
|
|
|
|
// Generating build globals
|
|
let default_locales = "./fractal-gtk/po".to_string();
|
|
let out_dir = env::var("OUT_DIR").unwrap();
|
|
let localedir = env::var("FRACTAL_LOCALEDIR").unwrap_or(default_locales);
|
|
let dest_path = Path::new(&out_dir).join("build_globals.rs");
|
|
let mut f = File::create(&dest_path).unwrap();
|
|
|
|
let globals = format!("
|
|
pub static LOCALEDIR: &'static str = \"{}\";
|
|
",
|
|
localedir);
|
|
|
|
f.write_all(&globals.into_bytes()[..]).unwrap();
|
|
}
|