@@ -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
102103pub 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
109111impl 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]
0 commit comments