@@ -229,6 +229,48 @@ fn main() {
229
229
)
230
230
. compile ( "pq" ) ;
231
231
232
- println ! ( "cargo:include={path}/src/include" ) ;
233
- println ! ( "cargo:lib_dir={}" , std:: env:: var( "OUT_DIR" ) . expect( "Set by cargo" ) ) ;
232
+ let out = std:: env:: var ( "OUT_DIR" ) . expect ( "Set by cargo" ) ;
233
+ let include_path = PathBuf :: from ( & out) . join ( "include" ) ;
234
+ let lib_pq_path = PathBuf :: from ( format ! ( "{path}/{pq_path}" ) ) ;
235
+ std:: fs:: create_dir_all ( & include_path) . expect ( "Failed to create include directory" ) ;
236
+ std:: fs:: create_dir_all ( include_path. join ( "postgres" ) . join ( "internal" ) )
237
+ . expect ( "Failed to create include directory" ) ;
238
+ std:: fs:: copy (
239
+ lib_pq_path. join ( "libpq-fe.h" ) ,
240
+ include_path. join ( "libpq-fe.h" ) ,
241
+ )
242
+ . expect ( "Copying headers failed" ) ;
243
+ std:: fs:: copy (
244
+ lib_pq_path. join ( "libpq-events.h" ) ,
245
+ include_path. join ( "libpq-events.h" ) ,
246
+ )
247
+ . expect ( "Copying headers failed" ) ;
248
+
249
+ std:: fs:: copy (
250
+ lib_pq_path. join ( "libpq-int.h" ) ,
251
+ include_path
252
+ . join ( "postgres" )
253
+ . join ( "internal" )
254
+ . join ( "libpq-int.h" ) ,
255
+ )
256
+ . expect ( "Copying headers failed" ) ;
257
+ std:: fs:: copy (
258
+ lib_pq_path. join ( "fe-auth-sasl.h" ) ,
259
+ include_path
260
+ . join ( "postgres" )
261
+ . join ( "internal" )
262
+ . join ( "fe-auth-sasl.h" ) ,
263
+ )
264
+ . expect ( "Copying headers failed" ) ;
265
+ std:: fs:: copy (
266
+ lib_pq_path. join ( "pqexpbuffer.h" ) ,
267
+ include_path
268
+ . join ( "postgres" )
269
+ . join ( "internal" )
270
+ . join ( "pqexpbuffer.h" ) ,
271
+ )
272
+ . expect ( "Copying headers failed" ) ;
273
+
274
+ println ! ( "cargo:include={out}/include" ) ;
275
+ println ! ( "cargo:lib_dir={}" , out) ;
234
276
}
0 commit comments