www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16746] New: Please output Makefile-style depfiles for ninja


          Issue ID: 16746
           Summary: Please output Makefile-style depfiles for ninja and
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: matthias tenstral.net

GCC and other compilers emit dependency information as Make-style depfiles,
allowing Make and make-replacements like Ninja to recompile dependencies as
soon as some unit higher up in the dependency chain has been changed.

This is tremendously useful, especially in D, where descending units have to be
rebuild e.g. on a template change or function signature change.

Unfortunately, DMDs `-deps=` flag makes it output a custom format, which makes
adding DMD and any compiler that is based on the DMD frontend to build systems
using Ninja and Make harder than it needs to be.

The Makefile-syntax used by GCC and Clang is the de-facto standard and changing
all other tools to support DMD will be impossible.

See https://ninja-build.org/manual.html#_depfile for a bit more information on
depfiles. Unfortunately, no format documentation exists, but the format is
simply a Makefile without variables in the form of:

``` Make
        source1.d source2.d source3.d

Ninja's tests also contain a bit of information:

Outputting both formats would be helpful, GDC has `-fdeps=` and `-fmake-deps=`
for that (with the latter option leading to a crash unfortunately).

See also the original bug report against LDC:

Nov 23 2016