Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 // Take a look at the license at the top of the repository in the LICENSE file.
2
3 #![doc = include_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include_str!!("../README.md")]
4
5 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/, pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#, processrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/::Commandrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/Command#};
6
7 // rustdoc-stripper-ignore-next
8 /// Call to run `glib-compile-resources` to generate compiled gresources to embed
9 /// in binary with [`gio::resources_register_include`]. `target` is relative to `OUT_DIR`.
10 ///
11 /// ```no_run
12 /// glib_build_tools::compile_resources(
13 /// &["resources"],
14 /// "resources/resources.gresource.xml",
15 /// "compiled.gresource",
16 /// );
17 /// ```
18 pub fn compile_resourcesrust-analyzer cargo glib-build-tools 0.22.8 compile_resources().<P: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>>(source_dirs: &[P], gresource: &str, target: &str) {
19 let out_dir = envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/var().("OUT_DIR").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
20 let out_dir = Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().(&out_dir);
21
22 let mut command = Commandrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/Command#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]new().("glib-compile-resources");
23
24 for source_dir in source_dirs {
25 command.argrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]arg().("--sourcedir").argrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]arg().(source_dir.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().());
26 }
27
28 let output = command
29 .argrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]arg().("--target")
30 .argrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]arg().(out_dir.joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().(target))
31 .argrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]arg().(gresource)
32 .outputrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]output().()
33 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
34
35 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
36 output.statusrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/Output#status..successrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[ExitStatus]success().(),
37 "glib-compile-resources failed with exit status {} and stderr:\n{}",
38 output.statusrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/Output#status.,
39 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::from_utf8_lossyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]from_utf8_lossy().(&output.stderrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/Output#stderr.)
40 );
41
42 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("cargo:rerun-if-changed={gresource}");
43 let mut command = Commandrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/Command#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]new().("glib-compile-resources");
44
45 for source_dir in source_dirs {
46 command.argrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]arg().("--sourcedir").argrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]arg().(source_dir.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().());
47 }
48
49 let output = command
50 .argrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]arg().("--generate-dependencies")
51 .argrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]arg().(gresource)
52 .outputrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]output().()
53 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
54 .stdoutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/Output#stdout.;
55 let output = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::from_utf8rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]from_utf8().(output).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
56 for dep in output.split_whitespacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_whitespace().() {
57 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("cargo:rerun-if-changed={dep}");
58 }
59 }