google / kati

An experimental GNU make clone
Apache License 2.0
941 stars 111 forks source link

Fix crash when using --empty_ninja_file #240

Closed Colecf closed 3 years ago

Colecf commented 3 years ago

This bug was introduced in commit bca0a69ffd7045e33bd2e42e795cc0ade6f81c69. EmitNode() used to always be called, but after that commit, EmitNode() is no longer called when using --empty_ninja_file. EmitNode() has the side effect of setting defaulttarget, which was then needed later on.

However it turns out that defaulttarget is not actually needed when using --empty_ninja_file, so moving the code that uses it into the check that that flag is not provided fixes the issue.