-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,340 additions
and
1,439 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,55 @@ | ||
use std::{env, fs, path::Path, process::Command}; | ||
|
||
fn render_schema(gschema: &str, out_dir: &Path) { | ||
let gettext_package = env::var("GETTEXT_PACKAGE").unwrap(); | ||
let app_id = env::var("APP_ID").unwrap(); | ||
let gettext_package = env::var("GETTEXT_PACKAGE").unwrap(); | ||
let app_id = env::var("APP_ID").unwrap(); | ||
|
||
let contents = fs::read_to_string(gschema).unwrap(); | ||
let contents = fs::read_to_string(gschema).unwrap(); | ||
eprintln!("{:?}", contents); | ||
let new = contents | ||
.replace("@gettext-package@", &gettext_package) | ||
.replace("@app-id@", &app_id); | ||
let new = contents.replace("@gettext-package@", &gettext_package).replace("@app-id@", &app_id); | ||
|
||
let filename = Path::new(gschema).file_name().unwrap(); | ||
let outfile = Path::new(filename).file_stem().unwrap(); | ||
let outpath = out_dir.join(outfile); | ||
let outfile = Path::new(filename).file_stem().unwrap(); | ||
let outpath = out_dir.join(outfile); | ||
|
||
fs::write(outpath.clone(), new).unwrap(); | ||
fs::write(outpath.clone(), new).unwrap(); | ||
|
||
let outpath_file = outpath.to_string_lossy(); | ||
println!("cargo:rerun-if-changed={gschema}"); | ||
println!("cargo:rerun-if-changed={gschema}"); | ||
println!("cargo:rerun-if-changed={outpath_file}"); | ||
} | ||
|
||
pub fn compile_schemas<P: AsRef<Path>>(gschemas: &[P]) { | ||
let out_dir = env::var("OUT_DIR").unwrap(); | ||
let out_dir = Path::new(&out_dir); | ||
|
||
for gschema in gschemas { | ||
render_schema(&gschema.as_ref().to_string_lossy(), out_dir); | ||
} | ||
|
||
let schema_dir = env::var("GSETTINGS_SCHEMA_DIR").unwrap(); | ||
let output = Command::new("glib-compile-schemas") | ||
.arg("--targetdir") | ||
.arg(schema_dir) | ||
.arg(out_dir) | ||
.output() | ||
.unwrap(); | ||
|
||
assert!( | ||
output.status.success(), | ||
"glib-compile-schemas failed with exit status {} and stderr:\n{}", | ||
output.status, | ||
String::from_utf8_lossy(&output.stderr) | ||
); | ||
let out_dir = env::var("OUT_DIR").unwrap(); | ||
let out_dir = Path::new(&out_dir); | ||
|
||
for gschema in gschemas { | ||
render_schema(&gschema.as_ref().to_string_lossy(), out_dir); | ||
} | ||
|
||
let schema_dir = env::var("GSETTINGS_SCHEMA_DIR").unwrap(); | ||
let output = Command::new("glib-compile-schemas") | ||
.arg("--targetdir") | ||
.arg(schema_dir) | ||
.arg(out_dir) | ||
.output() | ||
.unwrap(); | ||
|
||
assert!( | ||
output.status.success(), | ||
"glib-compile-schemas failed with exit status {} and stderr:\n{}", | ||
output.status, | ||
String::from_utf8_lossy(&output.stderr) | ||
); | ||
} | ||
|
||
fn compile_glib() { | ||
glib_build_tools::compile_resources( | ||
&["data/resources/"], | ||
"data/resources/resources.gresource.xml", | ||
"resources.gresource", | ||
); | ||
|
||
compile_schemas(&["data/com.github.vhdirk.Terms.gschema.xml.in"]); | ||
glib_build_tools::compile_resources(&["data/resources/"], "data/resources/resources.gresource.xml", "resources.gresource"); | ||
|
||
compile_schemas(&["data/com.github.vhdirk.Terms.gschema.xml.in"]); | ||
} | ||
|
||
fn main() { | ||
// TODO: we probably only want to do this when not running under meson | ||
compile_glib(); | ||
// TODO: we probably only want to do this when not running under meson | ||
compile_glib(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
edition = "2021" | ||
max_width = 80 | ||
hard_tabs = true | ||
max_width = 160 | ||
hard_tabs = false | ||
match_block_trailing_comma = true | ||
merge_derives = true | ||
newline_style = "Unix" | ||
reorder_imports = true | ||
reorder_modules = true | ||
tab_spaces = 2 | ||
tab_spaces = 4 | ||
use_field_init_shorthand = true |
Oops, something went wrong.