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.
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.