ninja-build / ninja

a small build system with a focus on speed
https://ninja-build.org/
Apache License 2.0
11.33k stars 1.62k forks source link

depfile parser could be smarter about linebreaks #876

Open nico opened 10 years ago

nico commented 10 years ago
rule cgt
   depfile = c.d
   command = touch a; touch b; 
      echo "a: /usr/bin/ls" > c.d; $
      echo "b: /usr/bin/ls" >> c.d

build a b: cgt

This generates a depfile looking like

a: /usr/bin/ls
b: /usr/bin/ls

Ninja currently thinks that a is the output, and /usr/bin/ls, b (ninja strips the trailing ':' for some reason), and /usr/bin/ls are inputs. Instead, it should only read things on the first line as inputs for a (with "\\\n" being a line continuation character).

One issue with this is that gcc -MMD -MP -MF foo.d output will then count as having multiple outputs in the depfile. If that's an issue in practice, maybe outputs with 0 inputs could be silently skipped.

nico commented 10 years ago

Hm, both gcc's output and the thread I got this from ( https://groups.google.com/forum/#!topic/ninja-build/IGIZqyYq0AM ) add a completely empty line between outputs, so that might be easier than tracking line continuations.

nico commented 10 years ago

Oh hey, #704 is related to this.