@@ -290,17 +290,43 @@ impl Client {
290290 ///
291291 /// On platforms other than Unix and Windows this panics.
292292 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 ( ) ;
298316 cmd. env ( "CARGO_MAKEFLAGS" , & value) ;
299317 cmd. env ( "MAKEFLAGS" , & value) ;
300318 cmd. env ( "MFLAGS" , & value) ;
301319 self . inner . configure ( cmd) ;
302320 }
303321
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+
304330 /// Converts this `Client` into a helper thread to deal with a blocking
305331 /// `acquire` function a little more easily.
306332 ///
0 commit comments