www.digitalmars.com         C & C++   DMDScript  

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

https://issues.dlang.org/show_bug.cgi?id=16746

          Issue ID: 16746
           Summary: Please output Makefile-style depfiles for ninja and
                    make
           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
the_generated_file.o:
        source1.d source2.d source3.d
```

Ninja's tests also contain a bit of information:
https://github.com/ninja-build/ninja/blob/master/src/depfile_parser_test.cc

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

See also the original bug report against LDC:
https://github.com/ldc-developers/ldc/issues/1802

--
Nov 23 2016