@@ -140,10 +140,16 @@ fn main() {
140
140
cc:: Build :: new ( )
141
141
. cpp ( true )
142
142
. file ( "cpp/Test.cc" )
143
+ . include ( "include" )
143
144
. compile ( "libtest.a" ) ;
144
145
145
146
let macros = Arc :: new ( RwLock :: new ( HashSet :: new ( ) ) ) ;
146
147
148
+ let out_path = PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
149
+ let out_rust_file = out_path. join ( "test.rs" ) ;
150
+ let out_rust_file_relative = out_rust_file. strip_prefix ( std:: env:: current_dir ( ) . unwrap ( ) ) . unwrap ( ) ;
151
+ let out_dep_file = out_path. join ( "test.d" ) ;
152
+
147
153
let bindings = Builder :: default ( )
148
154
. rustfmt_bindings ( false )
149
155
. enable_cxx_namespaces ( )
@@ -154,7 +160,7 @@ fn main() {
154
160
. raw_line ( "extern { fn my_prefixed_function_to_remove(i: i32); }" )
155
161
. module_raw_line ( "root::testing" , "pub type Bar = i32;" )
156
162
. header ( "cpp/Test.h" )
157
- . clang_args ( & [ "-x" , "c++" , "-std=c++11" ] )
163
+ . clang_args ( & [ "-x" , "c++" , "-std=c++11" , "-I" , "include" ] )
158
164
. parse_callbacks ( Box :: new ( MacroCallback {
159
165
macros : macros. clone ( ) ,
160
166
seen_hellos : Mutex :: new ( 0 ) ,
@@ -163,13 +169,18 @@ fn main() {
163
169
. blocklist_function ( "my_prefixed_function_to_remove" )
164
170
. constified_enum ( "my_prefixed_enum_to_be_constified" )
165
171
. opaque_type ( "my_prefixed_templated_foo<my_prefixed_baz>" )
172
+ . depfile ( out_rust_file_relative. display ( ) . to_string ( ) , & out_dep_file)
166
173
. generate ( )
167
174
. expect ( "Unable to generate bindings" ) ;
168
175
169
176
assert ! ( macros. read( ) . unwrap( ) . contains( "TESTMACRO" ) ) ;
170
-
171
- let out_path = PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
172
- bindings
173
- . write_to_file ( out_path. join ( "test.rs" ) )
174
- . expect ( "Couldn't write bindings!" ) ;
177
+ bindings. write_to_file ( & out_rust_file) . expect ( "Couldn't write bindings!" ) ;
178
+
179
+ let observed_deps = std:: fs:: read_to_string ( out_dep_file) . expect ( "Couldn't read depfile!" ) ;
180
+ let expected_deps = format ! ( "{}: cpp/Test.h include/stub.h" , out_rust_file_relative. display( ) ) ;
181
+ assert_eq ! (
182
+ observed_deps,
183
+ expected_deps,
184
+ "including stub via include dir must produce correct dep path" ,
185
+ ) ;
175
186
}
0 commit comments