@@ -290,17 +290,43 @@ impl Client {
290
290
///
291
291
/// On platforms other than Unix and Windows this panics.
292
292
pub fn configure ( & self , cmd : & mut Command ) {
293
- let arg = self . inner . string_arg ( ) ;
294
- // Older implementations of make use `--jobserver-fds` and newer
295
- // implementations use `--jobserver-auth`, pass both to try to catch
296
- // both implementations.
297
- let value = format ! ( "-j --jobserver-fds={0} --jobserver-auth={0}" , arg) ;
293
+ cmd. env ( "CARGO_MAKEFLAGS" , & self . mflags_env ( ) ) ;
294
+ self . inner . configure ( cmd) ;
295
+ }
296
+
297
+ /// Configures a child process to have access to this client's jobserver as
298
+ /// well.
299
+ ///
300
+ /// This function is required to be called to ensure that a jobserver is
301
+ /// properly inherited to a child process. If this function is *not* called
302
+ /// then this `Client` will not be accessible in the child process. In other
303
+ /// words, if not called, then `Client::from_env` will return `None` in the
304
+ /// child process (or the equivalent of `Child::from_env` that `make` uses).
305
+ ///
306
+ /// ## Platform-specific behavior
307
+ ///
308
+ /// On Unix and Windows this will clobber the `CARGO_MAKEFLAGS`,
309
+ /// `MAKEFLAGS` and `MFLAGS` environment variables for the child process,
310
+ /// and on Unix this will also allow the two file descriptors for
311
+ /// this client to be inherited to the child.
312
+ ///
313
+ /// On platforms other than Unix and Windows this panics.
314
+ pub fn configure_make ( & self , cmd : & mut Command ) {
315
+ let value = self . mflags_env ( ) ;
298
316
cmd. env ( "CARGO_MAKEFLAGS" , & value) ;
299
317
cmd. env ( "MAKEFLAGS" , & value) ;
300
318
cmd. env ( "MFLAGS" , & value) ;
301
319
self . inner . configure ( cmd) ;
302
320
}
303
321
322
+ fn mflags_env ( & self ) -> String {
323
+ let arg = self . inner . string_arg ( ) ;
324
+ // Older implementations of make use `--jobserver-fds` and newer
325
+ // implementations use `--jobserver-auth`, pass both to try to catch
326
+ // both implementations.
327
+ format ! ( "-j --jobserver-fds={0} --jobserver-auth={0}" , arg)
328
+ }
329
+
304
330
/// Converts this `Client` into a helper thread to deal with a blocking
305
331
/// `acquire` function a little more easily.
306
332
///
0 commit comments