Skip to content

Commit 38da1f3

Browse files
committed
Print rerun-if-changed in objc2_sys
1 parent a4352ad commit 38da1f3

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

gnustep_libobjc2_src/src/lib.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl Builder {
5959
panic!("{}", NO_SOURCES_MSG);
6060
}
6161

62-
let dst = cmake::Config::new(source_dir)
62+
let dst = cmake::Config::new(&source_dir)
6363
// Default to ignoring `gnustep-config` presence, since they
6464
// usually want to install the libraries globally (which requires
6565
// root). Users that want systemwide installation should just
@@ -91,6 +91,7 @@ impl Builder {
9191
.build();
9292

9393
Artifacts {
94+
source_dir,
9495
include_dir: dst.join("include"),
9596
lib_dir: dst.join("lib"),
9697
lib_kind: self.lib_kind,
@@ -100,13 +101,18 @@ impl Builder {
100101
}
101102

102103
pub struct Artifacts {
104+
source_dir: PathBuf,
103105
include_dir: PathBuf,
104106
lib_dir: PathBuf,
105107
lib_kind: LibKind,
106108
lib_name: &'static str,
107109
}
108110

109111
impl Artifacts {
112+
pub fn source_dir(&self) -> &Path {
113+
&self.source_dir
114+
}
115+
110116
pub fn include_dir(&self) -> &Path {
111117
&self.include_dir
112118
}
@@ -133,6 +139,22 @@ impl Artifacts {
133139
println!("cargo:include={}", self.include_dir.display());
134140
println!("cargo:lib={}", self.lib_dir.display());
135141
}
142+
143+
pub fn print_cargo_rerun_if_changed(&self) {
144+
println!("cargo:rerun-if-env-changed=CC");
145+
println!("cargo:rerun-if-env-changed=CXX");
146+
rerun_if(&self.source_dir);
147+
}
148+
}
149+
150+
fn rerun_if(path: &Path) {
151+
if path.is_dir() {
152+
for entry in std::fs::read_dir(path).expect("read_dir") {
153+
rerun_if(&entry.expect("entry").path());
154+
}
155+
} else {
156+
println!("cargo:rerun-if-changed={}", path.display());
157+
}
136158
}
137159

138160
#[non_exhaustive]

objc2_sys/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fn main() {
99

1010
let artifacts = builder.build();
1111
artifacts.print_cargo_metadata();
12+
artifacts.print_cargo_rerun_if_changed();
1213

1314
// Add #[cfg(gnustep)] directive
1415
println!("cargo:rustc-cfg=gnustep");

0 commit comments

Comments
 (0)