File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -293,9 +293,38 @@ fn build_grpc(cc: &mut cc::Build, library: &str) {
293
293
}
294
294
}
295
295
296
+ figure_systemd_path ( & build_dir) ;
297
+
296
298
cc. include ( "grpc/include" ) ;
297
299
}
298
300
301
+ fn figure_systemd_path ( build_dir : & str ) {
302
+ let path = format ! ( "{build_dir}/CMakeCache.txt" ) ;
303
+ let f = BufReader :: new ( std:: fs:: File :: open ( & path) . unwrap ( ) ) ;
304
+ let mut libdir: Option < String > = None ;
305
+ let mut libname: Option < String > = None ;
306
+ for l in f. lines ( ) {
307
+ let l = l. unwrap ( ) ;
308
+ if let Some ( s) = trim_start ( & l, "SYSTEMD_LIBDIR:INTERNAL=" ) . filter ( |s| !s. is_empty ( ) ) {
309
+ libdir = Some ( s. to_owned ( ) ) ;
310
+ if libname. is_some ( ) {
311
+ break ;
312
+ }
313
+ } else if let Some ( s) =
314
+ trim_start ( & l, "SYSTEMD_LIBRARIES:INTERNAL=" ) . filter ( |s| !s. is_empty ( ) )
315
+ {
316
+ libname = Some ( s. to_owned ( ) ) ;
317
+ if libdir. is_some ( ) {
318
+ break ;
319
+ }
320
+ }
321
+ }
322
+ if let ( Some ( libdir) , Some ( libname) ) = ( libdir, libname) {
323
+ println ! ( "cargo:rustc-link-search=native={}" , libdir) ;
324
+ println ! ( "cargo:rustc-link-lib={}" , libname) ;
325
+ }
326
+ }
327
+
299
328
fn figure_ssl_path ( build_dir : & str ) {
300
329
let path = format ! ( "{build_dir}/CMakeCache.txt" ) ;
301
330
let f = BufReader :: new ( std:: fs:: File :: open ( & path) . unwrap ( ) ) ;
You can’t perform that action at this time.
0 commit comments