Skip to content

Commit 02b7f71

Browse files
committed
fix
1 parent 2f29eac commit 02b7f71

File tree

1 file changed

+13
-27
lines changed

1 file changed

+13
-27
lines changed

glib-build-tools/src/lib.rs

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22

33
#![doc = include_str!("../README.md")]
44

5-
use gio::glib;
6-
use std::{
7-
env,
8-
path::{Path, PathBuf},
9-
process::Command,
10-
};
5+
use std::{env, path::Path, process::Command};
116

127
// rustdoc-stripper-ignore-next
138
/// Call to run `glib-compile-resources` to generate compiled gresources to embed
@@ -65,36 +60,27 @@ pub fn compile_resources<P: AsRef<Path>>(source_dirs: &[P], gresource: &str, tar
6560

6661
// rustdoc-stripper-ignore-next
6762
/// Call to run `glib-compile-schemas` to generate compiled gschemas from `.gschema.xml` schemas
68-
/// files from specified directories and store `gschemas.compiled` into `glib-2.0` schema cache
69-
/// directory.
70-
///
71-
/// If `target_dir` is `None`, the default schema cache directory is used:
72-
/// - Unix: `$HOME/.local/share/glib-2.0/schemas/`
73-
/// - Windows: `C:/ProgramData/glib-2.0/schemas/`
63+
/// files.
7464
///
7565
/// ```no_run
7666
/// glib_build_tools::compile_schemas(
77-
/// &["schemas"],
78-
/// None
67+
/// &["schemas"]
7968
/// );
8069
/// ```
81-
pub fn compile_schemas(schemas_dir: &[&str], target_dir: Option<&str>) {
82-
let target_dir = match target_dir {
83-
Some(base) => PathBuf::from(base),
84-
None => {
85-
let prefix = if cfg!(windows) {
86-
PathBuf::from("C:/ProgramData")
87-
} else {
88-
glib::user_data_dir()
89-
};
90-
91-
Path::new(&prefix).join("glib-2.0").join("schemas")
92-
}
93-
};
70+
pub fn compile_schemas(schemas_dir: &[&str]) {
71+
let out_dir = env::var("OUT_DIR").unwrap();
72+
let out_dir = Path::new(&out_dir);
73+
74+
let target_dir = out_dir.join("gschemas");
9475

9576
// Ensure target_dir exists
9677
std::fs::create_dir_all(&target_dir).expect("Failed to create target directory");
9778

79+
println!(
80+
"cargo:rustc-env=GSETTINGS_SCHEMA_DIR={}",
81+
target_dir.to_str().unwrap()
82+
);
83+
9884
// Recursively copy all files with .gschema.xml extension from schema_dir to target_dir
9985
for schema_dir in schemas_dir {
10086
let entries = Path::new(schema_dir)

0 commit comments

Comments
 (0)