Skip to content

Commit a39f982

Browse files
committed
build-tools: Allow passing multiple source dirs to compile_resources
You can pass the command line tool multiple source dirs, so we should allow it too.
1 parent bb0879e commit a39f982

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

examples/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fn main() {
22
glib_build_tools::compile_resources(
3-
"resources",
3+
&["resources"],
44
"resources/resources.gresource.xml",
55
"compiled.gresource",
66
);

glib-build-tools/src/lib.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,22 @@ use std::{env, path::Path, process::Command};
1010
///
1111
/// ```no_run
1212
/// glib_build_tools::compile_resources(
13-
/// "resources",
13+
/// &["resources"],
1414
/// "resources/resources.gresource.xml",
1515
/// "compiled.gresource",
1616
/// );
1717
/// ```
18-
pub fn compile_resources<P: AsRef<Path>>(source_dir: P, gresource: &str, target: &str) {
18+
pub fn compile_resources<P: AsRef<Path>>(source_dirs: &[P], gresource: &str, target: &str) {
1919
let out_dir = env::var("OUT_DIR").unwrap();
2020
let out_dir = Path::new(&out_dir);
2121

22-
let output = Command::new("glib-compile-resources")
23-
.arg("--sourcedir")
24-
.arg(source_dir.as_ref())
22+
let mut command = Command::new("glib-compile-resources");
23+
24+
for source_dir in source_dirs {
25+
command.arg("--sourcedir").arg(source_dir.as_ref());
26+
}
27+
28+
let output = command
2529
.arg("--target")
2630
.arg(out_dir.join(target))
2731
.arg(gresource)
@@ -36,9 +40,13 @@ pub fn compile_resources<P: AsRef<Path>>(source_dir: P, gresource: &str, target:
3640
);
3741

3842
println!("cargo:rerun-if-changed={gresource}");
39-
let output = Command::new("glib-compile-resources")
40-
.arg("--sourcedir")
41-
.arg(source_dir.as_ref())
43+
let mut command = Command::new("glib-compile-resources");
44+
45+
for source_dir in source_dirs {
46+
command.arg("--sourcedir").arg(source_dir.as_ref());
47+
}
48+
49+
let output = command
4250
.arg("--generate-dependencies")
4351
.arg(gresource)
4452
.output()

0 commit comments

Comments
 (0)