Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command-line: add option to generate a depfile when using zig build-obj/zig build-exe #16850

Open
taikoo opened this issue Aug 16, 2023 · 1 comment

Comments

@taikoo
Copy link

taikoo commented Aug 16, 2023

somthing like gcc:

  -MD                     Write a depfile containing user and system headers
  -MF <file>              Write depfile output from -MMD, -MD, -MM, or -M to <file>
  -MMD                    Write a depfile containing user headers
  -MM                     Like -MMD, but also implies -E and writes to stdout by default

gcc -MD, clang -MD, rustc --emit dep-info

possible scenarios:

using zig build-obj, zig build-exe with Make, Ninja

sample usage:

$ zig build-exe -MD a.zig
@dcbaker
Copy link

dcbaker commented Jan 8, 2024

I have interest in such a feature as well. I want to clarify that -MD is not, by itself sufficient. What is really needed is -MD -MQ <target name> and (for me) the ability to choose where to write the target, ie -MF <depfile>.d. Note that rustc's --emit dep-infodoes this via--emit dep-info=depfile.d`.

MQ is important, as it causes the output to quote characters that are special to make (since a dep-file is a limited subset of make syntax). My preference would be to take the approach Rust did, and do the right thing and only the right thing, by always quoting, and not having to repeat the output name since rustc (or zig in this case), already knows that the output name is.

I would be willing to work on this, but I'm not sure where to start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants