Skip to content

GNU Make integration: Correctly react to the presence of n (--just-print) in MAKEFLAGS #16639

@mbs-c

Description

@mbs-c

Problem

Thanks to cargo implementing the jobserver protocol (#1744), you can already call cargo from a GNU make build and have both build systems figure out how many parallel jobs can be started at a given time. All you have to do is prefix the GNU Make recipe line in which cargo is invoked with a +.

Unfortunately, this has a nasty side effect: If you (or your IDE 1) only want to know what GNU Make would execute and start make -n, then make executes cargo anyway, assuming that sub-makes will know how to handle the MAKEFLAGS appropriately. Unfortunately, cargo actually completely ignores the presence of n in MAKEFLAGS and starts building stuff, which is the exact opposite of what the user wanted.

Proposed Solution

If n is present in MAKEFLAGS, cargo should only print the processes it would normally execute instead of actually executing build processes.

Notes

Relevant GNU Make documentation:

Footnotes

  1. CLion, for example, does this when importing Makefile projects

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-build-systemArea: build system integrationC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-team-inputStatus: Needs input from team on whether/how to proceed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions